Re: [PATCH v6 6/9] iio: accel: mma8452: Reuse existing dev pointer in mma8452_probe()

From: Andy Shevchenko

Date: Wed Aug 26 2026 - 03:28:02 EST


On Tue, Aug 25, 2026 at 10:27:44AM +0200, Esben Haabendal wrote:
> In commit 32a5c04d4575 ("iio: accel: mma8452: Use dev_err_probe()") the
> struct device * pointer was assigned to local variable dev, so we can just
> as well reuse that throughout the function for sligthly more readable code.

...

> static int mma8452_runtime_suspend(struct device *dev)
> {
> - struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> + struct i2c_client *client = to_i2c_client(dev);
> + struct iio_dev *indio_dev = i2c_get_clientdata(client);

This change is unrelated and should be as simple as

struct iio_dev *indio_dev = dev_get_drvdata(dev);

OTOH, this might require the full device.h to be included...
Either way, it's not for this patch.

> struct mma8452_data *data = iio_priv(indio_dev);
> int ret;

> ret = mma8452_standby(data);
> mutex_unlock(&data->lock);
> if (ret < 0) {
> - dev_err(&data->client->dev, "powering off device failed\n");
> + dev_err(&client->dev, "powering off device failed\n");
> return -EAGAIN;
> }

Why? Just use given 'dev' as is.

--
With Best Regards,
Andy Shevchenko