Skip to content

Commit

Permalink
hwmon: use simple i2c probe function (take 2)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Kitt authored and Guenter Roeck committed Sep 23, 2020
1 parent c1e60c0 commit 673afe4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
5 changes: 2 additions & 3 deletions drivers/hwmon/adc128d818.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,7 @@ static int adc128_init_client(struct adc128_data *data)
return 0;
}

static int adc128_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int adc128_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct regulator *regulator;
Expand Down Expand Up @@ -524,7 +523,7 @@ static struct i2c_driver adc128_driver = {
.name = "adc128d818",
.of_match_table = of_match_ptr(adc128_of_match),
},
.probe = adc128_probe,
.probe_new = adc128_probe,
.remove = adc128_remove,
.id_table = adc128_id,
.detect = adc128_detect,
Expand Down
9 changes: 5 additions & 4 deletions drivers/hwmon/ads7828.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ static const struct regmap_config ads2830_regmap_config = {
.val_bits = 8,
};

static int ads7828_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static const struct i2c_device_id ads7828_device_ids[];

static int ads7828_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct ads7828_platform_data *pdata = dev_get_platdata(dev);
Expand Down Expand Up @@ -141,7 +142,7 @@ static int ads7828_probe(struct i2c_client *client,
chip = (enum ads7828_chips)
of_device_get_match_data(&client->dev);
else
chip = id->driver_data;
chip = i2c_match_id(ads7828_device_ids, client)->driver_data;

/* Bound Vref with min/max values */
vref_mv = clamp_val(vref_mv, ADS7828_EXT_VREF_MV_MIN,
Expand Down Expand Up @@ -207,7 +208,7 @@ static struct i2c_driver ads7828_driver = {
},

.id_table = ads7828_device_ids,
.probe = ads7828_probe,
.probe_new = ads7828_probe,
};

module_i2c_driver(ads7828_driver);
Expand Down
4 changes: 2 additions & 2 deletions drivers/hwmon/lm87.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ static int lm87_init_client(struct i2c_client *client)
return 0;
}

static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id)
static int lm87_probe(struct i2c_client *client)
{
struct lm87_data *data;
struct device *hwmon_dev;
Expand Down Expand Up @@ -994,7 +994,7 @@ static struct i2c_driver lm87_driver = {
.name = "lm87",
.of_match_table = lm87_of_match,
},
.probe = lm87_probe,
.probe_new = lm87_probe,
.id_table = lm87_id,
.detect = lm87_detect,
.address_list = normal_i2c,
Expand Down
9 changes: 5 additions & 4 deletions drivers/hwmon/w83795.c
Original file line number Diff line number Diff line change
Expand Up @@ -2134,8 +2134,9 @@ static void w83795_apply_temp_config(struct w83795_data *data, u8 config,
}
}

static int w83795_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static const struct i2c_device_id w83795_id[];

static int w83795_probe(struct i2c_client *client)
{
int i;
u8 tmp;
Expand All @@ -2148,7 +2149,7 @@ static int w83795_probe(struct i2c_client *client,
return -ENOMEM;

i2c_set_clientdata(client, data);
data->chip_type = id->driver_data;
data->chip_type = i2c_match_id(w83795_id, client)->driver_data;
data->bank = i2c_smbus_read_byte_data(client, W83795_REG_BANKSEL);
mutex_init(&data->update_lock);

Expand Down Expand Up @@ -2256,7 +2257,7 @@ static struct i2c_driver w83795_driver = {
.driver = {
.name = "w83795",
},
.probe = w83795_probe,
.probe_new = w83795_probe,
.remove = w83795_remove,
.id_table = w83795_id,

Expand Down

0 comments on commit 673afe4

Please sign in to comment.