linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ad7124: drop use of chip info array
@ 2025-06-28 16:16 David Lechner
  2025-06-29 17:25 ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: David Lechner @ 2025-06-28 16:16 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, David Lechner

Change the ad7124 driver to use individual chip info structures instead
of an array. This reduces the verbosity of the code. Also, the data is
now const as it should have been in the first place.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 drivers/iio/adc/ad7124.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index 92596f15e797378329d2072bff71e392664c69db..9808df2e92424283a86e9c105492c7447d071e44 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -94,11 +94,6 @@
 
 /* AD7124 input sources */
 
-enum ad7124_ids {
-	ID_AD7124_4,
-	ID_AD7124_8,
-};
-
 enum ad7124_ref_sel {
 	AD7124_REFIN1,
 	AD7124_REFIN2,
@@ -193,17 +188,16 @@ struct ad7124_state {
 	DECLARE_KFIFO(live_cfgs_fifo, struct ad7124_channel_config *, AD7124_MAX_CONFIGS);
 };
 
-static struct ad7124_chip_info ad7124_chip_info_tbl[] = {
-	[ID_AD7124_4] = {
-		.name = "ad7124-4",
-		.chip_id = AD7124_ID_DEVICE_ID_AD7124_4,
-		.num_inputs = 8,
-	},
-	[ID_AD7124_8] = {
-		.name = "ad7124-8",
-		.chip_id = AD7124_ID_DEVICE_ID_AD7124_8,
-		.num_inputs = 16,
-	},
+static const struct ad7124_chip_info ad7124_4_chip_info = {
+	.name = "ad7124-4",
+	.chip_id = AD7124_ID_DEVICE_ID_AD7124_4,
+	.num_inputs = 8,
+};
+
+static const struct ad7124_chip_info ad7124_8_chip_info = {
+	.name = "ad7124-8",
+	.chip_id = AD7124_ID_DEVICE_ID_AD7124_8,
+	.num_inputs = 16,
 };
 
 static int ad7124_find_closest_match(const int *array,
@@ -1341,17 +1335,15 @@ static int ad7124_probe(struct spi_device *spi)
 }
 
 static const struct of_device_id ad7124_of_match[] = {
-	{ .compatible = "adi,ad7124-4",
-		.data = &ad7124_chip_info_tbl[ID_AD7124_4], },
-	{ .compatible = "adi,ad7124-8",
-		.data = &ad7124_chip_info_tbl[ID_AD7124_8], },
+	{ .compatible = "adi,ad7124-4", .data = &ad7124_4_chip_info },
+	{ .compatible = "adi,ad7124-8", .data = &ad7124_8_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ad7124_of_match);
 
 static const struct spi_device_id ad71124_ids[] = {
-	{ "ad7124-4", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_4] },
-	{ "ad7124-8", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_8] },
+	{ "ad7124-4", (kernel_ulong_t)&ad7124_4_chip_info },
+	{ "ad7124-8", (kernel_ulong_t)&ad7124_8_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(spi, ad71124_ids);

---
base-commit: 14071b9cf2d751ff9bc8b5e43fa94fbf08aceea1
change-id: 20250628-iio-const-data-5-4cc817647407

Best regards,
-- 
David Lechner <dlechner@baylibre.com>


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: adc: ad7124: drop use of chip info array
  2025-06-28 16:16 [PATCH] iio: adc: ad7124: drop use of chip info array David Lechner
@ 2025-06-29 17:25 ` Jonathan Cameron
  2025-06-30  8:15   ` Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2025-06-29 17:25 UTC (permalink / raw)
  To: David Lechner
  Cc: Lars-Peter Clausen, Michael Hennerich, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel, Uwe Kleine-König

On Sat, 28 Jun 2025 11:16:51 -0500
David Lechner <dlechner@baylibre.com> wrote:

> Change the ad7124 driver to use individual chip info structures instead
> of an array. This reduces the verbosity of the code. Also, the data is
> now const as it should have been in the first place.
> 
> Signed-off-by: David Lechner <dlechner@baylibre.com>

I'm going to let these array to separate structures patches sit on list a while
as whilst I agree in general they are a nice to have, there is churn involved.

Also I might edit the titles to say
"drop use of array for chip info"

Current title kind of sounds like you stopped using any chip info at all!


For this one, Uwe has been active in the driver recently so would
be a reasonable +CC.

> ---
>  drivers/iio/adc/ad7124.c | 36 ++++++++++++++----------------------
>  1 file changed, 14 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> index 92596f15e797378329d2072bff71e392664c69db..9808df2e92424283a86e9c105492c7447d071e44 100644
> --- a/drivers/iio/adc/ad7124.c
> +++ b/drivers/iio/adc/ad7124.c
> @@ -94,11 +94,6 @@
>  
>  /* AD7124 input sources */
>  
> -enum ad7124_ids {
> -	ID_AD7124_4,
> -	ID_AD7124_8,
> -};
> -
>  enum ad7124_ref_sel {
>  	AD7124_REFIN1,
>  	AD7124_REFIN2,
> @@ -193,17 +188,16 @@ struct ad7124_state {
>  	DECLARE_KFIFO(live_cfgs_fifo, struct ad7124_channel_config *, AD7124_MAX_CONFIGS);
>  };
>  
> -static struct ad7124_chip_info ad7124_chip_info_tbl[] = {
> -	[ID_AD7124_4] = {
> -		.name = "ad7124-4",
> -		.chip_id = AD7124_ID_DEVICE_ID_AD7124_4,
> -		.num_inputs = 8,
> -	},
> -	[ID_AD7124_8] = {
> -		.name = "ad7124-8",
> -		.chip_id = AD7124_ID_DEVICE_ID_AD7124_8,
> -		.num_inputs = 16,
> -	},
> +static const struct ad7124_chip_info ad7124_4_chip_info = {
> +	.name = "ad7124-4",
> +	.chip_id = AD7124_ID_DEVICE_ID_AD7124_4,
> +	.num_inputs = 8,
> +};
> +
> +static const struct ad7124_chip_info ad7124_8_chip_info = {
> +	.name = "ad7124-8",
> +	.chip_id = AD7124_ID_DEVICE_ID_AD7124_8,
> +	.num_inputs = 16,
>  };
>  
>  static int ad7124_find_closest_match(const int *array,
> @@ -1341,17 +1335,15 @@ static int ad7124_probe(struct spi_device *spi)
>  }
>  
>  static const struct of_device_id ad7124_of_match[] = {
> -	{ .compatible = "adi,ad7124-4",
> -		.data = &ad7124_chip_info_tbl[ID_AD7124_4], },
> -	{ .compatible = "adi,ad7124-8",
> -		.data = &ad7124_chip_info_tbl[ID_AD7124_8], },
> +	{ .compatible = "adi,ad7124-4", .data = &ad7124_4_chip_info },
> +	{ .compatible = "adi,ad7124-8", .data = &ad7124_8_chip_info },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, ad7124_of_match);
>  
>  static const struct spi_device_id ad71124_ids[] = {
> -	{ "ad7124-4", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_4] },
> -	{ "ad7124-8", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_8] },
> +	{ "ad7124-4", (kernel_ulong_t)&ad7124_4_chip_info },
> +	{ "ad7124-8", (kernel_ulong_t)&ad7124_8_chip_info },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(spi, ad71124_ids);
> 
> ---
> base-commit: 14071b9cf2d751ff9bc8b5e43fa94fbf08aceea1
> change-id: 20250628-iio-const-data-5-4cc817647407
> 
> Best regards,


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: adc: ad7124: drop use of chip info array
  2025-06-29 17:25 ` Jonathan Cameron
@ 2025-06-30  8:15   ` Uwe Kleine-König
  2025-07-01 17:37     ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2025-06-30  8:15 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, Lars-Peter Clausen, Michael Hennerich,
	Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2735 bytes --]

Hello Jonathan,

On Sun, Jun 29, 2025 at 06:25:31PM +0100, Jonathan Cameron wrote:
> > ---
> >  drivers/iio/adc/ad7124.c | 36 ++++++++++++++----------------------
> >  1 file changed, 14 insertions(+), 22 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> > index 92596f15e797378329d2072bff71e392664c69db..9808df2e92424283a86e9c105492c7447d071e44 100644
> > --- a/drivers/iio/adc/ad7124.c
> > +++ b/drivers/iio/adc/ad7124.c
> > @@ -94,11 +94,6 @@
> >  
> >  /* AD7124 input sources */
> >  
> > -enum ad7124_ids {
> > -	ID_AD7124_4,
> > -	ID_AD7124_8,
> > -};
> > -
> >  enum ad7124_ref_sel {
> >  	AD7124_REFIN1,
> >  	AD7124_REFIN2,
> > @@ -193,17 +188,16 @@ struct ad7124_state {
> >  	DECLARE_KFIFO(live_cfgs_fifo, struct ad7124_channel_config *, AD7124_MAX_CONFIGS);
> >  };
> >  
> > -static struct ad7124_chip_info ad7124_chip_info_tbl[] = {
> > -	[ID_AD7124_4] = {
> > -		.name = "ad7124-4",
> > -		.chip_id = AD7124_ID_DEVICE_ID_AD7124_4,
> > -		.num_inputs = 8,
> > -	},
> > -	[ID_AD7124_8] = {
> > -		.name = "ad7124-8",
> > -		.chip_id = AD7124_ID_DEVICE_ID_AD7124_8,
> > -		.num_inputs = 16,
> > -	},
> > +static const struct ad7124_chip_info ad7124_4_chip_info = {
> > +	.name = "ad7124-4",
> > +	.chip_id = AD7124_ID_DEVICE_ID_AD7124_4,
> > +	.num_inputs = 8,
> > +};
> > +
> > +static const struct ad7124_chip_info ad7124_8_chip_info = {
> > +	.name = "ad7124-8",
> > +	.chip_id = AD7124_ID_DEVICE_ID_AD7124_8,
> > +	.num_inputs = 16,
> >  };
> >  
> >  static int ad7124_find_closest_match(const int *array,
> > @@ -1341,17 +1335,15 @@ static int ad7124_probe(struct spi_device *spi)
> >  }
> >  
> >  static const struct of_device_id ad7124_of_match[] = {
> > -	{ .compatible = "adi,ad7124-4",
> > -		.data = &ad7124_chip_info_tbl[ID_AD7124_4], },
> > -	{ .compatible = "adi,ad7124-8",
> > -		.data = &ad7124_chip_info_tbl[ID_AD7124_8], },
> > +	{ .compatible = "adi,ad7124-4", .data = &ad7124_4_chip_info },
> > +	{ .compatible = "adi,ad7124-8", .data = &ad7124_8_chip_info },
> >  	{ }
> >  };
> >  MODULE_DEVICE_TABLE(of, ad7124_of_match);
> >  
> >  static const struct spi_device_id ad71124_ids[] = {
> > -	{ "ad7124-4", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_4] },
> > -	{ "ad7124-8", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_8] },
> > +	{ "ad7124-4", (kernel_ulong_t)&ad7124_4_chip_info },
> > +	{ "ad7124-8", (kernel_ulong_t)&ad7124_8_chip_info },
> >  	{ }
> >  };
> >  MODULE_DEVICE_TABLE(spi, ad71124_ids);

The patch looks fine for me. I remember having considered creating such
a patch, too.

Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: adc: ad7124: drop use of chip info array
  2025-06-30  8:15   ` Uwe Kleine-König
@ 2025-07-01 17:37     ` Jonathan Cameron
  2025-07-02  6:56       ` Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2025-07-01 17:37 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: David Lechner, Lars-Peter Clausen, Michael Hennerich,
	Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel

On Mon, 30 Jun 2025 10:15:14 +0200
Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote:

> Hello Jonathan,
> 
> On Sun, Jun 29, 2025 at 06:25:31PM +0100, Jonathan Cameron wrote:
> > > ---
> > >  drivers/iio/adc/ad7124.c | 36 ++++++++++++++----------------------
> > >  1 file changed, 14 insertions(+), 22 deletions(-)
> > > 
> > > diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> > > index 92596f15e797378329d2072bff71e392664c69db..9808df2e92424283a86e9c105492c7447d071e44 100644
> > > --- a/drivers/iio/adc/ad7124.c
> > > +++ b/drivers/iio/adc/ad7124.c
> > > @@ -94,11 +94,6 @@
> > >  
> > >  /* AD7124 input sources */
> > >  
> > > -enum ad7124_ids {
> > > -	ID_AD7124_4,
> > > -	ID_AD7124_8,
> > > -};
> > > -
> > >  enum ad7124_ref_sel {
> > >  	AD7124_REFIN1,
> > >  	AD7124_REFIN2,
> > > @@ -193,17 +188,16 @@ struct ad7124_state {
> > >  	DECLARE_KFIFO(live_cfgs_fifo, struct ad7124_channel_config *, AD7124_MAX_CONFIGS);
> > >  };
> > >  
> > > -static struct ad7124_chip_info ad7124_chip_info_tbl[] = {
> > > -	[ID_AD7124_4] = {
> > > -		.name = "ad7124-4",
> > > -		.chip_id = AD7124_ID_DEVICE_ID_AD7124_4,
> > > -		.num_inputs = 8,
> > > -	},
> > > -	[ID_AD7124_8] = {
> > > -		.name = "ad7124-8",
> > > -		.chip_id = AD7124_ID_DEVICE_ID_AD7124_8,
> > > -		.num_inputs = 16,
> > > -	},
> > > +static const struct ad7124_chip_info ad7124_4_chip_info = {
> > > +	.name = "ad7124-4",
> > > +	.chip_id = AD7124_ID_DEVICE_ID_AD7124_4,
> > > +	.num_inputs = 8,
> > > +};
> > > +
> > > +static const struct ad7124_chip_info ad7124_8_chip_info = {
> > > +	.name = "ad7124-8",
> > > +	.chip_id = AD7124_ID_DEVICE_ID_AD7124_8,
> > > +	.num_inputs = 16,
> > >  };
> > >  
> > >  static int ad7124_find_closest_match(const int *array,
> > > @@ -1341,17 +1335,15 @@ static int ad7124_probe(struct spi_device *spi)
> > >  }
> > >  
> > >  static const struct of_device_id ad7124_of_match[] = {
> > > -	{ .compatible = "adi,ad7124-4",
> > > -		.data = &ad7124_chip_info_tbl[ID_AD7124_4], },
> > > -	{ .compatible = "adi,ad7124-8",
> > > -		.data = &ad7124_chip_info_tbl[ID_AD7124_8], },
> > > +	{ .compatible = "adi,ad7124-4", .data = &ad7124_4_chip_info },
> > > +	{ .compatible = "adi,ad7124-8", .data = &ad7124_8_chip_info },
> > >  	{ }
> > >  };
> > >  MODULE_DEVICE_TABLE(of, ad7124_of_match);
> > >  
> > >  static const struct spi_device_id ad71124_ids[] = {
> > > -	{ "ad7124-4", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_4] },
> > > -	{ "ad7124-8", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_8] },
> > > +	{ "ad7124-4", (kernel_ulong_t)&ad7124_4_chip_info },
> > > +	{ "ad7124-8", (kernel_ulong_t)&ad7124_8_chip_info },
> > >  	{ }
> > >  };
> > >  MODULE_DEVICE_TABLE(spi, ad71124_ids);  
> 
> The patch looks fine for me. I remember having considered creating such
> a patch, too.
> 
> Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Applied.  Thanks

> 
> Best regards
> Uwe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: adc: ad7124: drop use of chip info array
  2025-07-01 17:37     ` Jonathan Cameron
@ 2025-07-02  6:56       ` Uwe Kleine-König
  2025-07-06  9:48         ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2025-07-02  6:56 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, Lars-Peter Clausen, Michael Hennerich,
	Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

Hello Jonathan,

On Tue, Jul 01, 2025 at 06:37:51PM +0100, Jonathan Cameron wrote:
> On Mon, 30 Jun 2025 10:15:14 +0200
> Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote:
> 
> > [...]
> > The patch looks fine for me. I remember having considered creating such
> > a patch, too.
> > 
> > Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> Applied.  Thanks

Huh, I'm surprised. Did you address "Current title kind of sounds like
you stopped using any chip info at all!" while applying?

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] iio: adc: ad7124: drop use of chip info array
  2025-07-02  6:56       ` Uwe Kleine-König
@ 2025-07-06  9:48         ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2025-07-06  9:48 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: David Lechner, Lars-Peter Clausen, Michael Hennerich,
	Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel

On Wed, 2 Jul 2025 08:56:54 +0200
Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote:

> Hello Jonathan,
> 
> On Tue, Jul 01, 2025 at 06:37:51PM +0100, Jonathan Cameron wrote:
> > On Mon, 30 Jun 2025 10:15:14 +0200
> > Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote:
> >   
> > > [...]
> > > The patch looks fine for me. I remember having considered creating such
> > > a patch, too.
> > > 
> > > Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>  
> > Applied.  Thanks  
> 
> Huh, I'm surprised. Did you address "Current title kind of sounds like
> you stopped using any chip info at all!" while applying?
Good point. I forgot my own feedback.  I'll tweak it and push out again.

> 
> Best regards
> Uwe


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-06  9:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-28 16:16 [PATCH] iio: adc: ad7124: drop use of chip info array David Lechner
2025-06-29 17:25 ` Jonathan Cameron
2025-06-30  8:15   ` Uwe Kleine-König
2025-07-01 17:37     ` Jonathan Cameron
2025-07-02  6:56       ` Uwe Kleine-König
2025-07-06  9:48         ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).