diff mbox series

net: smc91x: Fix pointer types

Message ID 20240516121142.181934-3-thorsten.blum@toblux.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: smc91x: Fix pointer types | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 921 this patch: 921
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 925 this patch: 925
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 926 this patch: 926
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 82 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-05-16--15-00 (tests: 1031)

Commit Message

Thorsten Blum May 16, 2024, 12:11 p.m. UTC
Use void __iomem pointers as parameters for mcf_insw() and mcf_outsw()
to align with the parameter types of readw() and writew().

Consistently call SMC_outsw(), SMC_outsb(), SMC_insw(), and SMC_insb()
with void __iomem pointers to address the following warnings reported by
kernel test robot:

drivers/net/ethernet/smsc/smc91x.c:590:9: sparse: warning: incorrect type in argument 1 (different address spaces)
drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    expected void *a
drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    got void [noderef] __iomem *
drivers/net/ethernet/smsc/smc91x.c:590:9: sparse: warning: incorrect type in argument 1 (different address spaces)
drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    expected void *a
drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    got void [noderef] __iomem *
drivers/net/ethernet/smsc/smc91x.c:590:9: sparse: warning: incorrect type in argument 1 (different address spaces)
drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    expected void *a
drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    got void [noderef] __iomem *
drivers/net/ethernet/smsc/smc91x.c:483:17: sparse: warning: incorrect type in argument 1 (different address spaces)
drivers/net/ethernet/smsc/smc91x.c:483:17: sparse:    expected void *a
drivers/net/ethernet/smsc/smc91x.c:483:17: sparse:    got void [noderef] __iomem *

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202405160853.3qyaSj8w-lkp@intel.com/
---
 drivers/net/ethernet/smsc/smc91x.h | 34 +++++++++++++++---------------
 1 file changed, 17 insertions(+), 17 deletions(-)

Comments

Andrew Lunn May 16, 2024, 2:13 p.m. UTC | #1
> -#define SMC_PUSH_DATA(lp, p, l)					\
> +#define SMC_PUSH_DATA(lp, p, l)						\
>  	do {								\
> -		if (SMC_32BIT(lp)) {				\
> +		void __iomem *__ioaddr = ioaddr;			\

ioaddr is not a parameter passed to this macro. 

> +		if (SMC_32BIT(lp)) {					\
>  			void *__ptr = (p);				\
>  			int __len = (l);				\
> -			void __iomem *__ioaddr = ioaddr;		\
>  			if (__len >= 2 && (unsigned long)__ptr & 2) {	\
>  				__len -= 2;				\
> -				SMC_outsw(ioaddr, DATA_REG(lp), __ptr, 1); \
> +				SMC_outsw(__ioaddr, DATA_REG(lp), __ptr, 1); \

You probably should use lp->base here, which is passed into this
macro, and should have the correct type.

> @@ -1072,7 +1072,7 @@ static const char * chip_ids[ 16 ] =  {
>  				 */					\
>  				__ptr -= 2;				\
>  				__len += 2;				\
> -				SMC_SET_PTR(lp,			\
> +				SMC_SET_PTR(lp,				\
>  					2|PTR_READ|PTR_RCV|PTR_AUTOINC); \
>  			}						\
>  			if (SMC_CAN_USE_DATACS && lp->datacs)		\

This is just a whitespace change. Please put that into a different
patch.

	Andrew
Thorsten Blum May 16, 2024, 3:13 p.m. UTC | #2
On 16. May 2024, at 16:13, Andrew Lunn <andrew@lunn.ch> wrote:
> -#define SMC_PUSH_DATA(lp, p, l) \
>> +#define SMC_PUSH_DATA(lp, p, l) \
>> do { \
>> - if (SMC_32BIT(lp)) { \
>> + void __iomem *__ioaddr = ioaddr; \
> 
> ioaddr is not a parameter passed to this macro.

Yes, most (all?) macros in this file rely on ioaddr being implicitly
defined in the surrounding scope.

> + if (SMC_32BIT(lp)) { \
>> void *__ptr = (p); \
>> int __len = (l); \
>> - void __iomem *__ioaddr = ioaddr; \
>> if (__len >= 2 && (unsigned long)__ptr & 2) { \
>> __len -= 2; \
>> - SMC_outsw(ioaddr, DATA_REG(lp), __ptr, 1); \
>> + SMC_outsw(__ioaddr, DATA_REG(lp), __ptr, 1); \
> 
> You probably should use lp->base here, which is passed into this
> macro, and should have the correct type.

ioaddr is lp->base:

	void __iomem *ioaddr = lp->base;

but the type information for ioaddr gets lost across multiple macro
boundaries which is why either __ioaddr or lp->base must be used when
calling the SMC_* macros. Both __ioaddr and lp->base work, but I guess
you prefer lp->base? I'm fine with both.

> @@ -1072,7 +1072,7 @@ static const char * chip_ids[ 16 ] =  {
>> */ \
>> __ptr -= 2; \
>> __len += 2; \
>> - SMC_SET_PTR(lp, \
>> + SMC_SET_PTR(lp, \
>> 2|PTR_READ|PTR_RCV|PTR_AUTOINC); \
>> } \
>> if (SMC_CAN_USE_DATACS && lp->datacs) \
> 
> This is just a whitespace change. Please put that into a different
> patch.

Ok, I'll change this in v2.

Thanks,
Thorsten
Nicolas Pitre May 16, 2024, 3:28 p.m. UTC | #3
On Thu, 16 May 2024, Thorsten Blum wrote:

> Use void __iomem pointers as parameters for mcf_insw() and mcf_outsw()
> to align with the parameter types of readw() and writew().
> 
> Consistently call SMC_outsw(), SMC_outsb(), SMC_insw(), and SMC_insb()
> with void __iomem pointers to address the following warnings reported by
> kernel test robot:
> 
> drivers/net/ethernet/smsc/smc91x.c:590:9: sparse: warning: incorrect type in argument 1 (different address spaces)
> drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    expected void *a
> drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    got void [noderef] __iomem *
> drivers/net/ethernet/smsc/smc91x.c:590:9: sparse: warning: incorrect type in argument 1 (different address spaces)
> drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    expected void *a
> drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    got void [noderef] __iomem *
> drivers/net/ethernet/smsc/smc91x.c:590:9: sparse: warning: incorrect type in argument 1 (different address spaces)
> drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    expected void *a
> drivers/net/ethernet/smsc/smc91x.c:590:9: sparse:    got void [noderef] __iomem *
> drivers/net/ethernet/smsc/smc91x.c:483:17: sparse: warning: incorrect type in argument 1 (different address spaces)
> drivers/net/ethernet/smsc/smc91x.c:483:17: sparse:    expected void *a
> drivers/net/ethernet/smsc/smc91x.c:483:17: sparse:    got void [noderef] __iomem *
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202405160853.3qyaSj8w-lkp@intel.com/

Acked-by: Nicolas Pitre <nico@fluxnic.net>

> ---
>  drivers/net/ethernet/smsc/smc91x.h | 34 +++++++++++++++---------------
>  1 file changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h
> index 45ef5ac0788a..204fbb5c975c 100644
> --- a/drivers/net/ethernet/smsc/smc91x.h
> +++ b/drivers/net/ethernet/smsc/smc91x.h
> @@ -142,14 +142,14 @@ static inline void _SMC_outw_align4(u16 val, void __iomem *ioaddr, int reg,
>  #define SMC_CAN_USE_32BIT	0
>  #define SMC_NOWAIT		1
>  
> -static inline void mcf_insw(void *a, unsigned char *p, int l)
> +static inline void mcf_insw(void __iomem *a, unsigned char *p, int l)
>  {
>  	u16 *wp = (u16 *) p;
>  	while (l-- > 0)
>  		*wp++ = readw(a);
>  }
>  
> -static inline void mcf_outsw(void *a, unsigned char *p, int l)
> +static inline void mcf_outsw(void __iomem *a, unsigned char *p, int l)
>  {
>  	u16 *wp = (u16 *) p;
>  	while (l-- > 0)
> @@ -1026,15 +1026,15 @@ static const char * chip_ids[ 16 ] =  {
>  		}							\
>  	} while (0)
>  
> -#define SMC_PUSH_DATA(lp, p, l)					\
> +#define SMC_PUSH_DATA(lp, p, l)						\
>  	do {								\
> -		if (SMC_32BIT(lp)) {				\
> +		void __iomem *__ioaddr = ioaddr;			\
> +		if (SMC_32BIT(lp)) {					\
>  			void *__ptr = (p);				\
>  			int __len = (l);				\
> -			void __iomem *__ioaddr = ioaddr;		\
>  			if (__len >= 2 && (unsigned long)__ptr & 2) {	\
>  				__len -= 2;				\
> -				SMC_outsw(ioaddr, DATA_REG(lp), __ptr, 1); \
> +				SMC_outsw(__ioaddr, DATA_REG(lp), __ptr, 1); \
>  				__ptr += 2;				\
>  			}						\
>  			if (SMC_CAN_USE_DATACS && lp->datacs)		\
> @@ -1042,20 +1042,20 @@ static const char * chip_ids[ 16 ] =  {
>  			SMC_outsl(__ioaddr, DATA_REG(lp), __ptr, __len>>2); \
>  			if (__len & 2) {				\
>  				__ptr += (__len & ~3);			\
> -				SMC_outsw(ioaddr, DATA_REG(lp), __ptr, 1); \
> +				SMC_outsw(__ioaddr, DATA_REG(lp), __ptr, 1); \
>  			}						\
>  		} else if (SMC_16BIT(lp))				\
> -			SMC_outsw(ioaddr, DATA_REG(lp), p, (l) >> 1);	\
> -		else if (SMC_8BIT(lp))				\
> -			SMC_outsb(ioaddr, DATA_REG(lp), p, l);	\
> +			SMC_outsw(__ioaddr, DATA_REG(lp), p, (l) >> 1);	\
> +		else if (SMC_8BIT(lp))					\
> +			SMC_outsb(__ioaddr, DATA_REG(lp), p, l);	\
>  	} while (0)
>  
> -#define SMC_PULL_DATA(lp, p, l)					\
> +#define SMC_PULL_DATA(lp, p, l)						\
>  	do {								\
> -		if (SMC_32BIT(lp)) {				\
> +		void __iomem *__ioaddr = ioaddr;			\
> +		if (SMC_32BIT(lp)) {					\
>  			void *__ptr = (p);				\
>  			int __len = (l);				\
> -			void __iomem *__ioaddr = ioaddr;		\
>  			if ((unsigned long)__ptr & 2) {			\
>  				/*					\
>  				 * We want 32bit alignment here.	\
> @@ -1072,7 +1072,7 @@ static const char * chip_ids[ 16 ] =  {
>  				 */					\
>  				__ptr -= 2;				\
>  				__len += 2;				\
> -				SMC_SET_PTR(lp,			\
> +				SMC_SET_PTR(lp,				\
>  					2|PTR_READ|PTR_RCV|PTR_AUTOINC); \
>  			}						\
>  			if (SMC_CAN_USE_DATACS && lp->datacs)		\
> @@ -1080,9 +1080,9 @@ static const char * chip_ids[ 16 ] =  {
>  			__len += 2;					\
>  			SMC_insl(__ioaddr, DATA_REG(lp), __ptr, __len>>2); \
>  		} else if (SMC_16BIT(lp))				\
> -			SMC_insw(ioaddr, DATA_REG(lp), p, (l) >> 1);	\
> -		else if (SMC_8BIT(lp))				\
> -			SMC_insb(ioaddr, DATA_REG(lp), p, l);		\
> +			SMC_insw(__ioaddr, DATA_REG(lp), p, (l) >> 1);	\
> +		else if (SMC_8BIT(lp))					\
> +			SMC_insb(__ioaddr, DATA_REG(lp), p, l);		\
>  	} while (0)
>  
>  #endif  /* _SMC91X_H_ */
> -- 
> 2.45.0
> 
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h
index 45ef5ac0788a..204fbb5c975c 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -142,14 +142,14 @@  static inline void _SMC_outw_align4(u16 val, void __iomem *ioaddr, int reg,
 #define SMC_CAN_USE_32BIT	0
 #define SMC_NOWAIT		1
 
-static inline void mcf_insw(void *a, unsigned char *p, int l)
+static inline void mcf_insw(void __iomem *a, unsigned char *p, int l)
 {
 	u16 *wp = (u16 *) p;
 	while (l-- > 0)
 		*wp++ = readw(a);
 }
 
-static inline void mcf_outsw(void *a, unsigned char *p, int l)
+static inline void mcf_outsw(void __iomem *a, unsigned char *p, int l)
 {
 	u16 *wp = (u16 *) p;
 	while (l-- > 0)
@@ -1026,15 +1026,15 @@  static const char * chip_ids[ 16 ] =  {
 		}							\
 	} while (0)
 
-#define SMC_PUSH_DATA(lp, p, l)					\
+#define SMC_PUSH_DATA(lp, p, l)						\
 	do {								\
-		if (SMC_32BIT(lp)) {				\
+		void __iomem *__ioaddr = ioaddr;			\
+		if (SMC_32BIT(lp)) {					\
 			void *__ptr = (p);				\
 			int __len = (l);				\
-			void __iomem *__ioaddr = ioaddr;		\
 			if (__len >= 2 && (unsigned long)__ptr & 2) {	\
 				__len -= 2;				\
-				SMC_outsw(ioaddr, DATA_REG(lp), __ptr, 1); \
+				SMC_outsw(__ioaddr, DATA_REG(lp), __ptr, 1); \
 				__ptr += 2;				\
 			}						\
 			if (SMC_CAN_USE_DATACS && lp->datacs)		\
@@ -1042,20 +1042,20 @@  static const char * chip_ids[ 16 ] =  {
 			SMC_outsl(__ioaddr, DATA_REG(lp), __ptr, __len>>2); \
 			if (__len & 2) {				\
 				__ptr += (__len & ~3);			\
-				SMC_outsw(ioaddr, DATA_REG(lp), __ptr, 1); \
+				SMC_outsw(__ioaddr, DATA_REG(lp), __ptr, 1); \
 			}						\
 		} else if (SMC_16BIT(lp))				\
-			SMC_outsw(ioaddr, DATA_REG(lp), p, (l) >> 1);	\
-		else if (SMC_8BIT(lp))				\
-			SMC_outsb(ioaddr, DATA_REG(lp), p, l);	\
+			SMC_outsw(__ioaddr, DATA_REG(lp), p, (l) >> 1);	\
+		else if (SMC_8BIT(lp))					\
+			SMC_outsb(__ioaddr, DATA_REG(lp), p, l);	\
 	} while (0)
 
-#define SMC_PULL_DATA(lp, p, l)					\
+#define SMC_PULL_DATA(lp, p, l)						\
 	do {								\
-		if (SMC_32BIT(lp)) {				\
+		void __iomem *__ioaddr = ioaddr;			\
+		if (SMC_32BIT(lp)) {					\
 			void *__ptr = (p);				\
 			int __len = (l);				\
-			void __iomem *__ioaddr = ioaddr;		\
 			if ((unsigned long)__ptr & 2) {			\
 				/*					\
 				 * We want 32bit alignment here.	\
@@ -1072,7 +1072,7 @@  static const char * chip_ids[ 16 ] =  {
 				 */					\
 				__ptr -= 2;				\
 				__len += 2;				\
-				SMC_SET_PTR(lp,			\
+				SMC_SET_PTR(lp,				\
 					2|PTR_READ|PTR_RCV|PTR_AUTOINC); \
 			}						\
 			if (SMC_CAN_USE_DATACS && lp->datacs)		\
@@ -1080,9 +1080,9 @@  static const char * chip_ids[ 16 ] =  {
 			__len += 2;					\
 			SMC_insl(__ioaddr, DATA_REG(lp), __ptr, __len>>2); \
 		} else if (SMC_16BIT(lp))				\
-			SMC_insw(ioaddr, DATA_REG(lp), p, (l) >> 1);	\
-		else if (SMC_8BIT(lp))				\
-			SMC_insb(ioaddr, DATA_REG(lp), p, l);		\
+			SMC_insw(__ioaddr, DATA_REG(lp), p, (l) >> 1);	\
+		else if (SMC_8BIT(lp))					\
+			SMC_insb(__ioaddr, DATA_REG(lp), p, l);		\
 	} while (0)
 
 #endif  /* _SMC91X_H_ */