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

iio: adc: ad9467: use chip_info variables instead of array

Instead of having an array and keeping IDs for each entry of the array,
just have a chip_info struct per device.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20231207-iio-backend-prep-v2-6-a4a33bc4d70e@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sa and committed by
Jonathan Cameron
6dd3fa9f b67cc85d

+43 -46
+43 -46
drivers/iio/adc/ad9467.c
··· 101 101 #define AD9467_DEF_OUTPUT_MODE 0x08 102 102 #define AD9467_REG_VREF_MASK 0x0F 103 103 104 - enum { 105 - ID_AD9265, 106 - ID_AD9434, 107 - ID_AD9467, 108 - }; 109 - 110 104 struct ad9467_chip_info { 111 105 struct adi_axi_adc_chip_info axi_adc_info; 112 106 unsigned int default_output_mode; ··· 228 234 AD9467_CHAN(0, 0, 16, 'S'), 229 235 }; 230 236 231 - static const struct ad9467_chip_info ad9467_chip_tbl[] = { 232 - [ID_AD9265] = { 233 - .axi_adc_info = { 234 - .id = CHIPID_AD9265, 235 - .max_rate = 125000000UL, 236 - .scale_table = ad9265_scale_table, 237 - .num_scales = ARRAY_SIZE(ad9265_scale_table), 238 - .channels = ad9467_channels, 239 - .num_channels = ARRAY_SIZE(ad9467_channels), 240 - }, 241 - .default_output_mode = AD9265_DEF_OUTPUT_MODE, 242 - .vref_mask = AD9265_REG_VREF_MASK, 237 + static const struct ad9467_chip_info ad9467_chip_tbl = { 238 + .axi_adc_info = { 239 + .name = "ad9467", 240 + .id = CHIPID_AD9467, 241 + .max_rate = 250000000UL, 242 + .scale_table = ad9467_scale_table, 243 + .num_scales = ARRAY_SIZE(ad9467_scale_table), 244 + .channels = ad9467_channels, 245 + .num_channels = ARRAY_SIZE(ad9467_channels), 243 246 }, 244 - [ID_AD9434] = { 245 - .axi_adc_info = { 246 - .id = CHIPID_AD9434, 247 - .max_rate = 500000000UL, 248 - .scale_table = ad9434_scale_table, 249 - .num_scales = ARRAY_SIZE(ad9434_scale_table), 250 - .channels = ad9434_channels, 251 - .num_channels = ARRAY_SIZE(ad9434_channels), 252 - }, 253 - .default_output_mode = AD9434_DEF_OUTPUT_MODE, 254 - .vref_mask = AD9434_REG_VREF_MASK, 247 + .default_output_mode = AD9467_DEF_OUTPUT_MODE, 248 + .vref_mask = AD9467_REG_VREF_MASK, 249 + }; 250 + 251 + static const struct ad9467_chip_info ad9434_chip_tbl = { 252 + .axi_adc_info = { 253 + .name = "ad9434", 254 + .id = CHIPID_AD9434, 255 + .max_rate = 500000000UL, 256 + .scale_table = ad9434_scale_table, 257 + .num_scales = ARRAY_SIZE(ad9434_scale_table), 258 + .channels = ad9434_channels, 259 + .num_channels = ARRAY_SIZE(ad9434_channels), 255 260 }, 256 - [ID_AD9467] = { 257 - .axi_adc_info = { 258 - .id = CHIPID_AD9467, 259 - .max_rate = 250000000UL, 260 - .scale_table = ad9467_scale_table, 261 - .num_scales = ARRAY_SIZE(ad9467_scale_table), 262 - .channels = ad9467_channels, 263 - .num_channels = ARRAY_SIZE(ad9467_channels), 264 - }, 265 - .default_output_mode = AD9467_DEF_OUTPUT_MODE, 266 - .vref_mask = AD9467_REG_VREF_MASK, 261 + .default_output_mode = AD9434_DEF_OUTPUT_MODE, 262 + .vref_mask = AD9434_REG_VREF_MASK, 263 + }; 264 + 265 + static const struct ad9467_chip_info ad9265_chip_tbl = { 266 + .axi_adc_info = { 267 + .name = "ad9265", 268 + .id = CHIPID_AD9265, 269 + .max_rate = 125000000UL, 270 + .scale_table = ad9265_scale_table, 271 + .num_scales = ARRAY_SIZE(ad9265_scale_table), 272 + .channels = ad9467_channels, 273 + .num_channels = ARRAY_SIZE(ad9467_channels), 267 274 }, 275 + .default_output_mode = AD9265_DEF_OUTPUT_MODE, 276 + .vref_mask = AD9265_REG_VREF_MASK, 268 277 }; 269 278 270 279 static int ad9467_get_scale(struct adi_axi_adc_conv *conv, int *val, int *val2) ··· 501 504 } 502 505 503 506 static const struct of_device_id ad9467_of_match[] = { 504 - { .compatible = "adi,ad9265", .data = &ad9467_chip_tbl[ID_AD9265], }, 505 - { .compatible = "adi,ad9434", .data = &ad9467_chip_tbl[ID_AD9434], }, 506 - { .compatible = "adi,ad9467", .data = &ad9467_chip_tbl[ID_AD9467], }, 507 + { .compatible = "adi,ad9265", .data = &ad9265_chip_tbl, }, 508 + { .compatible = "adi,ad9434", .data = &ad9434_chip_tbl, }, 509 + { .compatible = "adi,ad9467", .data = &ad9467_chip_tbl, }, 507 510 {} 508 511 }; 509 512 MODULE_DEVICE_TABLE(of, ad9467_of_match); 510 513 511 514 static const struct spi_device_id ad9467_ids[] = { 512 - { "ad9265", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9265] }, 513 - { "ad9434", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9434] }, 514 - { "ad9467", (kernel_ulong_t)&ad9467_chip_tbl[ID_AD9467] }, 515 + { "ad9265", (kernel_ulong_t)&ad9265_chip_tbl }, 516 + { "ad9434", (kernel_ulong_t)&ad9434_chip_tbl }, 517 + { "ad9467", (kernel_ulong_t)&ad9467_chip_tbl }, 515 518 {} 516 519 }; 517 520 MODULE_DEVICE_TABLE(spi, ad9467_ids);