diff mbox series

[2/4] lib/logic_iomem: fix sparse warnings

Message ID 20210625103437.8ab400c16323.Ic4ba1a600f837d01bf592fad52f55fe52c063388@changeid
State Accepted
Headers show
Series [1/4] um: make PCI emulation driver init/exit static | expand

Commit Message

Johannes Berg June 25, 2021, 8:34 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

A couple of sparse warnings happened here due to casts on
the prints, a missing static and a missing include. Fix
all of them.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 lib/logic_iomem.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Anton Ivanov June 25, 2021, 9:16 a.m. UTC | #1
On 25/06/2021 09:34, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> A couple of sparse warnings happened here due to casts on
> the prints, a missing static and a missing include. Fix
> all of them.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: ca2e334232b6 ("lib: add iomem emulation (logic_iomem)")
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>   lib/logic_iomem.c | 16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c
> index b76b92dd0f1f..9bdfde0c0f86 100644
> --- a/lib/logic_iomem.c
> +++ b/lib/logic_iomem.c
> @@ -6,6 +6,7 @@
>   #include <linux/types.h>
>   #include <linux/slab.h>
>   #include <linux/logic_iomem.h>
> +#include <asm/io.h>
>   
>   struct logic_iomem_region {
>   	const struct resource *res;
> @@ -78,7 +79,7 @@ static void __iomem *real_ioremap(phys_addr_t offset, size_t size)
>   static void real_iounmap(void __iomem *addr)
>   {
>   	WARN(1, "invalid iounmap for addr 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   }
>   #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
>   
> @@ -172,14 +173,15 @@ EXPORT_SYMBOL(iounmap);
>   static u##sz real_raw_read ## op(const volatile void __iomem *addr)	\
>   {									\
>   	WARN(1, "Invalid read" #op " at address %llx\n",		\
> -	     (unsigned long long)addr);					\
> +	     (unsigned long long __force)addr);				\
>   	return (u ## sz)~0ULL;						\
>   }									\
>   									\
> -void real_raw_write ## op(u ## sz val, volatile void __iomem *addr)	\
> +static void real_raw_write ## op(u ## sz val,				\
> +				 volatile void __iomem *addr)		\
>   {									\
>   	WARN(1, "Invalid writeq" #op " of 0x%llx at address %llx\n",	\
> -	     (unsigned long long)val, (unsigned long long)addr);	\
> +	     (unsigned long long)val, (unsigned long long __force)addr);\
>   }									\
>   
>   MAKE_FALLBACK(b, 8);
> @@ -192,14 +194,14 @@ MAKE_FALLBACK(q, 64);
>   static void real_memset_io(volatile void __iomem *addr, int value, size_t size)
>   {
>   	WARN(1, "Invalid memset_io at address 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   }
>   
>   static void real_memcpy_fromio(void *buffer, const volatile void __iomem *addr,
>   			       size_t size)
>   {
>   	WARN(1, "Invalid memcpy_fromio at address 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   
>   	memset(buffer, 0xff, size);
>   }
> @@ -208,7 +210,7 @@ static void real_memcpy_toio(volatile void __iomem *addr, const void *buffer,
>   			     size_t size)
>   {
>   	WARN(1, "Invalid memcpy_toio at address 0x%llx\n",
> -	     (unsigned long long)addr);
> +	     (unsigned long long __force)addr);
>   }
>   #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
>   
> 

Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
diff mbox series

Patch

diff --git a/lib/logic_iomem.c b/lib/logic_iomem.c
index b76b92dd0f1f..9bdfde0c0f86 100644
--- a/lib/logic_iomem.c
+++ b/lib/logic_iomem.c
@@ -6,6 +6,7 @@ 
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/logic_iomem.h>
+#include <asm/io.h>
 
 struct logic_iomem_region {
 	const struct resource *res;
@@ -78,7 +79,7 @@  static void __iomem *real_ioremap(phys_addr_t offset, size_t size)
 static void real_iounmap(void __iomem *addr)
 {
 	WARN(1, "invalid iounmap for addr 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 }
 #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */
 
@@ -172,14 +173,15 @@  EXPORT_SYMBOL(iounmap);
 static u##sz real_raw_read ## op(const volatile void __iomem *addr)	\
 {									\
 	WARN(1, "Invalid read" #op " at address %llx\n",		\
-	     (unsigned long long)addr);					\
+	     (unsigned long long __force)addr);				\
 	return (u ## sz)~0ULL;						\
 }									\
 									\
-void real_raw_write ## op(u ## sz val, volatile void __iomem *addr)	\
+static void real_raw_write ## op(u ## sz val,				\
+				 volatile void __iomem *addr)		\
 {									\
 	WARN(1, "Invalid writeq" #op " of 0x%llx at address %llx\n",	\
-	     (unsigned long long)val, (unsigned long long)addr);	\
+	     (unsigned long long)val, (unsigned long long __force)addr);\
 }									\
 
 MAKE_FALLBACK(b, 8);
@@ -192,14 +194,14 @@  MAKE_FALLBACK(q, 64);
 static void real_memset_io(volatile void __iomem *addr, int value, size_t size)
 {
 	WARN(1, "Invalid memset_io at address 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 }
 
 static void real_memcpy_fromio(void *buffer, const volatile void __iomem *addr,
 			       size_t size)
 {
 	WARN(1, "Invalid memcpy_fromio at address 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 
 	memset(buffer, 0xff, size);
 }
@@ -208,7 +210,7 @@  static void real_memcpy_toio(volatile void __iomem *addr, const void *buffer,
 			     size_t size)
 {
 	WARN(1, "Invalid memcpy_toio at address 0x%llx\n",
-	     (unsigned long long)addr);
+	     (unsigned long long __force)addr);
 }
 #endif /* CONFIG_LOGIC_IOMEM_FALLBACK */