drivers/extcon: use simple i2c probe
PATCH 1/1 drivers/extcon: 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
)
, };
--- drivers/extcon/extcon-fsa9480.c | 5 ++--- drivers/extcon/extcon-rt8973a.c | 5 ++--- drivers/extcon/extcon-usbc-tusb320.c | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-)
drivers/extcon/extcon-fsa9480.c +2 -3
@@ -257,8 +257,7 @@ static irqreturn_t fsa9480_irq_handler(int irq, void *data)return IRQ_HANDLED ; } -static int fsa9480_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int fsa9480_probe (struct i2c_client *client) {struct fsa9480_usbsw *info;int ret;
@@ -370,7 +369,7 @@ static struct i2c_driver fsa9480_i2c_driver = { .pm = &fsa9480_pm_ops, .of_match_table = fsa9480_of_match, }, - .probe = fsa9480_probe, + .probe_new = fsa9480_probe, .id_table = fsa9480_id, };
drivers/extcon/extcon-rt8973a.c +2 -3
@@ -548,8 +548,7 @@ static void rt8973a_init_dev_type(struct rt8973a_muic_info *info) } } -static int rt8973a_muic_i2c_probe (struct i2c_client *i2c, -const struct i2c_device_id *id) +static int rt8973a_muic_i2c_probe (struct i2c_client *i2c) {struct device_node *np = i2c->dev.of_node;struct rt8973a_muic_info *info;
@@ -696,7 +695,7 @@ static struct i2c_driver rt8973a_muic_i2c_driver = { .pm = &rt8973a_muic_pm_ops, .of_match_table = rt8973a_dt_match, }, - .probe = rt8973a_muic_i2c_probe, + .probe_new = rt8973a_muic_i2c_probe, .remove = rt8973a_muic_i2c_remove, .id_table = rt8973a_i2c_id, };
drivers/extcon/extcon-usbc-tusb320.c +2 -3
@@ -230,8 +230,7 @@ static const struct regmap_config tusb320_regmap_config = { .val_bits = 8, }; -static int tusb320_extcon_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int tusb320_extcon_probe (struct i2c_client *client) {struct tusb320_priv *priv;const void *match_data;
@@ -313,7 +312,7 @@ static const struct of_device_id tusb320_extcon_dt_match[] = {MODULE_DEVICE_TABLE (of, tusb320_extcon_dt_match);static struct i2c_driver tusb320_extcon_driver = { - .probe = tusb320_extcon_probe, + .probe_new = tusb320_extcon_probe, .driver = { .name ="extcon-tusb320" , .of_match_table = tusb320_extcon_dt_match,
base-commit: 833477fce7a14d43ae4c07f8ddc32fa5119471a2
Signature · 1 line
2.30.2
Hi,
Looks good to me. Could you change the patch title as following:
- extcon: Use simple i2c probe
Quoted 135 lines · Stephen Kitt
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:
indrivers/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_newinstead, avoiding the call toi2c_match_id. Drivers which do can still be converted to probe_new-style, callingi2c_match_idthemselves (as is done currently forof_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 intfn(struct i2c_client *client)
{
...when != id
}@ rule2 depends on rule1 @
identifier rule1.fn;
identifier driver;
@@struct
i2c_driverdriver = {(quoted diff) +1
-1- .probe + .probe_new =(
fn
|(quoted diff) +1
-1- &fn + fn)
, };Signed-off-by Stephen Kitt <[email protected]>--- drivers/extcon/extcon-fsa9480.c | 5 ++--- drivers/extcon/extcon-rt8973a.c | 5 ++--- drivers/extcon/extcon-usbc-tusb320.c | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-)drivers/extcon/extcon-fsa9480.c +2
-3@@ -257,8 +257,7 @@ static irqreturn_t fsa9480_irq_handler(int irq, void *data)return IRQ_HANDLED ; } -static int fsa9480_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int fsa9480_probe (struct i2c_client *client) {struct fsa9480_usbsw *info;int ret;@@ -370,7 +369,7 @@ static struct i2c_driver fsa9480_i2c_driver = { .pm = &fsa9480_pm_ops, .of_match_table = fsa9480_of_match, }, - .probe = fsa9480_probe, + .probe_new = fsa9480_probe, .id_table = fsa9480_id, };drivers/extcon/extcon-rt8973a.c +2
-3@@ -548,8 +548,7 @@ static void rt8973a_init_dev_type(struct rt8973a_muic_info *info) } } -static int rt8973a_muic_i2c_probe (struct i2c_client *i2c, -const struct i2c_device_id *id) +static int rt8973a_muic_i2c_probe (struct i2c_client *i2c) {struct device_node *np = i2c->dev.of_node;struct rt8973a_muic_info *info;@@ -696,7 +695,7 @@ static struct i2c_driver rt8973a_muic_i2c_driver = { .pm = &rt8973a_muic_pm_ops, .of_match_table = rt8973a_dt_match, }, - .probe = rt8973a_muic_i2c_probe, + .probe_new = rt8973a_muic_i2c_probe, .remove = rt8973a_muic_i2c_remove, .id_table = rt8973a_i2c_id, };drivers/extcon/extcon-usbc-tusb320.c +2
-3@@ -230,8 +230,7 @@ static const struct regmap_config tusb320_regmap_config = { .val_bits = 8, }; -static int tusb320_extcon_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int tusb320_extcon_probe (struct i2c_client *client) {struct tusb320_priv *priv;const void *match_data;@@ -313,7 +312,7 @@ static const struct of_device_id tusb320_extcon_dt_match[] = {MODULE_DEVICE_TABLE (of, tusb320_extcon_dt_match);static struct i2c_driver tusb320_extcon_driver = { - .probe = tusb320_extcon_probe, + .probe_new = tusb320_extcon_probe, .driver = { .name ="extcon-tusb320" , .of_match_table = tusb320_extcon_dt_match,base-commit:
833477fce7a14d43ae4c07f8ddc32fa5119471a2
Signature · 3 lines
Best Regards, Samsung Electronics Chanwoo Choi
Quoted 63 lines
--------- Original Message ---------
Sender : Stephen Kitt <[email protected]>
Date : 2022-10-12 23:18 (GMT+9)
Title : [PATCH]drivers/extcon: 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
)
,
};
Quoted 1 line
Signed-off-by Stephen Kitt <[email protected]>
Chanwoo, PTAL.
Cheers,
MyungJoo