Re: [PATCH 1/4] iio: pressure: mpl3115: convert probe to fully devm managed
Andy Shevchenko <[email protected]>
| Newsgroups | dev.linux.lists.linux-kernel-mentees,org.kernel.vger.linux-iio |
|---|---|
| Message-ID | <CAHp75Vfd_eRRgnCpXsa0CVQ56f85YwQQRTj70MfmB4prVygYGg@mail.gmail.com> |
On Sat, May 30, 2026 at 1:40 PM SeungJu Cheon <[email protected]> wrote: > > Convert probe to use devm-managed resource allocation, > removing the need for an explicit remove callback. > > Replace iio_triggered_buffer_setup() and > iio_device_register() with their devm equivalents. > Register a devm action to return the device to standby, > replacing the cleanup previously performed in > mpl3115_remove(). > > Move mpl3115_standby() and suspend/resume helpers above > probe to satisfy declaration ordering requirements. > > No functional change. ... > +static int mpl3115_suspend(struct device *dev) > +{ > + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); What's wrong with dev_get_drvdata() ? > + return mpl3115_standby(iio_priv(indio_dev)); > +} > + > +static int mpl3115_resume(struct device *dev) > +{ > + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); Ditto. > + struct mpl3115_data *data = iio_priv(indio_dev); > + > + return i2c_smbus_write_byte_data(data->client, MPL3115_CTRL_REG1, > + data->ctrl_reg1); > +} ... You forgot about mutex_init(). > - ret = mpl3115_trigger_probe(data, indio_dev); > + ret = devm_add_action_or_reset(&client->dev, mpl3115_standby_action, > + data); Add struct device *dev = &client->dev; to the top of the function to make this shorter and easier to read. > if (ret) > return ret; ... > -static int mpl3115_standby(struct mpl3115_data *data) > -{ > - return i2c_smbus_write_byte_data(data->client, MPL3115_CTRL_REG1, > - data->ctrl_reg1 & ~MPL3115_CTRL1_ACTIVE); > -} Split moving of this function to a separate prerequisite patch. ... > -static int mpl3115_suspend(struct device *dev) > -static int mpl3115_resume(struct device *dev) Why did you touch these two? -- With Best Regards, Andy Shevchenko