drivers/iio/adc/ad7124.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
Remove __ad7124_set_channel() wrapper function. This just added an
unnecessary layer of indirection with an extra call to container_of().
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
Just a small cleanup while I continue to work on this driver.
---
drivers/iio/adc/ad7124.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index 910b40393f77de84afc77d406c17c6e5051a02cd..c24f3d5127cb83eeab0cf37882446fc994173274 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -657,20 +657,13 @@ static int ad7124_prepare_read(struct ad7124_state *st, int address)
return ad7124_enable_channel(st, &st->channels[address]);
}
-static int __ad7124_set_channel(struct ad_sigma_delta *sd, unsigned int channel)
-{
- struct ad7124_state *st = container_of(sd, struct ad7124_state, sd);
-
- return ad7124_prepare_read(st, channel);
-}
-
static int ad7124_set_channel(struct ad_sigma_delta *sd, unsigned int channel)
{
struct ad7124_state *st = container_of(sd, struct ad7124_state, sd);
int ret;
mutex_lock(&st->cfgs_lock);
- ret = __ad7124_set_channel(sd, channel);
+ ret = ad7124_prepare_read(st, channel);
mutex_unlock(&st->cfgs_lock);
return ret;
@@ -965,7 +958,7 @@ static int ad7124_update_scan_mode(struct iio_dev *indio_dev,
for (i = 0; i < st->num_channels; i++) {
bit_set = test_bit(i, scan_mask);
if (bit_set)
- ret = __ad7124_set_channel(&st->sd, i);
+ ret = ad7124_prepare_read(st, i);
else
ret = ad7124_spi_write_mask(st, AD7124_CHANNEL(i), AD7124_CHANNEL_ENABLE,
0, 2);
---
base-commit: df76e03e8127f756f314418d683bad24b460c61f
change-id: 20250916-iio-adc-ad7124-remove-__ad7124_set_channel-d8e5c30ec7c6
Best regards,
--
David Lechner <dlechner@baylibre.com>
For some reason I put drivers: in the subject, which should not be there.
On Tue, 2025-09-16 at 16:39 -0500, David Lechner wrote:
> Remove __ad7124_set_channel() wrapper function. This just added an
> unnecessary layer of indirection with an extra call to container_of().
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> Just a small cleanup while I continue to work on this driver.
> ---
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> drivers/iio/adc/ad7124.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> index
> 910b40393f77de84afc77d406c17c6e5051a02cd..c24f3d5127cb83eeab0cf37882446fc99417
> 3274 100644
> --- a/drivers/iio/adc/ad7124.c
> +++ b/drivers/iio/adc/ad7124.c
> @@ -657,20 +657,13 @@ static int ad7124_prepare_read(struct ad7124_state *st,
> int address)
> return ad7124_enable_channel(st, &st->channels[address]);
> }
>
> -static int __ad7124_set_channel(struct ad_sigma_delta *sd, unsigned int
> channel)
> -{
> - struct ad7124_state *st = container_of(sd, struct ad7124_state, sd);
> -
> - return ad7124_prepare_read(st, channel);
> -}
> -
> static int ad7124_set_channel(struct ad_sigma_delta *sd, unsigned int
> channel)
> {
> struct ad7124_state *st = container_of(sd, struct ad7124_state, sd);
> int ret;
>
> mutex_lock(&st->cfgs_lock);
> - ret = __ad7124_set_channel(sd, channel);
> + ret = ad7124_prepare_read(st, channel);
> mutex_unlock(&st->cfgs_lock);
>
> return ret;
> @@ -965,7 +958,7 @@ static int ad7124_update_scan_mode(struct iio_dev
> *indio_dev,
> for (i = 0; i < st->num_channels; i++) {
> bit_set = test_bit(i, scan_mask);
> if (bit_set)
> - ret = __ad7124_set_channel(&st->sd, i);
> + ret = ad7124_prepare_read(st, i);
> else
> ret = ad7124_spi_write_mask(st, AD7124_CHANNEL(i),
> AD7124_CHANNEL_ENABLE,
> 0, 2);
>
> ---
> base-commit: df76e03e8127f756f314418d683bad24b460c61f
> change-id: 20250916-iio-adc-ad7124-remove-__ad7124_set_channel-d8e5c30ec7c6
>
> Best regards,
© 2016 - 2026 Red Hat, Inc.