Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ti-adc081c: use individual model structures instead of array

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>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250721-iio-const-data-11-v2-1-c3fec12511ee@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
972b1d5d 97b262d2

+18 -22
+18 -22
drivers/iio/adc/ti-adc081c.c
··· 102 102 int bits; 103 103 }; 104 104 105 - #define ADCxx1C_MODEL(_name, _bits) \ 106 - { \ 107 - .channels = _name ## _channels, \ 108 - .bits = (_bits), \ 109 - } 110 - 111 105 DEFINE_ADCxx1C_CHANNELS(adc081c, 8); 112 106 DEFINE_ADCxx1C_CHANNELS(adc101c, 10); 113 107 DEFINE_ADCxx1C_CHANNELS(adc121c, 12); 114 108 115 - /* Model ids are indexes in _models array */ 116 - enum adcxx1c_model_id { 117 - ADC081C = 0, 118 - ADC101C = 1, 119 - ADC121C = 2, 109 + static const struct adcxx1c_model adc081c_model = { 110 + .channels = adc081c_channels, 111 + .bits = 8, 120 112 }; 121 113 122 - static struct adcxx1c_model adcxx1c_models[] = { 123 - ADCxx1C_MODEL(adc081c, 8), 124 - ADCxx1C_MODEL(adc101c, 10), 125 - ADCxx1C_MODEL(adc121c, 12), 114 + static const struct adcxx1c_model adc101c_model = { 115 + .channels = adc101c_channels, 116 + .bits = 10, 117 + }; 118 + 119 + static const struct adcxx1c_model adc121c_model = { 120 + .channels = adc121c_channels, 121 + .bits = 12, 126 122 }; 127 123 128 124 static const struct iio_info adc081c_info = { ··· 199 203 } 200 204 201 205 static const struct i2c_device_id adc081c_id[] = { 202 - { "adc081c", (kernel_ulong_t)&adcxx1c_models[ADC081C] }, 203 - { "adc101c", (kernel_ulong_t)&adcxx1c_models[ADC101C] }, 204 - { "adc121c", (kernel_ulong_t)&adcxx1c_models[ADC121C] }, 206 + { "adc081c", (kernel_ulong_t)&adc081c_model }, 207 + { "adc101c", (kernel_ulong_t)&adc101c_model }, 208 + { "adc121c", (kernel_ulong_t)&adc121c_model }, 205 209 { } 206 210 }; 207 211 MODULE_DEVICE_TABLE(i2c, adc081c_id); 208 212 209 213 static const struct acpi_device_id adc081c_acpi_match[] = { 210 214 /* Used on some AAEON boards */ 211 - { "ADC081C", (kernel_ulong_t)&adcxx1c_models[ADC081C] }, 215 + { "ADC081C", (kernel_ulong_t)&adc081c_model }, 212 216 { } 213 217 }; 214 218 MODULE_DEVICE_TABLE(acpi, adc081c_acpi_match); 215 219 216 220 static const struct of_device_id adc081c_of_match[] = { 217 - { .compatible = "ti,adc081c", .data = &adcxx1c_models[ADC081C] }, 218 - { .compatible = "ti,adc101c", .data = &adcxx1c_models[ADC101C] }, 219 - { .compatible = "ti,adc121c", .data = &adcxx1c_models[ADC121C] }, 221 + { .compatible = "ti,adc081c", .data = &adc081c_model }, 222 + { .compatible = "ti,adc101c", .data = &adc101c_model }, 223 + { .compatible = "ti,adc121c", .data = &adc121c_model }, 220 224 { } 221 225 }; 222 226 MODULE_DEVICE_TABLE(of, adc081c_of_match);