Re: [PATCH] net: mdio-octeon: Fix pointer/integer casts

From: Andrew Lunn
Date: Sun Nov 10 2019 - 21:33:03 EST


On Sun, Nov 10, 2019 at 04:42:11PM -0800, Olof Johansson wrote:
> Fixes a bunch of these warnings on arm allmodconfig:
>
> In file included from /build/drivers/net/phy/mdio-cavium.c:11:
> /build/drivers/net/phy/mdio-cavium.c: In function 'cavium_mdiobus_set_mode':
> /build/drivers/net/phy/mdio-cavium.h:114:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> 114 | #define oct_mdio_readq(addr) readq((void *)addr)
> | ^
> /build/drivers/net/phy/mdio-cavium.c:21:16: note: in expansion of macro 'oct_mdio_readq'
> 21 | smi_clk.u64 = oct_mdio_readq(p->register_base + SMI_CLK);
> | ^~~~~~~~~~~~~~
>
> Fixes: 171a9bae68c7 ("staging/octeon: Allow test build on !MIPS")
> Signed-off-by: Olof Johansson <olof@xxxxxxxxx>
> ---
> drivers/net/phy/mdio-cavium.h | 14 +++++++-------
> drivers/net/phy/mdio-octeon.c | 5 ++---
> drivers/net/phy/mdio-thunder.c | 2 +-
> 3 files changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/phy/mdio-cavium.h b/drivers/net/phy/mdio-cavium.h
> index b7f89ad27465f..1cf81f0bc585f 100644
> --- a/drivers/net/phy/mdio-cavium.h
> +++ b/drivers/net/phy/mdio-cavium.h
> @@ -90,7 +90,7 @@ union cvmx_smix_wr_dat {
>
> struct cavium_mdiobus {
> struct mii_bus *mii_bus;
> - u64 register_base;
> + void __iomem *register_base;
> enum cavium_mdiobus_mode mode;
> };
>
> @@ -98,20 +98,20 @@ struct cavium_mdiobus {
>
> #include <asm/octeon/octeon.h>
>
> -static inline void oct_mdio_writeq(u64 val, u64 addr)
> +static inline void oct_mdio_writeq(u64 val, void __iomem *addr)
> {
> - cvmx_write_csr(addr, val);
> + cvmx_write_csr((u64)addr, val);
> }

Hi Olof

Humm. The warning goes away, but is it really any better?

Did you try also changing the stub function in
drivers/staging/octeon/octeon-stubs.h so it takes void __iomem? Or
did that cause a lot more warnings from other places?

Thanks
Andrew