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: ad7124: Use separate structures rather than array for chip info

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>
Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250628-iio-const-data-5-v1-1-9e56c2f77979@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
5eef68d6 b1a6eac5

+14 -22
+14 -22
drivers/iio/adc/ad7124.c
··· 94 94 95 95 /* AD7124 input sources */ 96 96 97 - enum ad7124_ids { 98 - ID_AD7124_4, 99 - ID_AD7124_8, 100 - }; 101 - 102 97 enum ad7124_ref_sel { 103 98 AD7124_REFIN1, 104 99 AD7124_REFIN2, ··· 188 193 DECLARE_KFIFO(live_cfgs_fifo, struct ad7124_channel_config *, AD7124_MAX_CONFIGS); 189 194 }; 190 195 191 - static struct ad7124_chip_info ad7124_chip_info_tbl[] = { 192 - [ID_AD7124_4] = { 193 - .name = "ad7124-4", 194 - .chip_id = AD7124_ID_DEVICE_ID_AD7124_4, 195 - .num_inputs = 8, 196 - }, 197 - [ID_AD7124_8] = { 198 - .name = "ad7124-8", 199 - .chip_id = AD7124_ID_DEVICE_ID_AD7124_8, 200 - .num_inputs = 16, 201 - }, 196 + static const struct ad7124_chip_info ad7124_4_chip_info = { 197 + .name = "ad7124-4", 198 + .chip_id = AD7124_ID_DEVICE_ID_AD7124_4, 199 + .num_inputs = 8, 200 + }; 201 + 202 + static const struct ad7124_chip_info ad7124_8_chip_info = { 203 + .name = "ad7124-8", 204 + .chip_id = AD7124_ID_DEVICE_ID_AD7124_8, 205 + .num_inputs = 16, 202 206 }; 203 207 204 208 static int ad7124_find_closest_match(const int *array, ··· 1335 1341 } 1336 1342 1337 1343 static const struct of_device_id ad7124_of_match[] = { 1338 - { .compatible = "adi,ad7124-4", 1339 - .data = &ad7124_chip_info_tbl[ID_AD7124_4], }, 1340 - { .compatible = "adi,ad7124-8", 1341 - .data = &ad7124_chip_info_tbl[ID_AD7124_8], }, 1344 + { .compatible = "adi,ad7124-4", .data = &ad7124_4_chip_info }, 1345 + { .compatible = "adi,ad7124-8", .data = &ad7124_8_chip_info }, 1342 1346 { } 1343 1347 }; 1344 1348 MODULE_DEVICE_TABLE(of, ad7124_of_match); 1345 1349 1346 1350 static const struct spi_device_id ad71124_ids[] = { 1347 - { "ad7124-4", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_4] }, 1348 - { "ad7124-8", (kernel_ulong_t)&ad7124_chip_info_tbl[ID_AD7124_8] }, 1351 + { "ad7124-4", (kernel_ulong_t)&ad7124_4_chip_info }, 1352 + { "ad7124-8", (kernel_ulong_t)&ad7124_8_chip_info }, 1349 1353 { } 1350 1354 }; 1351 1355 MODULE_DEVICE_TABLE(spi, ad71124_ids);