alpha: io: Make sparse happy about bitwise types
PATCH 1/1 alpha: io: Make sparse happy about bitwise types
On Alpha the IO accessors are using plain unsigned types, such as uXX. But Alpha can be configured to any endianess and implementation of BE IO accessors, such as iowrite32be(), require endianess conversion. This conversion, when done via cpu_to*() and *_to_cpu() helpers, uses bitwise types of which sparse is not happy.
8250_dwlib.c:45:17: sparse: sparse: incorrect type in argument 1 (different base types)
8250_dwlib.c:45:17: sparse: expected unsigned int [usertype]
8250_dwlib.c:45:17: sparse: got restricted __be32 [usertype]
One way is to use a lot of ifdeffery to properly use swab*() combination with writel() or so, another is much simpler, i.e. forcing types, especially taking into consideration the commit message of the original commit for that API.
--- arch/alpha/include/asm/io.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/alpha/include/asm/io.h +2 -2
@@ -491,8 +491,8 @@ extern inline void writeq(u64 b, volatile void __iomem *addr)#define ioread16be (p) be16_to_cpu(ioread16(p))#define ioread32be (p) be32_to_cpu(ioread32(p)) -#define iowrite16be (v,p) iowrite16(cpu_to_be16(v), (p)) -#define iowrite32be (v,p) iowrite32(cpu_to_be32(v), (p)) +#define iowrite16be (v,p) iowrite16((__force u16)cpu_to_be16(v), (p)) +#define iowrite32be (v,p) iowrite32((__force u32)cpu_to_be32(v), (p))#define inb_p inb#define inw_p inw
Signature · 1 line
2.27.0.rc2
Quoted 6 lines · Andy Shevchenko
On Alpha the IO accessors are using plain unsigned types, such as uXX. But Alpha can be configured to any endianess and implementation of BE IO accessors, such as
iowrite32be(), require endianess conversion. This conversion, when done via cpu_to*() and*_to_cpu()helpers, uses bitwise types of which sparse is not happy.
Quoted 7 lines
8250_dwlib.c:45:17: sparse: sparse: incorrect type in argument 1 (different base types)
8250_dwlib.c:45:17: sparse: expected unsigned int [usertype]
8250_dwlib.c:45:17: sparse: got restricted__be32[usertype]One way is to use a lot of ifdeffery to properly use swab*() combination with
writel()or so, another is much simpler, i.e. forcing types, especially taking into consideration the commit message of the original commit for that API.
Any comment on this so far?
Quoted 25 lines
Fixes 25534eb77078 ("alpha: add io{read,write}{16,32}be functions")Reported-by kernel test robot <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- arch/alpha/include/asm/io.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/alpha/include/asm/io.h +2
-2@@ -491,8 +491,8 @@ extern inline void writeq(u64 b, volatile void __iomem *addr)#define ioread16be (p) be16_to_cpu(ioread16(p))#define ioread32be (p) be32_to_cpu(ioread32(p)) -#define iowrite16be (v,p) iowrite16(cpu_to_be16(v), (p)) -#define iowrite32be (v,p) iowrite32(cpu_to_be32(v), (p)) +#define iowrite16be (v,p) iowrite16((__force u16)cpu_to_be16(v), (p)) +#define iowrite32be (v,p) iowrite32((__force u32)cpu_to_be32(v), (p))#define inb_p inb#define inw_p inwSignature · 1 line
2.27.0.rc2
Signature · 2 lines
With Best Regards, Andy Shevchenko