Skip to content

Commit c1d55d5

Browse files
committed
asm-generic/io.h: Fix sparse warnings on big-endian architectures
On big-endian architectures like OpenRISC, sparse outputs below warnings on asm-generic/io.h. This is due to io statements like: __raw_writel(cpu_to_le32(value), PCI_IOBASE + addr); The __raw_writel() function expects native endianness, however cpu_to_le32() returns __le32. On little-endian machines these match up and there is no issue. However, on big-endian we get warnings, for IO that is defined as little-endian the mismatch is expected. The fix I propose is to __force to native endian. Warnings: ./include/asm-generic/io.h:166:15: warning: cast to restricted __le16 ./include/asm-generic/io.h:166:15: warning: cast to restricted __le16 ./include/asm-generic/io.h:166:15: warning: cast to restricted __le16 ./include/asm-generic/io.h:166:15: warning: cast to restricted __le16 ./include/asm-generic/io.h:179:15: warning: cast to restricted __le32 ./include/asm-generic/io.h:179:15: warning: cast to restricted __le32 ./include/asm-generic/io.h:179:15: warning: cast to restricted __le32 ./include/asm-generic/io.h:179:15: warning: cast to restricted __le32 ./include/asm-generic/io.h:179:15: warning: cast to restricted __le32 ./include/asm-generic/io.h:179:15: warning: cast to restricted __le32 ./include/asm-generic/io.h:215:22: warning: incorrect type in argument 1 (different base types) ./include/asm-generic/io.h:215:22: expected unsigned short [usertype] value ./include/asm-generic/io.h:215:22: got restricted __le16 [usertype] ./include/asm-generic/io.h:225:22: warning: incorrect type in argument 1 (different base types) ./include/asm-generic/io.h:225:22: expected unsigned int [usertype] value ./include/asm-generic/io.h:225:22: got restricted __le32 [usertype] Signed-off-by: Stafford Horne <[email protected]> Acked-by: Arnd Bergmann <[email protected]>
1 parent c28b274 commit c1d55d5

File tree

1 file changed

+8
-8
lines changed
  • include/asm-generic

1 file changed

+8
-8
lines changed

include/asm-generic/io.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static inline u16 readw(const volatile void __iomem *addr)
163163
u16 val;
164164

165165
__io_br();
166-
val = __le16_to_cpu(__raw_readw(addr));
166+
val = __le16_to_cpu((__le16 __force)__raw_readw(addr));
167167
__io_ar(val);
168168
return val;
169169
}
@@ -176,7 +176,7 @@ static inline u32 readl(const volatile void __iomem *addr)
176176
u32 val;
177177

178178
__io_br();
179-
val = __le32_to_cpu(__raw_readl(addr));
179+
val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
180180
__io_ar(val);
181181
return val;
182182
}
@@ -212,7 +212,7 @@ static inline void writeb(u8 value, volatile void __iomem *addr)
212212
static inline void writew(u16 value, volatile void __iomem *addr)
213213
{
214214
__io_bw();
215-
__raw_writew(cpu_to_le16(value), addr);
215+
__raw_writew((u16 __force)cpu_to_le16(value), addr);
216216
__io_aw();
217217
}
218218
#endif
@@ -222,7 +222,7 @@ static inline void writew(u16 value, volatile void __iomem *addr)
222222
static inline void writel(u32 value, volatile void __iomem *addr)
223223
{
224224
__io_bw();
225-
__raw_writel(__cpu_to_le32(value), addr);
225+
__raw_writel((u32 __force)__cpu_to_le32(value), addr);
226226
__io_aw();
227227
}
228228
#endif
@@ -474,7 +474,7 @@ static inline u16 _inw(unsigned long addr)
474474
u16 val;
475475

476476
__io_pbr();
477-
val = __le16_to_cpu(__raw_readw(PCI_IOBASE + addr));
477+
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
478478
__io_par(val);
479479
return val;
480480
}
@@ -487,7 +487,7 @@ static inline u32 _inl(unsigned long addr)
487487
u32 val;
488488

489489
__io_pbr();
490-
val = __le32_to_cpu(__raw_readl(PCI_IOBASE + addr));
490+
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
491491
__io_par(val);
492492
return val;
493493
}
@@ -508,7 +508,7 @@ static inline void _outb(u8 value, unsigned long addr)
508508
static inline void _outw(u16 value, unsigned long addr)
509509
{
510510
__io_pbw();
511-
__raw_writew(cpu_to_le16(value), PCI_IOBASE + addr);
511+
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
512512
__io_paw();
513513
}
514514
#endif
@@ -518,7 +518,7 @@ static inline void _outw(u16 value, unsigned long addr)
518518
static inline void _outl(u32 value, unsigned long addr)
519519
{
520520
__io_pbw();
521-
__raw_writel(cpu_to_le32(value), PCI_IOBASE + addr);
521+
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
522522
__io_paw();
523523
}
524524
#endif

0 commit comments

Comments
 (0)