Mailing List Archive

[PATCH] add __force tag to fb_readb, etc.
This patch fixes many sparse warnings on MIPS (and some other) platform.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/include/linux/fb.h b/include/linux/fb.h
index 2cb19e6..61562d7 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -823,14 +823,14 @@ struct fb_info {

#else

-#define fb_readb(addr) (*(volatile u8 *) (addr))
-#define fb_readw(addr) (*(volatile u16 *) (addr))
-#define fb_readl(addr) (*(volatile u32 *) (addr))
-#define fb_readq(addr) (*(volatile u64 *) (addr))
-#define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
-#define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
-#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
-#define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b))
+#define fb_readb(addr) (*(volatile u8 __force *) (addr))
+#define fb_readw(addr) (*(volatile u16 __force *) (addr))
+#define fb_readl(addr) (*(volatile u32 __force *) (addr))
+#define fb_readq(addr) (*(volatile u64 __force *) (addr))
+#define fb_writeb(b,addr) (*(volatile u8 __force *) (addr) = (b))
+#define fb_writew(b,addr) (*(volatile u16 __force *) (addr) = (b))
+#define fb_writel(b,addr) (*(volatile u32 __force *) (addr) = (b))
+#define fb_writeq(b,addr) (*(volatile u64 __force *) (addr) = (b))
#define fb_memset memset

#endif
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] add __force tag to fb_readb, etc. [ In reply to ]
On Sat, Feb 18, 2006 at 12:04:08AM +0900, Atsushi Nemoto wrote:
> This patch fixes many sparse warnings on MIPS (and some other) platform.

ITYM "hides". You've just lost anything resembling typechecking of
arguments; it might be wrong in the current form, but at least we
get a reminder of possible problems.

With __force you've lost _all_ warnings - anything goes. NAK. At the
very least, figure out what type should the argument be and add a
(non-force) cast to that before forcing it.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] add __force tag to fb_readb, etc. [ In reply to ]
>>>>> On Fri, 17 Feb 2006 16:12:47 +0000, Al Viro <viro@ftp.linux.org.uk> said:

viro> With __force you've lost _all_ warnings - anything goes. NAK.
viro> At the very least, figure out what type should the argument be
viro> and add a (non-force) cast to that before forcing it.

Thanks. Then how about this?

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/include/linux/fb.h b/include/linux/fb.h
index 2cb19e6..d1c81e2 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -823,14 +823,14 @@ struct fb_info {

#else

-#define fb_readb(addr) (*(volatile u8 *) (addr))
-#define fb_readw(addr) (*(volatile u16 *) (addr))
-#define fb_readl(addr) (*(volatile u32 *) (addr))
-#define fb_readq(addr) (*(volatile u64 *) (addr))
-#define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
-#define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
-#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
-#define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b))
+#define fb_readb(addr) (*(volatile u8 __force *)(const volatile u8 __iomem *)(addr))
+#define fb_readw(addr) (*(volatile u16 __force *)(const volatile u16 __iomem *)(addr))
+#define fb_readl(addr) (*(volatile u32 __force *)(const volatile u32 __iomem *)(addr))
+#define fb_readq(addr) (*(volatile u64 __force *)(const volatile u64 __iomem *)(addr))
+#define fb_writeb(b,addr) (*(volatile u8 __force *)(volatile u8 __iomem *)(addr) = (b))
+#define fb_writew(b,addr) (*(volatile u16 __force *)(volatile u16 __iomem *)(addr) = (b))
+#define fb_writel(b,addr) (*(volatile u32 __force *)(volatile u32 __iomem *)(addr) = (b))
+#define fb_writeq(b,addr) (*(volatile u64 __force *)(volatile u64 __iomem *)(addr) = (b))
#define fb_memset memset

#endif
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/