Re: [PATCH v2] mtd: physmap: physmap-bt1-rom: Fix __iomem addrspace removal warning

From: Miquel Raynal
Date: Mon Dec 07 2020 - 06:16:53 EST


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@xxxxxxxxx/
> Signed-off-by: Serge Semin <Sergey.Semin@xxxxxxxxxxxxxxxxxxxx>
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Cc: Alexey Malahov <Alexey.Malahov@xxxxxxxxxxxxxxxxxxxx>
> Cc: Pavel Parkhomenko <Pavel.Parkhomenko@xxxxxxxxxxxxxxxxxxxx>

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

Miquel