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

hwmon: use simple i2c probe



All these drivers have an i2c probe function which doesn't use the
"struct i2c_device_id *id" parameter, so they can trivially be
converted to the "probe_new" style of probe with a single argument.

This is part of an ongoing transition to single-argument i2c probe
functions. Old-style probe functions involve a call to i2c_match_id:
in drivers/i2c/i2c-core-base.c,

         /*
          * When there are no more users of probe(),
          * rename probe_new to probe.
          */
         if (driver->probe_new)
                 status = driver->probe_new(client);
         else if (driver->probe)
                 status = driver->probe(client,
                                        i2c_match_id(driver->id_table, client));
         else
                 status = -EINVAL;

Drivers which don't need the second parameter can be declared using
probe_new instead, avoiding the call to i2c_match_id. Drivers which do
can still be converted to probe_new-style, calling i2c_match_id
themselves (as is done currently for of_match_id).

This change was done using the following Coccinelle script, and fixed
up for whitespace changes:

@ rule1 @
identifier fn;
identifier client, id;
@@

- static int fn(struct i2c_client *client, const struct i2c_device_id *id)
+ static int fn(struct i2c_client *client)
{
...when != id
}

@ rule2 depends on rule1 @
identifier rule1.fn;
identifier driver;
@@

struct i2c_driver driver = {
-       .probe
+       .probe_new
                =
(
                   fn
|
-                  &fn
+                  fn
)
                ,
};

Signed-off-by: default avatarStephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20221011143309.3141267-1-steve@sk2.org


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent b3b19931
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -289,8 +289,7 @@ static const struct hwmon_chip_info aht10_chip_info = {
	.info = aht10_info,
};

static int aht10_probe(struct i2c_client *client,
		       const struct i2c_device_id *aht10_id)
static int aht10_probe(struct i2c_client *client)
{
	struct device *device = &client->dev;
	struct device *hwmon_dev;
@@ -336,7 +335,7 @@ static struct i2c_driver aht10_driver = {
	.driver = {
		.name = "aht10",
	},
	.probe      = aht10_probe,
	.probe_new  = aht10_probe,
	.id_table   = aht10_id,
};

+2 −2
Original line number Diff line number Diff line
@@ -518,7 +518,7 @@ static int emc2305_identify(struct device *dev)
	return 0;
}

static int emc2305_probe(struct i2c_client *client, const struct i2c_device_id *id)
static int emc2305_probe(struct i2c_client *client)
{
	struct i2c_adapter *adapter = client->adapter;
	struct device *dev = &client->dev;
@@ -607,7 +607,7 @@ static struct i2c_driver emc2305_driver = {
	.driver = {
		.name = "emc2305",
	},
	.probe    = emc2305_probe,
	.probe_new = emc2305_probe,
	.remove	  = emc2305_remove,
	.id_table = emc2305_ids,
	.address_list = emc2305_normal_i2c,
+2 −2
Original line number Diff line number Diff line
@@ -881,7 +881,7 @@ static int ltc2992_parse_dt(struct ltc2992_state *st)
	return 0;
}

static int ltc2992_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
static int ltc2992_i2c_probe(struct i2c_client *client)
{
	struct device *hwmon_dev;
	struct ltc2992_state *st;
@@ -927,7 +927,7 @@ static struct i2c_driver ltc2992_i2c_driver = {
		.name = "ltc2992",
		.of_match_table = ltc2992_of_match,
	},
	.probe    = ltc2992_i2c_probe,
	.probe_new = ltc2992_i2c_probe,
	.id_table = ltc2992_i2c_id,
};

+2 −3
Original line number Diff line number Diff line
@@ -303,8 +303,7 @@ static const struct hwmon_chip_info max127_chip_info = {
	.info = max127_info,
};

static int max127_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
static int max127_probe(struct i2c_client *client)
{
	int i;
	struct device *hwmon_dev;
@@ -340,7 +339,7 @@ static struct i2c_driver max127_driver = {
	.driver = {
		.name	= "max127",
	},
	.probe		= max127_probe,
	.probe_new	= max127_probe,
	.id_table	= max127_id,
};

+2 −3
Original line number Diff line number Diff line
@@ -297,8 +297,7 @@ static int sbrmi_get_max_pwr_limit(struct sbrmi_data *data)
	return ret;
}

static int sbrmi_probe(struct i2c_client *client,
		       const struct i2c_device_id *id)
static int sbrmi_probe(struct i2c_client *client)
{
	struct device *dev = &client->dev;
	struct device *hwmon_dev;
@@ -348,7 +347,7 @@ static struct i2c_driver sbrmi_driver = {
		.name = "sbrmi",
		.of_match_table = of_match_ptr(sbrmi_of_match),
	},
	.probe = sbrmi_probe,
	.probe_new = sbrmi_probe,
	.id_table = sbrmi_id,
};

Loading