Commit 67487038 authored by Stephen Kitt's avatar Stephen Kitt Committed by Guenter Roeck
Browse files

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: default avatarStephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20200813160222.1503401-1-steve@sk2.org


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent dd431939
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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,
Loading