Skip to content

Commit

Permalink
hwmon: use simple i2c probe function
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 as follows:

* if the information in i2c_client is sufficient, that's used instead
  (client->name);
* anything else is handled by calling i2c_match_id() with the same
  level of error-handling (if any) as before.

A few drivers aren't included in this patch because they have a
different set of maintainers. They will be covered by other patches.

Signed-off-by: Stephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20200813160222.1503401-1-steve@sk2.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
skitt authored and groeck committed Sep 23, 2020
1 parent dd43193 commit 6748703
Show file tree
Hide file tree
Showing 87 changed files with 250 additions and 285 deletions.
5 changes: 2 additions & 3 deletions drivers/hwmon/ad7414.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ static struct attribute *ad7414_attrs[] = {

ATTRIBUTE_GROUPS(ad7414);

static int ad7414_probe(struct i2c_client *client,
const struct i2c_device_id *dev_id)
static int ad7414_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct ad7414_data *data;
Expand Down Expand Up @@ -222,7 +221,7 @@ static struct i2c_driver ad7414_driver = {
.name = "ad7414",
.of_match_table = of_match_ptr(ad7414_of_match),
},
.probe = ad7414_probe,
.probe_new = ad7414_probe,
.id_table = ad7414_id,
};

Expand Down
9 changes: 5 additions & 4 deletions drivers/hwmon/ad7418.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ static void ad7418_init_client(struct i2c_client *client)
}
}

static int ad7418_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static const struct i2c_device_id ad7418_id[];

static int ad7418_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct i2c_adapter *adapter = client->adapter;
Expand All @@ -254,7 +255,7 @@ static int ad7418_probe(struct i2c_client *client,
if (dev->of_node)
data->type = (enum chips)of_device_get_match_data(dev);
else
data->type = id->driver_data;
data->type = i2c_match_id(ad7418_id, client)->driver_data;

switch (data->type) {
case ad7416:
Expand Down Expand Up @@ -305,7 +306,7 @@ static struct i2c_driver ad7418_driver = {
.name = "ad7418",
.of_match_table = ad7418_dt_ids,
},
.probe = ad7418_probe,
.probe_new = ad7418_probe,
.id_table = ad7418_id,
};

Expand Down
9 changes: 5 additions & 4 deletions drivers/hwmon/adm1021.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,9 @@ static void adm1021_init_client(struct i2c_client *client)
i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04);
}

static int adm1021_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static const struct i2c_device_id adm1021_id[];

static int adm1021_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct adm1021_data *data;
Expand All @@ -437,7 +438,7 @@ static int adm1021_probe(struct i2c_client *client,
return -ENOMEM;

data->client = client;
data->type = id->driver_data;
data->type = i2c_match_id(adm1021_id, client)->driver_data;
mutex_init(&data->update_lock);

/* Initialize the ADM1021 chip */
Expand Down Expand Up @@ -472,7 +473,7 @@ static struct i2c_driver adm1021_driver = {
.driver = {
.name = "adm1021",
},
.probe = adm1021_probe,
.probe_new = adm1021_probe,
.id_table = adm1021_id,
.detect = adm1021_detect,
.address_list = normal_i2c,
Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/adm1025.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,7 @@ static void adm1025_init_client(struct i2c_client *client)
(reg&0x7E)|0x01);
}

static int adm1025_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int adm1025_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct device *hwmon_dev;
Expand Down Expand Up @@ -560,7 +559,7 @@ static struct i2c_driver adm1025_driver = {
.driver = {
.name = "adm1025",
},
.probe = adm1025_probe,
.probe_new = adm1025_probe,
.id_table = adm1025_id,
.detect = adm1025_detect,
.address_list = normal_i2c,
Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/adm1026.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,8 +1816,7 @@ static void adm1026_init_client(struct i2c_client *client)
}
}

static int adm1026_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int adm1026_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct device *hwmon_dev;
Expand Down Expand Up @@ -1860,7 +1859,7 @@ static struct i2c_driver adm1026_driver = {
.driver = {
.name = "adm1026",
},
.probe = adm1026_probe,
.probe_new = adm1026_probe,
.id_table = adm1026_id,
.detect = adm1026_detect,
.address_list = normal_i2c,
Expand Down
9 changes: 5 additions & 4 deletions drivers/hwmon/adm1031.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,9 @@ static void adm1031_init_client(struct i2c_client *client)
data->update_interval = update_intervals[i];
}

static int adm1031_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static const struct i2c_device_id adm1031_id[];

static int adm1031_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct device *hwmon_dev;
Expand All @@ -1035,7 +1036,7 @@ static int adm1031_probe(struct i2c_client *client,

i2c_set_clientdata(client, data);
data->client = client;
data->chip_type = id->driver_data;
data->chip_type = i2c_match_id(adm1031_id, client)->driver_data;
mutex_init(&data->update_lock);

if (data->chip_type == adm1030)
Expand Down Expand Up @@ -1068,7 +1069,7 @@ static struct i2c_driver adm1031_driver = {
.driver = {
.name = "adm1031",
},
.probe = adm1031_probe,
.probe_new = adm1031_probe,
.id_table = adm1031_id,
.detect = adm1031_detect,
.address_list = normal_i2c,
Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/adm9240.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,7 @@ static void adm9240_init_client(struct i2c_client *client)
}
}

static int adm9240_probe(struct i2c_client *new_client,
const struct i2c_device_id *id)
static int adm9240_probe(struct i2c_client *new_client)
{
struct device *dev = &new_client->dev;
struct device *hwmon_dev;
Expand Down Expand Up @@ -741,7 +740,7 @@ static struct i2c_driver adm9240_driver = {
.driver = {
.name = "adm9240",
},
.probe = adm9240_probe,
.probe_new = adm9240_probe,
.id_table = adm9240_id,
.detect = adm9240_detect,
.address_list = normal_i2c,
Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/adt7410.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ static const struct adt7x10_ops adt7410_i2c_ops = {
.write_byte = adt7410_i2c_write_byte,
};

static int adt7410_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int adt7410_i2c_probe(struct i2c_client *client)
{
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
Expand All @@ -67,7 +66,7 @@ static struct i2c_driver adt7410_driver = {
.name = "adt7410",
.pm = ADT7X10_DEV_PM_OPS,
},
.probe = adt7410_i2c_probe,
.probe_new = adt7410_i2c_probe,
.remove = adt7410_i2c_remove,
.id_table = adt7410_ids,
.address_list = I2C_ADDRS(0x48, 0x49, 0x4a, 0x4b),
Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/adt7411.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,7 @@ static const struct hwmon_chip_info adt7411_chip_info = {
.info = adt7411_info,
};

static int adt7411_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int adt7411_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct adt7411_data *data;
Expand Down Expand Up @@ -707,7 +706,7 @@ static struct i2c_driver adt7411_driver = {
.driver = {
.name = "adt7411",
},
.probe = adt7411_probe,
.probe_new = adt7411_probe,
.id_table = adt7411_id,
.detect = adt7411_detect,
.address_list = normal_i2c,
Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/adt7462.c
Original file line number Diff line number Diff line change
Expand Up @@ -1787,8 +1787,7 @@ static int adt7462_detect(struct i2c_client *client,
return 0;
}

static int adt7462_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int adt7462_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct adt7462_data *data;
Expand Down Expand Up @@ -1820,7 +1819,7 @@ static struct i2c_driver adt7462_driver = {
.driver = {
.name = "adt7462",
},
.probe = adt7462_probe,
.probe_new = adt7462_probe,
.id_table = adt7462_id,
.detect = adt7462_detect,
.address_list = normal_i2c,
Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/adt7470.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,7 @@ static void adt7470_init_client(struct i2c_client *client)
}
}

static int adt7470_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int adt7470_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct adt7470_data *data;
Expand Down Expand Up @@ -1276,7 +1275,7 @@ static struct i2c_driver adt7470_driver = {
.driver = {
.name = "adt7470",
},
.probe = adt7470_probe,
.probe_new = adt7470_probe,
.remove = adt7470_remove,
.id_table = adt7470_id,
.detect = adt7470_detect,
Expand Down
6 changes: 3 additions & 3 deletions drivers/hwmon/adt7475.c
Original file line number Diff line number Diff line change
Expand Up @@ -1539,8 +1539,7 @@ static int adt7475_set_pwm_polarity(struct i2c_client *client)
return 0;
}

static int adt7475_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int adt7475_probe(struct i2c_client *client)
{
enum chips chip;
static const char * const names[] = {
Expand All @@ -1554,6 +1553,7 @@ static int adt7475_probe(struct i2c_client *client,
struct device *hwmon_dev;
int i, ret = 0, revision, group_num = 0;
u8 config3;
const struct i2c_device_id *id = i2c_match_id(adt7475_id, client);

data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
if (data == NULL)
Expand Down Expand Up @@ -1728,7 +1728,7 @@ static struct i2c_driver adt7475_driver = {
.name = "adt7475",
.of_match_table = of_match_ptr(adt7475_of_match),
},
.probe = adt7475_probe,
.probe_new = adt7475_probe,
.id_table = adt7475_id,
.detect = adt7475_detect,
.address_list = normal_i2c,
Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/amc6821.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,7 @@ static int amc6821_init_client(struct i2c_client *client)
return 0;
}

static int amc6821_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int amc6821_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct amc6821_data *data;
Expand Down Expand Up @@ -940,7 +939,7 @@ static struct i2c_driver amc6821_driver = {
.driver = {
.name = "amc6821",
},
.probe = amc6821_probe,
.probe_new = amc6821_probe,
.id_table = amc6821_id,
.detect = amc6821_detect,
.address_list = normal_i2c,
Expand Down
8 changes: 3 additions & 5 deletions drivers/hwmon/asb100.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ struct asb100_data {
static int asb100_read_value(struct i2c_client *client, u16 reg);
static void asb100_write_value(struct i2c_client *client, u16 reg, u16 val);

static int asb100_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int asb100_probe(struct i2c_client *client);
static int asb100_detect(struct i2c_client *client,
struct i2c_board_info *info);
static int asb100_remove(struct i2c_client *client);
Expand All @@ -224,7 +223,7 @@ static struct i2c_driver asb100_driver = {
.driver = {
.name = "asb100",
},
.probe = asb100_probe,
.probe_new = asb100_probe,
.remove = asb100_remove,
.id_table = asb100_id,
.detect = asb100_detect,
Expand Down Expand Up @@ -775,8 +774,7 @@ static int asb100_detect(struct i2c_client *client,
return 0;
}

static int asb100_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int asb100_probe(struct i2c_client *client)
{
int err;
struct asb100_data *data;
Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/atxp1.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ static struct attribute *atxp1_attrs[] = {
};
ATTRIBUTE_GROUPS(atxp1);

static int atxp1_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int atxp1_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct atxp1_data *data;
Expand Down Expand Up @@ -288,7 +287,7 @@ static struct i2c_driver atxp1_driver = {
.driver = {
.name = "atxp1",
},
.probe = atxp1_probe,
.probe_new = atxp1_probe,
.id_table = atxp1_id,
};

Expand Down
9 changes: 5 additions & 4 deletions drivers/hwmon/ds1621.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ static const struct attribute_group ds1621_group = {
};
__ATTRIBUTE_GROUPS(ds1621);

static int ds1621_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static const struct i2c_device_id ds1621_id[];

static int ds1621_probe(struct i2c_client *client)
{
struct ds1621_data *data;
struct device *hwmon_dev;
Expand All @@ -355,7 +356,7 @@ static int ds1621_probe(struct i2c_client *client,

mutex_init(&data->update_lock);

data->kind = id->driver_data;
data->kind = i2c_match_id(ds1621_id, client)->driver_data;
data->client = client;

/* Initialize the DS1621 chip */
Expand Down Expand Up @@ -383,7 +384,7 @@ static struct i2c_driver ds1621_driver = {
.driver = {
.name = "ds1621",
},
.probe = ds1621_probe,
.probe_new = ds1621_probe,
.id_table = ds1621_id,
};

Expand Down
5 changes: 2 additions & 3 deletions drivers/hwmon/ds620.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ static struct attribute *ds620_attrs[] = {

ATTRIBUTE_GROUPS(ds620);

static int ds620_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int ds620_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct device *hwmon_dev;
Expand Down Expand Up @@ -246,7 +245,7 @@ static struct i2c_driver ds620_driver = {
.driver = {
.name = "ds620",
},
.probe = ds620_probe,
.probe_new = ds620_probe,
.id_table = ds620_id,
};

Expand Down
Loading

0 comments on commit 6748703

Please sign in to comment.