Re: [PATCH] net: smc91x: Fix pointer types

From: Thorsten Blum
Date: Thu May 16 2024 - 11:13:25 EST


On 16. May 2024, at 16:13, Andrew Lunn <andrew@xxxxxxx> 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