v6.3: use simple i2c probe
commit a00f6d3723f5617222ab8df228228c3c2c84e3ec Author: Stephen Kitt <steve@sk2.org> Date: Wed Oct 12 18:36:47 2022 +0200 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 <steve@sk2.org> Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
parent
18e297d2d8
commit
0bb3ca6c98
2 changed files with 12 additions and 13 deletions
22
ac108.c
22
ac108.c
|
@ -1410,7 +1410,15 @@ static const struct regmap_config ac108_regmap = {
|
|||
.max_register = 0xDF,
|
||||
.cache_type = REGCACHE_FLAT,
|
||||
};
|
||||
static int ac108_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i2c_id) {
|
||||
static const struct i2c_device_id ac108_i2c_id[] = {
|
||||
{ "ac108_0", 0 },
|
||||
{ "ac108_1", 1 },
|
||||
{ "ac108_2", 2 },
|
||||
{ "ac108_3", 3 },
|
||||
{ "ac101", AC101_I2C_ID },
|
||||
{ }
|
||||
};
|
||||
static int ac108_i2c_probe(struct i2c_client *i2c) {
|
||||
struct device_node *np = i2c->dev.of_node;
|
||||
unsigned int val = 0;
|
||||
int ret = 0, index;
|
||||
|
@ -1423,11 +1431,11 @@ static int ac108_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i
|
|||
}
|
||||
}
|
||||
|
||||
index = (int)i2c_id->driver_data;
|
||||
index = (int)i2c_match_id(ac108_i2c_id, i2c)->driver_data;
|
||||
if (index == AC101_I2C_ID) {
|
||||
ac10x->i2c101 = i2c;
|
||||
i2c_set_clientdata(i2c, ac10x);
|
||||
ret = ac101_probe(i2c, i2c_id);
|
||||
ret = ac101_probe(i2c, i2c_match_id(ac108_i2c_id, i2c));
|
||||
if (ret) {
|
||||
ac10x->i2c101 = NULL;
|
||||
return ret;
|
||||
|
@ -1520,14 +1528,6 @@ __ret:
|
|||
}
|
||||
}
|
||||
|
||||
static const struct i2c_device_id ac108_i2c_id[] = {
|
||||
{ "ac108_0", 0 },
|
||||
{ "ac108_1", 1 },
|
||||
{ "ac108_2", 2 },
|
||||
{ "ac108_3", 3 },
|
||||
{ "ac101", AC101_I2C_ID },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ac108_i2c_id);
|
||||
|
||||
static const struct of_device_id ac108_of_match[] = {
|
||||
|
|
3
wm8960.c
3
wm8960.c
|
@ -1318,8 +1318,7 @@ static void wm8960_set_pdata_from_of(struct i2c_client *i2c,
|
|||
pdata->shared_lrclk = true;
|
||||
}
|
||||
|
||||
static int wm8960_i2c_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
static int wm8960_i2c_probe(struct i2c_client *i2c)
|
||||
{
|
||||
struct wm8960_data *pdata = dev_get_platdata(&i2c->dev);
|
||||
struct wm8960_priv *wm8960;
|
||||
|
|
Loading…
Reference in a new issue