[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VePmhLstCraz_+7Cqc_bLQ49+1rV4oH59a1oo2xHp0R+Q@mail.gmail.com>
Date: Tue, 5 Aug 2025 14:47:32 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Akshay Jindal <akshayaj.lkd@...il.com>
Cc: anshulusr@...il.com, jic23@...nel.org, dlechner@...libre.com,
nuno.sa@...log.com, andy@...nel.org, shuah@...nel.org,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: light: ltr390: Add remove callback with needed
support in device registration
On Tue, Aug 5, 2025 at 6:05 AM Akshay Jindal <akshayaj.lkd@...il.com> wrote:
>
> On Tue, Aug 5, 2025 at 2:36 AM Andy Shevchenko
> <andy.shevchenko@...il.com> wrote:
> >
> > Doesn't sound right to me. HAve you investigated PM runtime paths?
> Yes I did investigate and found that PM runtime->suspend() callback
> co-exists with remove callback.
>
> > Looking at what the code you added there it sounds to me like a part
> > of PM runtime ->suspend() callback.
> Yes, part of functionality will always be common, because both the
> callback implementations put
> the device into powered down or low power state which is what has been done here
> Both _suspend() and remove are called at different times in the lifecycle of the
> driver, but with respect to register setting, they put the device into
> power down state.
Are you sure about the remove stage and how it interacts with runtime
PM? Please, check how the device driver core manages PM on the remove
stage.
> Additionally .remove() can have code for:
> 1. disable runtime power management (if enabled while device registration).
If the device core enables it for you, it will disable it
symmetrically. I don't see the issue here, it should be done
automatically. If you do that explicitly, use the respective
devm_pm_runtime_*() call.
> 2. device cleanup (disabling interrupt and cleaning up other configs done).
Wrap them into devm if required.
> 2. unregister the device.
Already done in the original code which your patch reverts, why?
> For eg: another light sensor bh1750
> static void bh1750_remove(struct i2c_client *client)
> {
> iio_device_unregister(indio_dev);
> mutex_lock(&data->lock);
> i2c_smbus_write_byte(client, BH1750_POWER_DOWN);
> mutex_unlock(&data->lock);
> }
>
> static int bh1750_suspend(struct device *dev)
> {
> mutex_lock(&data->lock);
> ret = i2c_smbus_write_byte(data->client, BH1750_POWER_DOWN);
> mutex_unlock(&data->lock);
> return ret;
> }
Correct and where do you see the problem here? Perhaps the problem is
in the cleanup aordering and some other bugs vs. devm calls?
> In drivers/iio/light, you can find similar examples in pa12203001,
> rpr0521, apds9960,
> vcnl4000, isl29028, vcnl4035. You can find many more examples in
> sensors other than light sensors.
Good, should all they need to be fixed?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists