Skip to contentSkip to conversation

net: smc91x: Fix pointer types

PATCH Superseded Thorsten Blum 3 participants 11 messages May 16, 2024 – May 17, 2024

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: smc91x: Fix pointer types

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 *

---
 drivers/net/ethernet/smsc/smc91x.h | 34 +++++++++++++++---------------
 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/ethernet/smsc/smc91x.h +17 -17
index 45ef5ac0788a..204fbb5c975c 100644
@@ -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_ */
Signature · 1 line
2.45.0
#1 lore raw

drivers/net/ethernet/smsc/smc91x.h static const char * chip_ids[ 16 ] = { · line 1031

Quoted 5 lines
drivers/net/ethernet/smsc/smc91x.h +2 -2
-#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.

drivers/net/ethernet/smsc/smc91x.h static const char * chip_ids[ 16 ] = { · line 1037

Quoted 8 lines
drivers/net/ethernet/smsc/smc91x.h +2 -2
+		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.

drivers/net/ethernet/smsc/smc91x.h static const char * chip_ids[ 16 ] = { · line 1078

Quoted 9 lines
drivers/net/ethernet/smsc/smc91x.h +1 -1
@@ -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

#2 lore raw
Quoted 7 lines · Andrew Lunn

-#define SMC_PUSH_DATA(lp, p, l) \

Quoted 4 lines

+#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.

Quoted 11 lines

+ if (SMC_32BIT(lp)) { \

Quoted 7 lines

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.

Quoted 10 lines
(quoted diff) +0 -0
@@ -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); \
 > } \
Quoted 1 line

if (SMC_CAN_USE_DATACS && lp->datacs) \

Quoted 2 lines

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

Ok, I'll change this in v2.

Thanks,
Thorsten

#3 lore raw

PATCH v2 1/1 net: smc91x: Fix pointer types

Use void __iomem pointers as parameters for mcf_insw() and mcf_outsw() to align with the parameter types of readw() and writew().

Use lp->base instead of ioaddr when calling SMC_outsw(), SMC_outsb(), SMC_insw(), and SMC_insb() to retain its type across macro boundaries and to fix 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 *

---
Changes in v2:
- Use lp->base instead of __ioaddr as suggested by Andrew Lunn. They are essentially the same, but using lp->base results in a smaller diff
- Remove whitespace only changes as suggested by Andrew Lunn
- Preserve Acked-by: Nicolas Pitre tag (please let me know if you somehow disagree with the changes in v2)

---
 drivers/net/ethernet/smsc/smc91x.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/smsc/smc91x.h +8 -8
index 45ef5ac0788a..a1523fb503a3 100644
@@ -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)
@@ -1034,7 +1034,7 @@ static const char * chip_ids[ 16 ] =  {
 			void __iomem *__ioaddr = ioaddr;		\
 			if (__len >= 2 && (unsigned long)__ptr & 2) {	\
 				__len -= 2;				\
-				SMC_outsw(ioaddr, DATA_REG(lp), __ptr, 1); \
+				SMC_outsw(lp->base, DATA_REG(lp), __ptr, 1); \
 				__ptr += 2;				\
 			}						\
 			if (SMC_CAN_USE_DATACS && lp->datacs)		\
@@ -1042,12 +1042,12 @@ 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(lp->base, DATA_REG(lp), __ptr, 1); \
 			}						\
 		} else if (SMC_16BIT(lp))				\
-			SMC_outsw(ioaddr, DATA_REG(lp), p, (l) >> 1);	\
+			SMC_outsw(lp->base, DATA_REG(lp), p, (l) >> 1);	\
 		else if (SMC_8BIT(lp))				\
-			SMC_outsb(ioaddr, DATA_REG(lp), p, l);	\
+			SMC_outsb(lp->base, DATA_REG(lp), p, l);	\
 	} while (0)
 
 #define SMC_PULL_DATA(lp, p, l)					\
@@ -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);	\
+			SMC_insw(lp->base, DATA_REG(lp), p, (l) >> 1);	\
 		else if (SMC_8BIT(lp))				\
-			SMC_insb(ioaddr, DATA_REG(lp), p, l);		\
+			SMC_insb(lp->base, DATA_REG(lp), p, l);		\
 	} while (0)
 
 #endif  /* _SMC91X_H_ */
Signature · 1 line
2.45.0
Reviewed-by on v2 1/1
#4 lore raw
Quoted 20 lines · Thorsten Blum

Use void __iomem pointers as parameters for mcf_insw() and mcf_outsw() to align with the parameter types of readw() and writew().

Use lp->base instead of ioaddr when calling SMC_outsw(), SMC_outsb(), SMC_insw(), and SMC_insb() to retain its type across macro boundaries and to fix 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 *

Quoted 4 lines

You could add a follow up patch which removes the void __iomem *__ioaddr = ioaddr; lines and uses lp->base. The code will then be more uniform.

Andrew

maintainer
#5 lore raw
Quoted 3 lines · Andrew Lunn

You could add a follow up patch which removes the void __iomem *__ioaddr = ioaddr; lines and uses lp->base. The code will then be more uniform.

Beware, It is sometimes overridden with __ioaddr = lp->datacs.

Nicolas

#6 lore raw

PATCH v3 1/1 net: smc91x: Fix pointer types

In reply to Andrew Lunn

Use void __iomem pointers as parameters for mcf_insw() and mcf_outsw() to align with the parameter types of readw() and writew() to fix 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 *

---
Changes in v2:
- Use lp->base instead of __ioaddr as suggested by Andrew Lunn. They are essentially the same, but using lp->base results in a smaller diff
- Remove whitespace only changes as suggested by Andrew Lunn
- Preserve Acked-by: Nicolas Pitre tag (please let me know if you somehow disagree with the changes in v2 or v3)

Changes in v3:
- Revert changing the macros as this is unnecessary. Neither the types nor the __iomem attributes get lost across macro boundaries
- Preserve Reviewed-by: Andrew Lunn tag (please let me know if you somehow disagree with the changes in v3)

---
 drivers/net/ethernet/smsc/smc91x.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/smsc/smc91x.h +2 -2
index 45ef5ac0788a..38aa4374e813 100644
@@ -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)
Signature · 1 line
2.45.0
#7 lore raw
Quoted 30 lines · Thorsten Blum

Use void __iomem pointers as parameters for mcf_insw() and mcf_outsw() to align with the parameter types of readw() and writew() to fix 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 *

---
Changes in v2:
- Use lp->base instead of __ioaddr as suggested by Andrew Lunn. They are essentially the same, but using lp->base results in a smaller diff
- Remove whitespace only changes as suggested by Andrew Lunn
- Preserve Acked-by: Nicolas Pitre tag (please let me know if you somehow disagree with the changes in v2 or v3)

Quoted 5 lines

Changes in v3:
- Revert changing the macros as this is unnecessary. Neither the types nor the __iomem attributes get lost across macro boundaries
- Preserve Reviewed-by: Andrew Lunn tag (please let me know if you somehow disagree with the changes in v3)

This fixes the warning, but we still have the macro accessing things not passed to them. If you are going to brother to fix the warnings, it would also be good to fix the bad practice. Please make a patchset to do this.

It would also be good if you read:

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

Andrew

#8 lore raw
Quoted 37 lines · Andrew Lunn
Quoted 30 lines · Thorsten Blum

Use void __iomem pointers as parameters for mcf_insw() and mcf_outsw() to align with the parameter types of readw() and writew() to fix 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 *

---
Changes in v2:
- Use lp->base instead of __ioaddr as suggested by Andrew Lunn. They are essentially the same, but using lp->base results in a smaller diff
- Remove whitespace only changes as suggested by Andrew Lunn
- Preserve Acked-by: Nicolas Pitre tag (please let me know if you somehow disagree with the changes in v2 or v3)

Quoted 5 lines

Changes in v3:
- Revert changing the macros as this is unnecessary. Neither the types nor the __iomem attributes get lost across macro boundaries
- Preserve Reviewed-by: Andrew Lunn tag (please let me know if you somehow disagree with the changes in v3)

Quoted 4 lines

This fixes the warning, but we still have the macro accessing things not passed to them. If you are going to brother to fix the warnings, it would also be good to fix the bad practice. Please make a patchset to do this.

I would prefer to submit another patch to fix the macros. I submitted v3 because the patch description for v2 was wrong (type information or attributes don't get lost across macro boundaries) and the macro changes are unnecessary to fix the warnings.

I should never have changed the macros, but after first adding __iomem to mcf_insw() and mcf_outsw(), I kept getting the same errors and looked for the problem in the SMC_* macros. I probably didn't do a clean build or forgot to save my changes and just refactored the macros as a side effect.

Quoted 3 lines

It would also be good if you read:

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

Will do.

Thanks,
Thorsten

#9 lore raw
Quoted 6 lines · Thorsten Blum
Quoted 3 lines · Andrew Lunn

It would also be good if you read:

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

Will do.

Reading this was helpful and I learned that:
- net-next is closed during a merge window
- patches should be prefixed with the tree name

I'll submit the patch that cleans up ioaddr from all SMC_* macros when net-next is open again.

Thanks,
Thorsten

maintainer Acked-by on v1 1/1
#10 lore raw
In reply to Thorsten Blum
Quoted 20 lines · Thorsten Blum

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 *

Quoted 3 lines
Quoted 99 lines
---
 drivers/net/ethernet/smsc/smc91x.h | 34 +++++++++++++++---------------
 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/ethernet/smsc/smc91x.h +17 -17
index 45ef5ac0788a..204fbb5c975c 100644
@@ -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_ */
Signature · 1 line
2.45.0