Skip to content

Commit a00f6d3

Browse files
skittwsakernel
authored andcommitted
drivers/i2c: 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: Stephen Kitt <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 99c4ec2 commit a00f6d3

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,15 +1017,14 @@ static const struct i2c_device_id dummy_id[] = {
10171017
{ },
10181018
};
10191019

1020-
static int dummy_probe(struct i2c_client *client,
1021-
const struct i2c_device_id *id)
1020+
static int dummy_probe(struct i2c_client *client)
10221021
{
10231022
return 0;
10241023
}
10251024

10261025
static struct i2c_driver dummy_driver = {
10271026
.driver.name = "dummy",
1028-
.probe = dummy_probe,
1027+
.probe_new = dummy_probe,
10291028
.id_table = dummy_id,
10301029
};
10311030

drivers/i2c/i2c-smbus.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ static void smbalert_work(struct work_struct *work)
112112
}
113113

114114
/* Setup SMBALERT# infrastructure */
115-
static int smbalert_probe(struct i2c_client *ara,
116-
const struct i2c_device_id *id)
115+
static int smbalert_probe(struct i2c_client *ara)
117116
{
118117
struct i2c_smbus_alert_setup *setup = dev_get_platdata(&ara->dev);
119118
struct i2c_smbus_alert *alert;
@@ -170,7 +169,7 @@ static struct i2c_driver smbalert_driver = {
170169
.driver = {
171170
.name = "smbus_alert",
172171
},
173-
.probe = smbalert_probe,
172+
.probe_new = smbalert_probe,
174173
.remove = smbalert_remove,
175174
.id_table = smbalert_ids,
176175
};

0 commit comments

Comments
 (0)