summaryrefslogtreecommitdiff
path: root/drivers/misc/genwqe/card_utils.c
diff options
context:
space:
mode:
authorFrank Haverkamp <haver@linux.vnet.ibm.com>2013-12-20 16:26:10 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-20 08:45:50 -0800
commit58d66ce732378fed7a35ca79c763057b8c1e8aed (patch)
tree377998e1088365050c9ceca0a9bb676c9e3986cf /drivers/misc/genwqe/card_utils.c
parent76f5adbcb371b01ae0ad42e55377d0579706fb20 (diff)
GenWQE: Fix endian issues detected by sparse
Fengguang Wu used CF=-D__CHECK_ENDIAN__ to check the GenWQE driver for endian issues. Sparse found a couple of those. Most of them were caused by not correctly handling __be64/32 and __u64/32. Those I was able to fix with appropriate castings. One more serious issue was the ATS entry in struct genwqe_ddcb_cmd. The kernel expected it in big-endian, but the type was defined __u64. I decided that it is better to keep the interface consistent using host endian byte-odering instead of having a mixture. With this change the kernel likes to see host endian byte order for the ATS entry. That would have been an interface change, if someone would have used the driver already. Since this is not the case, I hope it is ok to fix it now. For the genqwe_readq/writeq/readl/writel functions I enforced the casts. It still complains, as far as I can see, about some copy_to/from_user() usages: CHECK char-misc/drivers/misc/genwqe/card_dev.c char-misc/arch/x86/include/asm/uaccess.h:625:18: warning: incorrect type in argument 1 (different modifiers) char-misc/arch/x86/include/asm/uaccess.h:625:18: expected void *<noident> char-misc/arch/x86/include/asm/uaccess.h:625:18: got void const *from char-misc/arch/x86/include/asm/uaccess.h:625:18: warning: incorrect type in argument 1 (different modifiers) char-misc/arch/x86/include/asm/uaccess.h:625:18: expected void *<noident> char-misc/arch/x86/include/asm/uaccess.h:625:18: got void const *from char-misc/arch/x86/include/asm/uaccess.h:625:18: warning: incorrect type in argument 1 (different modifiers) char-misc/arch/x86/include/asm/uaccess.h:625:18: expected void *<noident> char-misc/arch/x86/include/asm/uaccess.h:625:18: got void const *from char-misc/arch/x86/include/asm/uaccess.h:625:18: warning: incorrect type in argument 1 (different modifiers) char-misc/arch/x86/include/asm/uaccess.h:625:18: expected void *<noident> char-misc/arch/x86/include/asm/uaccess.h:625:18: got void const *from CC [M] drivers/misc/genwqe/card_dev.o CHECK char-misc/drivers/misc/genwqe/card_ddcb.c char-misc/arch/x86/include/asm/uaccess.h:625:18: warning: incorrect type in argument 1 (different modifiers) char-misc/arch/x86/include/asm/uaccess.h:625:18: expected void *<noident> char-misc/arch/x86/include/asm/uaccess.h:625:18: got void const *from char-misc/arch/x86/include/asm/uaccess.h:625:18: warning: incorrect type in argument 1 (different modifiers) char-misc/arch/x86/include/asm/uaccess.h:625:18: expected void *<noident> char-misc/arch/x86/include/asm/uaccess.h:625:18: got void const *from CC [M] drivers/misc/genwqe/card_ddcb.o LD [M] drivers/misc/genwqe/genwqe_card.o I appreciate some help from you to figure out what is causig those, and making a proposal how to fix them. I included the missing header file to fix the implicit-function-declaration warning when using dynamic_hex_dump. Signed-off-by: Frank Haverkamp <haver@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/genwqe/card_utils.c')
-rw-r--r--drivers/misc/genwqe/card_utils.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/misc/genwqe/card_utils.c b/drivers/misc/genwqe/card_utils.c
index ff952bb81521..663157b3a0d4 100644
--- a/drivers/misc/genwqe/card_utils.c
+++ b/drivers/misc/genwqe/card_utils.c
@@ -59,7 +59,7 @@ int __genwqe_writeq(struct genwqe_dev *cd, u64 byte_offs, u64 val)
if (cd->mmio == NULL)
return -EIO;
- __raw_writeq(cpu_to_be64((val)), (cd->mmio + byte_offs));
+ __raw_writeq((__force u32)cpu_to_be64(val), cd->mmio + byte_offs);
return 0;
}
@@ -72,8 +72,6 @@ int __genwqe_writeq(struct genwqe_dev *cd, u64 byte_offs, u64 val)
*/
u64 __genwqe_readq(struct genwqe_dev *cd, u64 byte_offs)
{
- u64 val;
-
if (cd->err_inject & GENWQE_INJECT_HARDWARE_FAILURE)
return 0xffffffffffffffffull;
@@ -88,8 +86,7 @@ u64 __genwqe_readq(struct genwqe_dev *cd, u64 byte_offs)
if (cd->mmio == NULL)
return 0xffffffffffffffffull;
- val = be64_to_cpu(__raw_readq(cd->mmio + byte_offs));
- return val;
+ return be64_to_cpu((__force __be64)__raw_readq(cd->mmio + byte_offs));
}
/**
@@ -108,7 +105,7 @@ int __genwqe_writel(struct genwqe_dev *cd, u64 byte_offs, u32 val)
if (cd->mmio == NULL)
return -EIO;
- __raw_writel(cpu_to_be32((val)), cd->mmio + byte_offs);
+ __raw_writel((__force u32)cpu_to_be32(val), cd->mmio + byte_offs);
return 0;
}
@@ -127,7 +124,7 @@ u32 __genwqe_readl(struct genwqe_dev *cd, u64 byte_offs)
if (cd->mmio == NULL)
return 0xffffffff;
- return be32_to_cpu(__raw_readl(cd->mmio + byte_offs));
+ return be32_to_cpu((__force __be32)__raw_readl(cd->mmio + byte_offs));
}
/**