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

Andy Shevchenko
2024-02-06T14:20:45Z

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...

Perhaps

ret = PTR_ERR_OR_ZERO(st->back);
if (ret && ret == -ENOENT)
return _a_new_helper_with_below_code_you_have();

return ret;

--
With Best Regards,
Andy Shevchenko