Re: [PATCH 1/5] iio: inkern: introduce devm_iio_map_array_register() short-hand function

From: Alexandru Ardelean
Date: Fri Sep 03 2021 - 09:56:58 EST


On Fri, 3 Sept 2021 at 16:40, Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Fri, Sep 03, 2021 at 10:29:13AM +0300, Alexandru Ardelean wrote:
> > This change introduces a device-managed variant to the
> > iio_map_array_register() function. It's a simple implementation of calling
> > iio_map_array_register() and registering a callback to
> > iio_map_array_unregister() with the devm_add_action_or_reset().
> >
> > The function uses an explicit 'dev' parameter to bind the unwinding to. It
> > could have been implemented to implicitly use the parent of the IIO device,
> > however it shouldn't be too expensive to callers to just specify to which
> > device object to bind this unwind call.
> > It would make the API a bit more flexible.
>
> AFAIU this dev pointer is kinda discussable thing. What scenario do you expect
> (have in mind) when it shouldn't use parent?

So, this brings me back to an older discussion about devm_ when I
thought about making some devm_ function that implicitly takes uses
the parent of the IIO device.

Jonathan mentioned that if we go that route, maybe we should prefix it
with iiom_ .
But we weren't sure at the time if that makes sense.
The idea was to bind the management of the unwinding to either the
parent of the IIO device, or the IIO device itself (indio_dev->dev).

We kind of concluded that it may probably not be a good to hide
anything and make standard a devm_ function with an explicit 'dev'
object parameter.

I found a recent mention here (while searching for iiom_ on linux-iio):
https://lore.kernel.org/linux-iio/20210313192150.74c0a91b@archlinux/


>
> --
> With Best Regards,
> Andy Shevchenko
>
>