Message ID | 2bb4c61122eca2f3a35f6087e7d9815675013f66.1740993491.git.mazziesaccount@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | Support ROHM BD79124 ADC | expand |
On Mon, 3 Mar 2025 13:33:21 +0200 Matti Vaittinen <mazziesaccount@gmail.com> wrote: > Device pointer is the only variable which is used by the > ads7924_get_channels_config() and which is declared outside this > function. Still, the function gets the iio_device and i2c_client as > parameters. The sole caller of this function (probe) already has the > device pointer which it can directly pass to the function. > > Simplify code by passing the device pointer directly as a parameter > instead of digging it from the iio_device's private data. > > Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Now an unrelated change, so I'll pick this up to avoid confusion in any future versions. Applied to the togreg branch of iio.git Thanks, Jonathan > > --- > Revision history: > v4 => No changes > > This commit is compile-tested only! All further testing is appreciated. > --- > drivers/iio/adc/ti-ads7924.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/iio/adc/ti-ads7924.c b/drivers/iio/adc/ti-ads7924.c > index 66b54c0d75aa..b1f745f75dbe 100644 > --- a/drivers/iio/adc/ti-ads7924.c > +++ b/drivers/iio/adc/ti-ads7924.c > @@ -251,11 +251,8 @@ static const struct iio_info ads7924_info = { > .read_raw = ads7924_read_raw, > }; > > -static int ads7924_get_channels_config(struct i2c_client *client, > - struct iio_dev *indio_dev) > +static int ads7924_get_channels_config(struct device *dev) > { > - struct ads7924_data *priv = iio_priv(indio_dev); > - struct device *dev = priv->dev; > struct fwnode_handle *node; > int num_channels = 0; > > @@ -380,7 +377,7 @@ static int ads7924_probe(struct i2c_client *client) > indio_dev->num_channels = ARRAY_SIZE(ads7924_channels); > indio_dev->info = &ads7924_info; > > - ret = ads7924_get_channels_config(client, indio_dev); > + ret = ads7924_get_channels_config(dev); > if (ret < 0) > return dev_err_probe(dev, ret, > "failed to get channels configuration\n");
diff --git a/drivers/iio/adc/ti-ads7924.c b/drivers/iio/adc/ti-ads7924.c index 66b54c0d75aa..b1f745f75dbe 100644 --- a/drivers/iio/adc/ti-ads7924.c +++ b/drivers/iio/adc/ti-ads7924.c @@ -251,11 +251,8 @@ static const struct iio_info ads7924_info = { .read_raw = ads7924_read_raw, }; -static int ads7924_get_channels_config(struct i2c_client *client, - struct iio_dev *indio_dev) +static int ads7924_get_channels_config(struct device *dev) { - struct ads7924_data *priv = iio_priv(indio_dev); - struct device *dev = priv->dev; struct fwnode_handle *node; int num_channels = 0; @@ -380,7 +377,7 @@ static int ads7924_probe(struct i2c_client *client) indio_dev->num_channels = ARRAY_SIZE(ads7924_channels); indio_dev->info = &ads7924_info; - ret = ads7924_get_channels_config(client, indio_dev); + ret = ads7924_get_channels_config(dev); if (ret < 0) return dev_err_probe(dev, ret, "failed to get channels configuration\n");
Device pointer is the only variable which is used by the ads7924_get_channels_config() and which is declared outside this function. Still, the function gets the iio_device and i2c_client as parameters. The sole caller of this function (probe) already has the device pointer which it can directly pass to the function. Simplify code by passing the device pointer directly as a parameter instead of digging it from the iio_device's private data. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> --- Revision history: v4 => No changes This commit is compile-tested only! All further testing is appreciated. --- drivers/iio/adc/ti-ads7924.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)