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-adc128s052: Switch to use spi_get_device_match_data()

The spi_get_device_match_data() helps to get driver data from the
firmware node or SPI ID table. Use it instead of open coding.

While at it, switch ID tables to provide an acrual pointers to
the configuration data.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230102173450.29882-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
d5f0da0c b7b81d1c

+20 -23
+20 -23
drivers/iio/adc/ti-adc128s052.c
··· 139 139 140 140 static int adc128_probe(struct spi_device *spi) 141 141 { 142 + const struct adc128_configuration *config; 142 143 struct iio_dev *indio_dev; 143 - unsigned int config; 144 144 struct adc128 *adc; 145 145 int ret; 146 - 147 - if (dev_fwnode(&spi->dev)) 148 - config = (unsigned long) device_get_match_data(&spi->dev); 149 - else 150 - config = spi_get_device_id(spi)->driver_data; 151 146 152 147 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); 153 148 if (!indio_dev) ··· 155 160 indio_dev->modes = INDIO_DIRECT_MODE; 156 161 indio_dev->info = &adc128_info; 157 162 158 - indio_dev->channels = adc128_config[config].channels; 159 - indio_dev->num_channels = adc128_config[config].num_channels; 163 + config = spi_get_device_match_data(spi); 164 + 165 + indio_dev->channels = config->channels; 166 + indio_dev->num_channels = config->num_channels; 160 167 161 168 adc->reg = devm_regulator_get(&spi->dev, "vref"); 162 169 if (IS_ERR(adc->reg)) ··· 178 181 } 179 182 180 183 static const struct of_device_id adc128_of_match[] = { 181 - { .compatible = "ti,adc128s052", .data = (void*)0L, }, 182 - { .compatible = "ti,adc122s021", .data = (void*)1L, }, 183 - { .compatible = "ti,adc122s051", .data = (void*)1L, }, 184 - { .compatible = "ti,adc122s101", .data = (void*)1L, }, 185 - { .compatible = "ti,adc124s021", .data = (void*)2L, }, 186 - { .compatible = "ti,adc124s051", .data = (void*)2L, }, 187 - { .compatible = "ti,adc124s101", .data = (void*)2L, }, 184 + { .compatible = "ti,adc128s052", .data = &adc128_config[0] }, 185 + { .compatible = "ti,adc122s021", .data = &adc128_config[1] }, 186 + { .compatible = "ti,adc122s051", .data = &adc128_config[1] }, 187 + { .compatible = "ti,adc122s101", .data = &adc128_config[1] }, 188 + { .compatible = "ti,adc124s021", .data = &adc128_config[2] }, 189 + { .compatible = "ti,adc124s051", .data = &adc128_config[2] }, 190 + { .compatible = "ti,adc124s101", .data = &adc128_config[2] }, 188 191 { /* sentinel */ }, 189 192 }; 190 193 MODULE_DEVICE_TABLE(of, adc128_of_match); 191 194 192 195 static const struct spi_device_id adc128_id[] = { 193 - { "adc128s052", 0 }, /* index into adc128_config */ 194 - { "adc122s021", 1 }, 195 - { "adc122s051", 1 }, 196 - { "adc122s101", 1 }, 197 - { "adc124s021", 2 }, 198 - { "adc124s051", 2 }, 199 - { "adc124s101", 2 }, 196 + { "adc128s052", (kernel_ulong_t)&adc128_config[0] }, 197 + { "adc122s021", (kernel_ulong_t)&adc128_config[1] }, 198 + { "adc122s051", (kernel_ulong_t)&adc128_config[1] }, 199 + { "adc122s101", (kernel_ulong_t)&adc128_config[1] }, 200 + { "adc124s021", (kernel_ulong_t)&adc128_config[2] }, 201 + { "adc124s051", (kernel_ulong_t)&adc128_config[2] }, 202 + { "adc124s101", (kernel_ulong_t)&adc128_config[2] }, 200 203 { } 201 204 }; 202 205 MODULE_DEVICE_TABLE(spi, adc128_id); 203 206 204 207 #ifdef CONFIG_ACPI 205 208 static const struct acpi_device_id adc128_acpi_match[] = { 206 - { "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */ 209 + { "AANT1280", (kernel_ulong_t)&adc128_config[2] }, 207 210 { } 208 211 }; 209 212 MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);