Subject: Re: [PATCH net-next v2 06/13] net: dsa: realtek: use phy_read in ds->ops

From: Andrew Lunn <[email-masked]>
Date: Thu, 30 Dec 2021 21:00:43 +0100

On Thu, Dec 30, 2021 at 04:44:26PM -0300, Luiz Angelo Daros de Luca wrote:
> > >   static int realtek_smi_mdio_read(struct mii_bus *bus, int addr, int regnum)
> > >   {
> > > -     struct realtek_priv *priv = bus->priv;
> > > +     struct dsa_switch *ds = ((struct realtek_priv *)bus->priv)->ds;
> >
> > No need to cast a void pointer, this applies throughout the entire patch
> > series.
> > --
> Hi Florian,
> 
> Apologize for my poor C experience but I didn't understand your
> suggestion. Simply removing the cast will not work because bus->priv
> is void*

You can do 

     struct realtek_priv *priv = bus->priv;
     struct dsa_switch *ds = priv->ds;

This is more readable than what you suggested, and avoids the cast.

     Andrew