linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning
@ 2020-11-12 18:00 Serge Semin
  2020-11-19 21:07 ` Miquel Raynal
  2020-11-25  7:26 ` [PATCH v2] " Serge Semin
  0 siblings, 2 replies; 4+ messages in thread
From: Serge Semin @ 2020-11-12 18:00 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: Serge Semin, Serge Semin, kernel test robot, Alexey Malahov,
	Pavel Parkhomenko, linux-mtd, linux-kernel

sparse is unhappy with us casting the __iomem address space pointer to
a type with no address space attribute specified:

"sparse warnings: (new ones prefixed by >>)"
>> drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

Indeed we perform the __iomem-less type casting but to an integer
variable. The integer variable isn't dereferenced then, so the casting is
safe and won't cause any problem. But in order to make sparse happy let's
fix the warning just by converting the local "shift" and "chunk" variables
to the "unsigned int" type. Add the same fix to the bt1_rom_map_read()
method for unification.

Fixes: b3e79e7682e0 ("mtd: physmap: Add Baikal-T1 physically mapped ROM support")
Link: https://lore.kernel.org/lkml/202011021254.XC70BaQT-lkp@intel.com/
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reported-by: kernel test robot <lkp@intel.com>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru>
---
 drivers/mtd/maps/physmap-bt1-rom.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/maps/physmap-bt1-rom.c b/drivers/mtd/maps/physmap-bt1-rom.c
index 27cfe1c63a2e..b7fd5a3759d0 100644
--- a/drivers/mtd/maps/physmap-bt1-rom.c
+++ b/drivers/mtd/maps/physmap-bt1-rom.c
@@ -31,12 +31,12 @@ static map_word __xipram bt1_rom_map_read(struct map_info *map,
 					  unsigned long ofs)
 {
 	void __iomem *src = map->virt + ofs;
-	unsigned long shift;
+	unsigned int shift;
 	map_word ret;
 	u32 data;
 
 	/* Read data within offset dword. */
-	shift = (unsigned long)src & 0x3;
+	shift = (unsigned int)src & 0x3;
 	data = readl_relaxed(src - shift);
 	if (!shift) {
 		ret.x[0] = data;
@@ -60,7 +60,7 @@ static void __xipram bt1_rom_map_copy_from(struct map_info *map,
 					   ssize_t len)
 {
 	void __iomem *src = map->virt + from;
-	ssize_t shift, chunk;
+	unsigned int shift, chunk;
 	u32 data;
 
 	if (len <= 0 || from >= map->size)
@@ -75,7 +75,7 @@ static void __xipram bt1_rom_map_copy_from(struct map_info *map,
 	 * up into the next three stages: unaligned head, aligned body,
 	 * unaligned tail.
 	 */
-	shift = (ssize_t)src & 0x3;
+	shift = (unsigned int)src & 0x3;
 	if (shift) {
 		chunk = min_t(ssize_t, 4 - shift, len);
 		data = readl_relaxed(src - shift);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning
  2020-11-12 18:00 [PATCH] mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning Serge Semin
@ 2020-11-19 21:07 ` Miquel Raynal
  2020-11-25  7:26 ` [PATCH v2] " Serge Semin
  1 sibling, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2020-11-19 21:07 UTC (permalink / raw)
  To: Serge Semin, Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: kernel test robot, linux-kernel, Serge Semin, Alexey Malahov,
	linux-mtd, Pavel Parkhomenko

On Thu, 2020-11-12 at 18:00:37 UTC, Serge Semin wrote:
> sparse is unhappy with us casting the __iomem address space pointer to
> a type with no address space attribute specified:
> 
> "sparse warnings: (new ones prefixed by >>)"
> >> drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression
> 
> Indeed we perform the __iomem-less type casting but to an integer
> variable. The integer variable isn't dereferenced then, so the casting is
> safe and won't cause any problem. But in order to make sparse happy let's
> fix the warning just by converting the local "shift" and "chunk" variables
> to the "unsigned int" type. Add the same fix to the bt1_rom_map_read()
> method for unification.
> 
> Fixes: b3e79e7682e0 ("mtd: physmap: Add Baikal-T1 physically mapped ROM support")
> Link: https://lore.kernel.org/lkml/202011021254.XC70BaQT-lkp@intel.com/
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> Reported-by: kernel test robot <lkp@intel.com>
> Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
> Cc: Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning
  2020-11-12 18:00 [PATCH] mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning Serge Semin
  2020-11-19 21:07 ` Miquel Raynal
@ 2020-11-25  7:26 ` Serge Semin
  2020-12-07 11:15   ` Miquel Raynal
  1 sibling, 1 reply; 4+ messages in thread
From: Serge Semin @ 2020-11-25  7:26 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: Serge Semin, Alexey Malahov, Ramil Zaripov, Pavel Parkhomenko,
	kernel test robot, linux-mtd, linux-kernel

sparse is unhappy with us casting the __iomem address space pointer to
a type with no address space attribute specified:

"sparse warnings: (new ones prefixed by >>)"
>> drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

Indeed we perform the __iomem-less type casting but to an integer
variable. The integer variable isn't dereferenced then, so the casting is
safe and won't cause any problem. But in order to make sparse happy and
keep the code coherent let's fix the warning by converting the local
"shift" and "chunk" variables to the "unsigned int" type (since their
value won't ever exceed three) and cast the __iomem-pointers to uintptr_t.
Add the same fix to the bt1_rom_map_read() method for unification.

Fixes: b3e79e7682e0 ("mtd: physmap: Add Baikal-T1 physically mapped ROM support")
Link: https://lore.kernel.org/lkml/202011021254.XC70BaQT-lkp@intel.com/
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reported-by: kernel test robot <lkp@intel.com>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru>

---

Link: https://lore.kernel.org/lkml/20201120113929.0aff2f32@canb.auug.org.au/
Changelog v2:
- Cast the pointers to uintptr_t instead of unsiged int so not to
  cause the "cast from pointer to integer of different size" warning on
  64-bits platforms.
---
 drivers/mtd/maps/physmap-bt1-rom.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/maps/physmap-bt1-rom.c b/drivers/mtd/maps/physmap-bt1-rom.c
index 27cfe1c63a2e..a35450002284 100644
--- a/drivers/mtd/maps/physmap-bt1-rom.c
+++ b/drivers/mtd/maps/physmap-bt1-rom.c
@@ -31,12 +31,12 @@ static map_word __xipram bt1_rom_map_read(struct map_info *map,
 					  unsigned long ofs)
 {
 	void __iomem *src = map->virt + ofs;
-	unsigned long shift;
+	unsigned int shift;
 	map_word ret;
 	u32 data;
 
 	/* Read data within offset dword. */
-	shift = (unsigned long)src & 0x3;
+	shift = (uintptr_t)src & 0x3;
 	data = readl_relaxed(src - shift);
 	if (!shift) {
 		ret.x[0] = data;
@@ -60,7 +60,7 @@ static void __xipram bt1_rom_map_copy_from(struct map_info *map,
 					   ssize_t len)
 {
 	void __iomem *src = map->virt + from;
-	ssize_t shift, chunk;
+	unsigned int shift, chunk;
 	u32 data;
 
 	if (len <= 0 || from >= map->size)
@@ -75,7 +75,7 @@ static void __xipram bt1_rom_map_copy_from(struct map_info *map,
 	 * up into the next three stages: unaligned head, aligned body,
 	 * unaligned tail.
 	 */
-	shift = (ssize_t)src & 0x3;
+	shift = (uintptr_t)src & 0x3;
 	if (shift) {
 		chunk = min_t(ssize_t, 4 - shift, len);
 		data = readl_relaxed(src - shift);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning
  2020-11-25  7:26 ` [PATCH v2] " Serge Semin
@ 2020-12-07 11:15   ` Miquel Raynal
  0 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2020-12-07 11:15 UTC (permalink / raw)
  To: Serge Semin, Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: kernel test robot, Ramil Zaripov, linux-kernel, Serge Semin,
	Alexey Malahov, linux-mtd, Pavel Parkhomenko

On Wed, 2020-11-25 at 07:26:40 UTC, Serge Semin wrote:
> sparse is unhappy with us casting the __iomem address space pointer to
> a type with no address space attribute specified:
> 
> "sparse warnings: (new ones prefixed by >>)"
> >> drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression
> 
> Indeed we perform the __iomem-less type casting but to an integer
> variable. The integer variable isn't dereferenced then, so the casting is
> safe and won't cause any problem. But in order to make sparse happy and
> keep the code coherent let's fix the warning by converting the local
> "shift" and "chunk" variables to the "unsigned int" type (since their
> value won't ever exceed three) and cast the __iomem-pointers to uintptr_t.
> Add the same fix to the bt1_rom_map_read() method for unification.
> 
> Fixes: b3e79e7682e0 ("mtd: physmap: Add Baikal-T1 physically mapped ROM support")
> Link: https://lore.kernel.org/lkml/202011021254.XC70BaQT-lkp@intel.com/
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
> Reported-by: kernel test robot <lkp@intel.com>
> Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
> Cc: Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-07 11:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 18:00 [PATCH] mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning Serge Semin
2020-11-19 21:07 ` Miquel Raynal
2020-11-25  7:26 ` [PATCH v2] " Serge Semin
2020-12-07 11:15   ` Miquel Raynal

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).