Re: [PATCH v3 5/7] iio: accel: kionix-kx022a: Refactor driver and add chip_info structure

Andy Shevchenko
2023-05-02T19:41:40Z

On Sun, Apr 30, 2023 at 06:49:10PM +0100, Jonathan Cameron wrote:
> On Sat, 29 Apr 2023 15:07:46 +0200
> Mehdi Djait <mehdi.djait.k@gmail.com> wrote:
> > On Tue, Apr 25, 2023 at 05:57:34PM +0200, Andi Shyti wrote:
> > > On Tue, Apr 25, 2023 at 12:22:25AM +0200, Mehdi Djait wrote:

...

> > > > + chip_info = device_get_match_data(&spi->dev);
> > > > + if (!chip_info) {
> > > > + const struct spi_device_id *id = spi_get_device_id(spi);
> > > > + chip_info = (const struct kx022a_chip_info *)id->driver_data;
> > >
> > > you don't need the cast here... if you don't find it messy, I
> > > wouldn't mind this form... some hate it, I find it easier to
> > > read:
> > >
> > > chip_info = spi_get_device_id(spi)->driver_data;
> > >
> > > your choice.
> >
> > I don't really have any strong opinion about this other than keeping the
> > same style used in iio drivers
> >
> > Again thank you for the review
>
> I'm fairly sure the cast is needed because driver_data is (via defines)
> an unsigned long, which you cannot implicitly cast to a pointer without
> various warnings being generated.

Instead we have a specific SPI provided helper for the above, please use it
instead of open coded stuff.

--
With Best Regards,
Andy Shevchenko