Subject: Re: [PATCH 09/14] net: ks8851: Split out SPI specific entries in struct ks8851_net

From: Andrew Lunn <[email-masked]>
Date: Tue, 24 Mar 2020 13:27:43 +0100

On Tue, Mar 24, 2020 at 11:49:19AM +0100, Lukas Wunner wrote:
> On Tue, Mar 24, 2020 at 12:42:58AM +0100, Marek Vasut wrote:
> > +/**
> > + * struct ks8851_net_spi - KS8851 SPI driver private data
> > + * @ks8851: KS8851 driver common private data
> > + * @spidev: The spi device we're bound to.
> > + * @spi_msg1: pre-setup SPI transfer with one message, @spi_xfer1.
> > + * @spi_msg2: pre-setup SPI transfer with two messages, @spi_xfer2.
> 
> You need to remove these kerneldoc entries further up from struct ks8851_net.
> 
> 
> > +struct ks8851_net_spi {
> > +	struct ks8851_net	ks8851;	/* Must be first */
> > +	struct spi_device	*spidev;
> > +	struct spi_message	spi_msg1;
> > +	struct spi_message	spi_msg2;
> > +	struct spi_transfer	spi_xfer1;
> > +	struct spi_transfer	spi_xfer2[2];
> > +};
> > +
> > +#define to_ks8851_spi(ks) container_of((ks), struct ks8851_net_spi, ks8851)
> 
> Since it's always the first entry in the struct, a cast instead of
> container_of() would seem to be sufficient.

Hi Lukus

That is bad practice. container_of() will always get it correct,
making it safer.

       Andrew