linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: arnd@arndb.de, gregkh@linuxfoundation.org
Cc: Oded Gabbay <oded.gabbay@gmail.com>,
	Tomer Tayar <ttayar@habana.ai>, Lee Jones <lee.jones@linaro.org>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/20] misc: habanalabs: goya: Omit pointless check ensuring addr is >=0
Date: Mon, 29 Jun 2020 15:04:28 +0100	[thread overview]
Message-ID: <20200629140442.1043957-7-lee.jones@linaro.org> (raw)
In-Reply-To: <20200629140442.1043957-1-lee.jones@linaro.org>

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>
---
 drivers/misc/habanalabs/goya/goya.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c
index 0d2952bb58dfb..a4a20e27ed3b4 100644
--- a/drivers/misc/habanalabs/goya/goya.c
+++ b/drivers/misc/habanalabs/goya/goya.c
@@ -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));
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-06-29 14:07 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29 14:04 [PATCH 00/20] Fix a bunch more W=1 warnings in Misc Lee Jones
2020-06-29 14:04 ` [PATCH 01/20] misc: pti: Repair kerneldoc formatting issues Lee Jones
2020-06-29 14:04 ` [PATCH 02/20] misc: pti: Remove unparsable empty line in function header Lee Jones
2020-06-29 14:04 ` [PATCH 03/20] misc: habanalabs: firmware_if: Add missing 'fw_name' and 'dst' entries to " Lee Jones
2020-06-29 14:57   ` Oded Gabbay
2020-06-29 14:04 ` [PATCH 04/20] misc: habanalabs: pci: Fix a variety of kerneldoc issues Lee Jones
2020-06-29 14:58   ` Oded Gabbay
2020-06-29 14:04 ` [PATCH 05/20] misc: habanalabs: irq: Repair kerneldoc formatting issues Lee Jones
2020-06-29 14:59   ` Oded Gabbay
2020-06-29 14:04 ` Lee Jones [this message]
2020-06-29 15:00   ` [PATCH 06/20] misc: habanalabs: goya: Omit pointless check ensuring addr is >=0 Oded Gabbay
2020-06-29 14:04 ` [PATCH 07/20] misc: habanalabs: pci: Scrub documentation for non-present function argument Lee Jones
2020-06-29 15:00   ` Oded Gabbay
2020-06-29 14:04 ` [PATCH 08/20] misc: habanalabs: goya: goya_coresight: Remove set but unused variable 'val' Lee Jones
2020-06-29 15:01   ` Oded Gabbay
2020-06-29 14:04 ` [PATCH 09/20] misc: habanalabs: gaudi: Remove ill placed asterisk from kerneldoc header Lee Jones
2020-06-29 15:01   ` Oded Gabbay
2020-06-29 14:04 ` [PATCH 10/20] misc: habanalabs: gaudi: gaudi_security: Repair incorrectly named function arg Lee Jones
2020-06-29 15:02   ` Oded Gabbay
2020-06-29 16:23   ` [PATCH v2 " Lee Jones
2020-06-29 14:04 ` [PATCH 11/20] misc: enclosure: Fix some kerneldoc anomalies Lee Jones
2020-06-29 14:04 ` [PATCH 12/20] misc: lattice-ecp3-config: Remove set but clearly unused variable 'ret' Lee Jones
2020-06-29 14:04 ` [PATCH 13/20] misc: pch_phub: Provide descriptions for 'chip' argument Lee Jones
2020-06-29 14:04 ` [PATCH 14/20] misc: pch_phub: Remove superfluous descriptions to non-existent args 'offset_address' Lee Jones
2020-06-29 14:04 ` [PATCH 15/20] misc: enclosure: Update enclosure_remove_device() documentation to match reality Lee Jones
2020-06-29 14:04 ` [PATCH 16/20] misc: genwqe: card_base: Remove set but unused variable 'rc' Lee Jones
2020-06-30  7:17   ` haver
2020-06-30  7:42     ` Lee Jones
2020-06-30  8:03       ` haver
2020-06-30  8:12         ` Lee Jones
2020-06-29 14:04 ` [PATCH 17/20] misc: genwqe: card_base: Do not pass unused argument 'fatal_err' Lee Jones
2020-06-30  7:35   ` haver
2020-06-30  9:10     ` Lee Jones
2020-06-30  9:54       ` haver
2020-06-30 14:00         ` Lee Jones
2020-06-29 14:04 ` [PATCH 18/20] misc: genwqe: card_base: Whole host of kerneldoc fixes Lee Jones
2020-06-30  7:24   ` haver
2020-06-29 14:04 ` [PATCH 19/20] misc: genwqe: card_dev: " Lee Jones
2020-06-30  7:25   ` haver
2020-06-29 14:04 ` [PATCH 20/20] misc: genwqe: card_utils: Whole a plethora of documentation issues Lee Jones
2020-06-30  7:26   ` haver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200629140442.1043957-7-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oded.gabbay@gmail.com \
    --cc=ttayar@habana.ai \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).