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

hwmon: use simple i2c probe function (take 2)

Many hwmon drivers don't use the id information provided by the old
i2c probe function, and the remainder can easily be adapted to the new
form ("probe_new") by calling i2c_match_id explicitly.

This avoids scanning the identifier tables during probes.

Drivers which didn't use the id are converted as-is; drivers which did
are modified to call i2c_match_id() with the same level of
error-handling (if any) as before.

This patch wraps up the transition for hwmon, with four stragglers not
included in the previous large patch.

Signed-off-by: Stephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20200821160354.594715-1-steve@sk2.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Stephen Kitt and committed by
Guenter Roeck
673afe46 c1e60c0d

+14 -13
+2 -3
drivers/hwmon/adc128d818.c
··· 427 427 return 0; 428 428 } 429 429 430 - static int adc128_probe(struct i2c_client *client, 431 - const struct i2c_device_id *id) 430 + static int adc128_probe(struct i2c_client *client) 432 431 { 433 432 struct device *dev = &client->dev; 434 433 struct regulator *regulator; ··· 523 524 .name = "adc128d818", 524 525 .of_match_table = of_match_ptr(adc128_of_match), 525 526 }, 526 - .probe = adc128_probe, 527 + .probe_new = adc128_probe, 527 528 .remove = adc128_remove, 528 529 .id_table = adc128_id, 529 530 .detect = adc128_detect,
+5 -4
drivers/hwmon/ads7828.c
··· 99 99 .val_bits = 8, 100 100 }; 101 101 102 - static int ads7828_probe(struct i2c_client *client, 103 - const struct i2c_device_id *id) 102 + static const struct i2c_device_id ads7828_device_ids[]; 103 + 104 + static int ads7828_probe(struct i2c_client *client) 104 105 { 105 106 struct device *dev = &client->dev; 106 107 struct ads7828_platform_data *pdata = dev_get_platdata(dev); ··· 142 141 chip = (enum ads7828_chips) 143 142 of_device_get_match_data(&client->dev); 144 143 else 145 - chip = id->driver_data; 144 + chip = i2c_match_id(ads7828_device_ids, client)->driver_data; 146 145 147 146 /* Bound Vref with min/max values */ 148 147 vref_mv = clamp_val(vref_mv, ADS7828_EXT_VREF_MV_MIN, ··· 208 207 }, 209 208 210 209 .id_table = ads7828_device_ids, 211 - .probe = ads7828_probe, 210 + .probe_new = ads7828_probe, 212 211 }; 213 212 214 213 module_i2c_driver(ads7828_driver);
+2 -2
drivers/hwmon/lm87.c
··· 912 912 return 0; 913 913 } 914 914 915 - static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id) 915 + static int lm87_probe(struct i2c_client *client) 916 916 { 917 917 struct lm87_data *data; 918 918 struct device *hwmon_dev; ··· 994 994 .name = "lm87", 995 995 .of_match_table = lm87_of_match, 996 996 }, 997 - .probe = lm87_probe, 997 + .probe_new = lm87_probe, 998 998 .id_table = lm87_id, 999 999 .detect = lm87_detect, 1000 1000 .address_list = normal_i2c,
+5 -4
drivers/hwmon/w83795.c
··· 2134 2134 } 2135 2135 } 2136 2136 2137 - static int w83795_probe(struct i2c_client *client, 2138 - const struct i2c_device_id *id) 2137 + static const struct i2c_device_id w83795_id[]; 2138 + 2139 + static int w83795_probe(struct i2c_client *client) 2139 2140 { 2140 2141 int i; 2141 2142 u8 tmp; ··· 2149 2148 return -ENOMEM; 2150 2149 2151 2150 i2c_set_clientdata(client, data); 2152 - data->chip_type = id->driver_data; 2151 + data->chip_type = i2c_match_id(w83795_id, client)->driver_data; 2153 2152 data->bank = i2c_smbus_read_byte_data(client, W83795_REG_BANKSEL); 2154 2153 mutex_init(&data->update_lock); 2155 2154 ··· 2257 2256 .driver = { 2258 2257 .name = "w83795", 2259 2258 }, 2260 - .probe = w83795_probe, 2259 + .probe_new = w83795_probe, 2261 2260 .remove = w83795_remove, 2262 2261 .id_table = w83795_id, 2263 2262