misc: habanalabs: goya: Omit pointless check ensuring addr is >=0
authorLee Jones <lee.jones@linaro.org>
Wed, 1 Jul 2020 08:58:39 +0000 (09:58 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Jul 2020 13:05:36 +0000 (15:05 +0200)
Seeing as 'addr' is unsigned, it would be impossible for the assigned
value to be anything other than zero or positive.

Squashes the following W=1 warnings:

 drivers/misc/habanalabs/goya/goya.c: In function ‘goya_debugfs_read32’:
 drivers/misc/habanalabs/goya/goya.c:3945:19: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
 3945 | } else if ((addr >= DRAM_PHYS_BASE) &&
 | ^~
 drivers/misc/habanalabs/goya/goya.c: In function ‘goya_debugfs_write32’:
 drivers/misc/habanalabs/goya/goya.c:4002:19: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
 4002 | } else if ((addr >= DRAM_PHYS_BASE) &&
 | ^~
 drivers/misc/habanalabs/goya/goya.c: In function ‘goya_debugfs_read64’:
 drivers/misc/habanalabs/goya/goya.c:4047:19: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
 4047 | } else if ((addr >= DRAM_PHYS_BASE) &&
 | ^~
 drivers/misc/habanalabs/goya/goya.c: In function ‘goya_debugfs_write64’:
 drivers/misc/habanalabs/goya/goya.c:4091:19: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
 4091 | } else if ((addr >= DRAM_PHYS_BASE) &&
 | ^~
 drivers/misc/habanalabs/pci.c:328: warning: Excess function parameter 'dma_mask' description in 'hl_pci_set_dma_mask'
 drivers/misc/habanalabs/goya/goya_coresight.c: In function ‘goya_debug_coresight’:
 drivers/misc/habanalabs/goya/goya_coresight.c:643:6: warning: variable ‘val’ set but not used [-Wunused-but-set-variable]
 643 | u32 val;
 | ^~~

Cc: Oded Gabbay <oded.gabbay@gmail.com>
Cc: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Link: https://lore.kernel.org/r/20200701085853.164358-7-lee.jones@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/habanalabs/goya/goya.c

index 0d2952b..a4a20e2 100644 (file)
@@ -3942,8 +3942,7 @@ static int goya_debugfs_read32(struct hl_device *hdev, u64 addr, u32 *val)
                *val = readl(hdev->pcie_bar[SRAM_CFG_BAR_ID] +
                                (addr - SRAM_BASE_ADDR));
 
-       } else if ((addr >= DRAM_PHYS_BASE) &&
-                       (addr < DRAM_PHYS_BASE + hdev->asic_prop.dram_size)) {
+       } else if (addr < DRAM_PHYS_BASE + hdev->asic_prop.dram_size) {
 
                u64 bar_base_addr = DRAM_PHYS_BASE +
                                (addr & ~(prop->dram_pci_bar_size - 0x1ull));
@@ -3999,8 +3998,7 @@ static int goya_debugfs_write32(struct hl_device *hdev, u64 addr, u32 val)
                writel(val, hdev->pcie_bar[SRAM_CFG_BAR_ID] +
                                        (addr - SRAM_BASE_ADDR));
 
-       } else if ((addr >= DRAM_PHYS_BASE) &&
-                       (addr < DRAM_PHYS_BASE + hdev->asic_prop.dram_size)) {
+       } else if (addr < DRAM_PHYS_BASE + hdev->asic_prop.dram_size) {
 
                u64 bar_base_addr = DRAM_PHYS_BASE +
                                (addr & ~(prop->dram_pci_bar_size - 0x1ull));
@@ -4044,9 +4042,8 @@ static int goya_debugfs_read64(struct hl_device *hdev, u64 addr, u64 *val)
                *val = readq(hdev->pcie_bar[SRAM_CFG_BAR_ID] +
                                (addr - SRAM_BASE_ADDR));
 
-       } else if ((addr >= DRAM_PHYS_BASE) &&
-                  (addr <=
-                   DRAM_PHYS_BASE + hdev->asic_prop.dram_size - sizeof(u64))) {
+       } else if (addr <=
+                  DRAM_PHYS_BASE + hdev->asic_prop.dram_size - sizeof(u64)) {
 
                u64 bar_base_addr = DRAM_PHYS_BASE +
                                (addr & ~(prop->dram_pci_bar_size - 0x1ull));
@@ -4088,9 +4085,8 @@ static int goya_debugfs_write64(struct hl_device *hdev, u64 addr, u64 val)
                writeq(val, hdev->pcie_bar[SRAM_CFG_BAR_ID] +
                                        (addr - SRAM_BASE_ADDR));
 
-       } else if ((addr >= DRAM_PHYS_BASE) &&
-                  (addr <=
-                   DRAM_PHYS_BASE + hdev->asic_prop.dram_size - sizeof(u64))) {
+       } else if (addr <=
+                  DRAM_PHYS_BASE + hdev->asic_prop.dram_size - sizeof(u64)) {
 
                u64 bar_base_addr = DRAM_PHYS_BASE +
                                (addr & ~(prop->dram_pci_bar_size - 0x1ull));