mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning
PATCH 1/1 mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning
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 >>)"
Quoted 1 line
Quoted 1 line
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.
--- drivers/mtd/maps/physmap-bt1-rom.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/maps/physmap-bt1-rom.c +4 -4
@@ -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);
Signature · 1 line
2.29.2
Quoted 13 lines · Serge Semin
sparse is unhappy with us casting the
__iomemaddress space pointer to a type with no address space attribute specified:"sparse warnings: (new ones prefixed by >>)"
Quoted 1 line
Quoted 1 line
drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expressionIndeed 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.
Quoted 6 lines
Fixes b3e79e7682e0 ("mtd: physmap: Add Baikal-T1 physically mapped ROM support")Signed-off-by Serge Semin <[email protected]>Reported-by kernel test robot <[email protected]>Cc Alexey Malahov <[email protected]>Cc Pavel Parkhomenko <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.
Miquel
PATCH v2 1/1 mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning
In reply to Serge Seminsparse 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 >>)"
Quoted 1 line
Quoted 1 line
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.
---
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(-)
drivers/mtd/maps/physmap-bt1-rom.c +4 -4
@@ -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);
Signature · 6 lines
2.29.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 14 lines · Serge Semin
sparse is unhappy with us casting the
__iomemaddress space pointer to a type with no address space attribute specified:"sparse warnings: (new ones prefixed by >>)"
Quoted 1 line
Quoted 1 line
drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expressionIndeed 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 thebt1_rom_map_read()method for unification.
Quoted 6 lines
Fixes b3e79e7682e0 ("mtd: physmap: Add Baikal-T1 physically mapped ROM support")Signed-off-by Serge Semin <[email protected]>Reported-by kernel test robot <[email protected]>Cc Alexey Malahov <[email protected]>Cc Pavel Parkhomenko <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/