* [PATCH v2] iio: adc: ti-adc081c: use individual model structures instead of array
@ 2025-07-21 22:12 David Lechner
2025-07-22 9:06 ` Nuno Sá
0 siblings, 1 reply; 3+ messages in thread
From: David Lechner @ 2025-07-21 22:12 UTC (permalink / raw)
To: Jonathan Cameron, Nuno Sá, Andy Shevchenko, David Lechner
Cc: linux-iio, linux-kernel
Change the ti-adc081c driver to use individual model 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. The ADCxx1C_MODEL()
macro is dropped to be consistent with similar model definitions in
other drivers.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
Changes in v2:
- Drop use of ADCxx1C_MODEL() macro.
- Link to v1: https://lore.kernel.org/r/20250628-iio-const-data-11-v1-1-268189459192@baylibre.com
---
drivers/iio/adc/ti-adc081c.c | 40 ++++++++++++++++++----------------------
1 file changed, 18 insertions(+), 22 deletions(-)
diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c
index 4f514db5c26ea803660087ae02b2cf8ec71911e4..8ef51c57912de62b1d6a6913372b2cc8c6d463ae 100644
--- a/drivers/iio/adc/ti-adc081c.c
+++ b/drivers/iio/adc/ti-adc081c.c
@@ -102,27 +102,23 @@ struct adcxx1c_model {
int bits;
};
-#define ADCxx1C_MODEL(_name, _bits) \
- { \
- .channels = _name ## _channels, \
- .bits = (_bits), \
- }
-
DEFINE_ADCxx1C_CHANNELS(adc081c, 8);
DEFINE_ADCxx1C_CHANNELS(adc101c, 10);
DEFINE_ADCxx1C_CHANNELS(adc121c, 12);
-/* Model ids are indexes in _models array */
-enum adcxx1c_model_id {
- ADC081C = 0,
- ADC101C = 1,
- ADC121C = 2,
+static const struct adcxx1c_model adc081c_model = {
+ .channels = adc081c_channels,
+ .bits = 8,
+};
+
+static const struct adcxx1c_model adc101c_model = {
+ .channels = adc101c_channels,
+ .bits = 10,
};
-static struct adcxx1c_model adcxx1c_models[] = {
- ADCxx1C_MODEL(adc081c, 8),
- ADCxx1C_MODEL(adc101c, 10),
- ADCxx1C_MODEL(adc121c, 12),
+static const struct adcxx1c_model adc121c_model = {
+ .channels = adc121c_channels,
+ .bits = 12,
};
static const struct iio_info adc081c_info = {
@@ -203,24 +199,24 @@ static int adc081c_probe(struct i2c_client *client)
}
static const struct i2c_device_id adc081c_id[] = {
- { "adc081c", (kernel_ulong_t)&adcxx1c_models[ADC081C] },
- { "adc101c", (kernel_ulong_t)&adcxx1c_models[ADC101C] },
- { "adc121c", (kernel_ulong_t)&adcxx1c_models[ADC121C] },
+ { "adc081c", (kernel_ulong_t)&adc081c_model },
+ { "adc101c", (kernel_ulong_t)&adc101c_model },
+ { "adc121c", (kernel_ulong_t)&adc121c_model },
{ }
};
MODULE_DEVICE_TABLE(i2c, adc081c_id);
static const struct acpi_device_id adc081c_acpi_match[] = {
/* Used on some AAEON boards */
- { "ADC081C", (kernel_ulong_t)&adcxx1c_models[ADC081C] },
+ { "ADC081C", (kernel_ulong_t)&adc081c_model },
{ }
};
MODULE_DEVICE_TABLE(acpi, adc081c_acpi_match);
static const struct of_device_id adc081c_of_match[] = {
- { .compatible = "ti,adc081c", .data = &adcxx1c_models[ADC081C] },
- { .compatible = "ti,adc101c", .data = &adcxx1c_models[ADC101C] },
- { .compatible = "ti,adc121c", .data = &adcxx1c_models[ADC121C] },
+ { .compatible = "ti,adc081c", .data = &adc081c_model },
+ { .compatible = "ti,adc101c", .data = &adc101c_model },
+ { .compatible = "ti,adc121c", .data = &adc121c_model },
{ }
};
MODULE_DEVICE_TABLE(of, adc081c_of_match);
---
base-commit: cd2731444ee4e35db76f4fb587f12d327eec5446
change-id: 20250628-iio-const-data-11-1c6b9e28aded
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] iio: adc: ti-adc081c: use individual model structures instead of array
2025-07-21 22:12 [PATCH v2] iio: adc: ti-adc081c: use individual model structures instead of array David Lechner
@ 2025-07-22 9:06 ` Nuno Sá
2025-08-02 11:53 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Nuno Sá @ 2025-07-22 9:06 UTC (permalink / raw)
To: David Lechner
Cc: Jonathan Cameron, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On Mon, Jul 21, 2025 at 05:12:47PM -0500, David Lechner wrote:
> Change the ti-adc081c driver to use individual model 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. The ADCxx1C_MODEL()
> macro is dropped to be consistent with similar model definitions in
> other drivers.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> Changes in v2:
> - Drop use of ADCxx1C_MODEL() macro.
> - Link to v1: https://lore.kernel.org/r/20250628-iio-const-data-11-v1-1-268189459192@baylibre.com
> ---
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> drivers/iio/adc/ti-adc081c.c | 40 ++++++++++++++++++----------------------
> 1 file changed, 18 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c
> index 4f514db5c26ea803660087ae02b2cf8ec71911e4..8ef51c57912de62b1d6a6913372b2cc8c6d463ae 100644
> --- a/drivers/iio/adc/ti-adc081c.c
> +++ b/drivers/iio/adc/ti-adc081c.c
> @@ -102,27 +102,23 @@ struct adcxx1c_model {
> int bits;
> };
>
> -#define ADCxx1C_MODEL(_name, _bits) \
> - { \
> - .channels = _name ## _channels, \
> - .bits = (_bits), \
> - }
> -
> DEFINE_ADCxx1C_CHANNELS(adc081c, 8);
> DEFINE_ADCxx1C_CHANNELS(adc101c, 10);
> DEFINE_ADCxx1C_CHANNELS(adc121c, 12);
>
> -/* Model ids are indexes in _models array */
> -enum adcxx1c_model_id {
> - ADC081C = 0,
> - ADC101C = 1,
> - ADC121C = 2,
> +static const struct adcxx1c_model adc081c_model = {
> + .channels = adc081c_channels,
> + .bits = 8,
> +};
> +
> +static const struct adcxx1c_model adc101c_model = {
> + .channels = adc101c_channels,
> + .bits = 10,
> };
>
> -static struct adcxx1c_model adcxx1c_models[] = {
> - ADCxx1C_MODEL(adc081c, 8),
> - ADCxx1C_MODEL(adc101c, 10),
> - ADCxx1C_MODEL(adc121c, 12),
> +static const struct adcxx1c_model adc121c_model = {
> + .channels = adc121c_channels,
> + .bits = 12,
> };
>
> static const struct iio_info adc081c_info = {
> @@ -203,24 +199,24 @@ static int adc081c_probe(struct i2c_client *client)
> }
>
> static const struct i2c_device_id adc081c_id[] = {
> - { "adc081c", (kernel_ulong_t)&adcxx1c_models[ADC081C] },
> - { "adc101c", (kernel_ulong_t)&adcxx1c_models[ADC101C] },
> - { "adc121c", (kernel_ulong_t)&adcxx1c_models[ADC121C] },
> + { "adc081c", (kernel_ulong_t)&adc081c_model },
> + { "adc101c", (kernel_ulong_t)&adc101c_model },
> + { "adc121c", (kernel_ulong_t)&adc121c_model },
> { }
> };
> MODULE_DEVICE_TABLE(i2c, adc081c_id);
>
> static const struct acpi_device_id adc081c_acpi_match[] = {
> /* Used on some AAEON boards */
> - { "ADC081C", (kernel_ulong_t)&adcxx1c_models[ADC081C] },
> + { "ADC081C", (kernel_ulong_t)&adc081c_model },
> { }
> };
> MODULE_DEVICE_TABLE(acpi, adc081c_acpi_match);
>
> static const struct of_device_id adc081c_of_match[] = {
> - { .compatible = "ti,adc081c", .data = &adcxx1c_models[ADC081C] },
> - { .compatible = "ti,adc101c", .data = &adcxx1c_models[ADC101C] },
> - { .compatible = "ti,adc121c", .data = &adcxx1c_models[ADC121C] },
> + { .compatible = "ti,adc081c", .data = &adc081c_model },
> + { .compatible = "ti,adc101c", .data = &adc101c_model },
> + { .compatible = "ti,adc121c", .data = &adc121c_model },
> { }
> };
> MODULE_DEVICE_TABLE(of, adc081c_of_match);
>
> ---
> base-commit: cd2731444ee4e35db76f4fb587f12d327eec5446
> change-id: 20250628-iio-const-data-11-1c6b9e28aded
>
> Best regards,
> --
> David Lechner <dlechner@baylibre.com>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] iio: adc: ti-adc081c: use individual model structures instead of array
2025-07-22 9:06 ` Nuno Sá
@ 2025-08-02 11:53 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2025-08-02 11:53 UTC (permalink / raw)
To: Nuno Sá
Cc: David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On Tue, 22 Jul 2025 10:06:51 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Mon, Jul 21, 2025 at 05:12:47PM -0500, David Lechner wrote:
> > Change the ti-adc081c driver to use individual model 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. The ADCxx1C_MODEL()
> > macro is dropped to be consistent with similar model definitions in
> > other drivers.
> >
> > Signed-off-by: David Lechner <dlechner@baylibre.com>
> > ---
> > Changes in v2:
> > - Drop use of ADCxx1C_MODEL() macro.
> > - Link to v1: https://lore.kernel.org/r/20250628-iio-const-data-11-v1-1-268189459192@baylibre.com
> > ---
>
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Hmm. Seems I picked this up a while back but neither replied or updated
patch work. Oops.
Jonathan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-02 11:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 22:12 [PATCH v2] iio: adc: ti-adc081c: use individual model structures instead of array David Lechner
2025-07-22 9:06 ` Nuno Sá
2025-08-02 11:53 ` 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).