lkml.org 
[lkml]   [2022]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 2/2] iio: light: Add support for ltrf216a sensor


>
> > + /* reset sensor, chip fails to respond to this, so ignore any errors */
> > + ltrf216a_reset(indio_dev);
> > +
> > + ret = pm_runtime_set_active(&client->dev);
> > + if (ret)
> > + goto error_power_down;
>
> Why do you need to power down here?
>
> > + pm_runtime_enable(&client->dev);

We now have devm_pm_runtime_enable() which will also deal
with disabling use_autosuspend for you and should help you
sort out some of the ordering.


> > + pm_runtime_set_autosuspend_delay(&client->dev, 5000);
> > + pm_runtime_use_autosuspend(&client->dev);
> > +
> > + ltrf216a_set_power_state(data, true);
>
> The below code suggests that you are mixing badly devm_ with non-devm_
> APIs, don't do this. You have to group devm_ first followed by
> non-devm_ calls.
>
> ...
>
> > +static int ltrf216a_remove(struct i2c_client *client)
> > +{
> > + struct iio_dev *indio_dev = i2c_get_clientdata(client);
> > +
> > + iio_device_unregister(indio_dev);
> > + pm_runtime_disable(&client->dev);
> > + pm_runtime_set_suspended(&client->dev);
> > + ltrf216a_disable(indio_dev);
> > +
> > + return 0;
>
> I believe the ordering of freeing resources and reverting state is not
> in reverse. See above why.

In particular you are calling disable there which is already handled
by devm_ unwinding.
>
> > +}
>


\
 
 \ /
  Last update: 2022-06-19 14:36    [W:0.099 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site