Re: [PATCH v9 6/7] iio: adc: ad9467: convert to backend framework

Nuno Sá
2024-02-06T16:51:32Z

On Tue, 2024-02-06 at 16:20 +0200, Andy Shevchenko wrote:
> On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay
> <devnull+nuno.sa.analog.com@kernel.org> wrote:
> >
> > From: Nuno Sa <nuno.sa@analog.com>
> >
> > Convert the driver to use the new IIO backend framework. The device
> > functionality is expected to be the same (meaning no added or removed
> > features).
> >
> > Also note this patch effectively breaks ABI and that's needed so we can
> > properly support this device and add needed features making use of the
> > new IIO framework.
> >
> > Giving the lack of features (and devices supported) in the ad9467 driver
>
> Given
>
> > compared with the ADI out of tree version, we don't expect any user of
> > the upstream driver so no one should notice the ABI breakage. However,
> > if someone is affected by this, ADI will happily support in transitioning
>
> support transitioning
>
> > to the backend framework.
>
> ...
>
> > -               .max_rate = 250000000UL,
>
> > -               .max_rate = 500000000UL,
>
> > -               .max_rate = 125000000UL,
>
> ...
>
> > +static int ad9467_update_scan_mode(struct iio_dev *indio_dev,
> > +                                  const unsigned long *scan_mask)
> > +{
> > +       struct ad9467_state *st = iio_priv(indio_dev);
> > +       unsigned int c;
> > +       int ret;
> > +
> > +       for (c = 0; c < st->info->num_channels; c++) {
> > +               if (test_bit(c, scan_mask))
> > +                       ret = iio_backend_chan_enable(st->back, c);
> > +               else
> > +                       ret = iio_backend_chan_disable(st->back, c);
>
> > +
>
> Unneeded blank line.
>
> > +               if (ret)
> > +                       return ret;
> > +       }
> > +
> > +       return 0;
> > +}
>
> ....
>
> > +       st->back = devm_iio_backend_get(&st->spi->dev, NULL);
> > +       /* If not found, don't error out as we might have legacy DT property */
> > +       if (!IS_ERR(st->back))
> > +               return 0;
> > +       if (PTR_ERR(st->back) != -ENOENT)
> > +               return PTR_ERR(st->back);
>
> This looks hackish...
>

This was suggested by Jonathan so I'm keen in leaving it as-is

- Nuno Sá