Re: [PATCH 07/11] iio: adc: Add support for QCOM PMIC5 Gen3 ADC

From: Jonathan Cameron
Date: Fri Oct 27 2023 - 09:26:39 EST


> > +
> >> +static const struct iio_info adc5_gen3_info = {
> >> + .read_raw = adc5_gen3_read_raw,
> >> + .fwnode_xlate = adc5_gen3_fwnode_xlate,
> >> +};
> > ...
>
>
> Did you mean to leave any comment here...?

Nope ... is a cut mark to indicate I dropped a load of quoted text.

On that note, don't bother replying to say you'll do things suggested
by reviewers - we assume you will unless you say otherwise :)

If you want to add a boilerplate message alongside comments on the
bits that need further discussion, along the lines of
"All other comments accepted." That's fine but it's not really necessary.

...

> >> +
> >> +static int adc5_gen3_exit(struct platform_device *pdev)
> >> +{
> > As you are mixing devm manged cleanup and the explicit sort the
> > result is that you remove the userspace interfaces 'after' you run
> > everything in here. I'm thinking disabling the channels at least
> > isn't a good idea in that case.
> >
> > If you want to use devm (which is good) then you need to work out how
> > to register additional callbacks during probe to tear down everything in
> > the right order (typically the reverse of what happens in probe)
> > devm_add_action_or_reset() is the way to add those extra callbacks.
> >
> > If not, just don't use devm for at least those bits that will end up
> > running out of order (such as iio_device_register()) and manually call their
> > cleanup routines instead.
>
>
> I checked some other examples in the iio/adc/ folder, I think I see what
> you mean here. It looks like drivers with a remove callback always use
> iio_device_register and iio_device_unregister instead of the devm_*
> variant, due to the issue with sysfs removal as you said.
>
> I'll update the probe and remove functions similarly, to do explicit
> cleanups as required, avoiding devm_ usage for places where it should be
> avoided.

Better to go the other way as Dmitry suggested. Make everything you can
devm managed.