Thread (2 messages) 2 messages, 1 author, 2020-07-08

Re: [PATCH v1] alpha: io: Make sparse happy about bitwise types

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2020-07-08 16:23:26

On Thu, Jun 18, 2020 at 04:51:17PM +0300, Andy Shevchenko wrote:
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.
Any comment on this so far?
quoted hunk ↗ jump to hunk
Fixes: 25534eb77078 ("alpha: add io{read,write}{16,32}be functions")
Reported-by: kernel test robot <redacted>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/alpha/include/asm/io.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index a4d0c19f1e79..9529656c24bb 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -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
-- 
2.27.0.rc2
-- 
With Best Regards,
Andy Shevchenko

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help