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

iio: adc: ti-adc081c: Simplify probe()

Simpilfy probe() by replacing of_device_get_match_data() and id lookup for
retrieving match data by using i2c_get_match_data() by making similar
OF/I2C/ACPI match tables.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20230902162633.50546-1-biju.das.jz@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Biju Das and committed by
Jonathan Cameron
5793ddcf 17f961a6

+4 -8
+4 -8
drivers/iio/adc/ti-adc081c.c
··· 154 154 155 155 static int adc081c_probe(struct i2c_client *client) 156 156 { 157 - const struct i2c_device_id *id = i2c_client_get_device_id(client); 158 157 struct iio_dev *iio; 159 158 struct adc081c *adc; 160 159 const struct adcxx1c_model *model; ··· 162 163 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) 163 164 return -EOPNOTSUPP; 164 165 165 - if (dev_fwnode(&client->dev)) 166 - model = device_get_match_data(&client->dev); 167 - else 168 - model = &adcxx1c_models[id->driver_data]; 166 + model = i2c_get_match_data(client); 169 167 170 168 iio = devm_iio_device_alloc(&client->dev, sizeof(*adc)); 171 169 if (!iio) ··· 203 207 } 204 208 205 209 static const struct i2c_device_id adc081c_id[] = { 206 - { "adc081c", ADC081C }, 207 - { "adc101c", ADC101C }, 208 - { "adc121c", ADC121C }, 210 + { "adc081c", (kernel_ulong_t)&adcxx1c_models[ADC081C] }, 211 + { "adc101c", (kernel_ulong_t)&adcxx1c_models[ADC101C] }, 212 + { "adc121c", (kernel_ulong_t)&adcxx1c_models[ADC121C] }, 209 213 { } 210 214 }; 211 215 MODULE_DEVICE_TABLE(i2c, adc081c_id);