hwmon: use simple i2c probe function

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>
This commit is contained in:
Stephen Kitt
2020-09-23 09:42:39 -07:00
committed by Guenter Roeck
parent dd43193976
commit 6748703856
87 changed files with 250 additions and 285 deletions
+2 -3
View File
@@ -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;
@@ -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,
};
+5 -4
View File
@@ -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;
@@ -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:
@@ -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,
};
+5 -4
View File
@@ -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;
@@ -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 */
@@ -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,
+2 -3
View File
@@ -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;
@@ -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,
+2 -3
View File
@@ -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;
@@ -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,
+5 -4
View File
@@ -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;
@@ -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)
@@ -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,
+2 -3
View File
@@ -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;
@@ -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,
+2 -3
View File
@@ -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))
@@ -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),
+2 -3
View File
@@ -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;
@@ -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,
+2 -3
View File
@@ -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;
@@ -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,
+2 -3
View File
@@ -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;
@@ -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,
+3 -3
View File
@@ -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[] = {
@@ -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)
@@ -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,
+2 -3
View File
@@ -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;
@@ -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,
+3 -5
View File
@@ -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);
@@ -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,
@@ -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;
+2 -3
View File
@@ -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;
@@ -288,7 +287,7 @@ static struct i2c_driver atxp1_driver = {
.driver = {
.name = "atxp1",
},
.probe = atxp1_probe,
.probe_new = atxp1_probe,
.id_table = atxp1_id,
};
+5 -4
View File
@@ -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;
@@ -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 */
@@ -383,7 +384,7 @@ static struct i2c_driver ds1621_driver = {
.driver = {
.name = "ds1621",
},
.probe = ds1621_probe,
.probe_new = ds1621_probe,
.id_table = ds1621_id,
};
+2 -3
View File
@@ -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;
@@ -246,7 +245,7 @@ static struct i2c_driver ds620_driver = {
.driver = {
.name = "ds620",
},
.probe = ds620_probe,
.probe_new = ds620_probe,
.id_table = ds620_id,
};
+5 -3
View File
@@ -386,11 +386,13 @@ static const struct regmap_config emc1403_regmap_config = {
.volatile_reg = emc1403_regmap_is_volatile,
};
static int emc1403_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static const struct i2c_device_id emc1403_idtable[];
static int emc1403_probe(struct i2c_client *client)
{
struct thermal_data *data;
struct device *hwmon_dev;
const struct i2c_device_id *id = i2c_match_id(emc1403_idtable, client);
data = devm_kzalloc(&client->dev, sizeof(struct thermal_data),
GFP_KERNEL);
@@ -452,7 +454,7 @@ static struct i2c_driver sensor_emc1403 = {
.name = "emc1403",
},
.detect = emc1403_detect,
.probe = emc1403_probe,
.probe_new = emc1403_probe,
.id_table = emc1403_idtable,
.address_list = emc1403_address_list,
};
+2 -3
View File
@@ -444,8 +444,7 @@ static int emc6w201_detect(struct i2c_client *client,
return 0;
}
static int emc6w201_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int emc6w201_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct emc6w201_data *data;
@@ -475,7 +474,7 @@ static struct i2c_driver emc6w201_driver = {
.driver = {
.name = "emc6w201",
},
.probe = emc6w201_probe,
.probe_new = emc6w201_probe,
.id_table = emc6w201_id,
.detect = emc6w201_detect,
.address_list = normal_i2c,
+4 -6
View File
@@ -214,8 +214,7 @@ static const int FSCHMD_NO_TEMP_SENSORS[7] = { 3, 3, 4, 3, 5, 5, 11 };
* Functions declarations
*/
static int fschmd_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int fschmd_probe(struct i2c_client *client);
static int fschmd_detect(struct i2c_client *client,
struct i2c_board_info *info);
static int fschmd_remove(struct i2c_client *client);
@@ -242,7 +241,7 @@ static struct i2c_driver fschmd_driver = {
.driver = {
.name = "fschmd",
},
.probe = fschmd_probe,
.probe_new = fschmd_probe,
.remove = fschmd_remove,
.id_table = fschmd_id,
.detect = fschmd_detect,
@@ -1081,15 +1080,14 @@ static int fschmd_detect(struct i2c_client *client,
return 0;
}
static int fschmd_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int fschmd_probe(struct i2c_client *client)
{
struct fschmd_data *data;
const char * const names[7] = { "Poseidon", "Hermes", "Scylla",
"Heracles", "Heimdall", "Hades", "Syleus" };
const int watchdog_minors[] = { WATCHDOG_MINOR, 212, 213, 214, 215 };
int i, err;
enum chips kind = id->driver_data;
enum chips kind = i2c_match_id(fschmd_id, client)->driver_data;
data = kzalloc(sizeof(struct fschmd_data), GFP_KERNEL);
if (!data)

Some files were not shown because too many files have changed in this diff Show More