i2c: Switch .probe() to not take an id parameter
Subsystems (12)
v2 cover i2c: Switch .probe() to not take an id parameter
Hello,
this is v2 of the series. I send it a bit earlier than I planned to do that initially because I failed to send v1 completely to the linux-i2c list.
Changes since (implicit) v1:
- Added Acks for patches #5, #6 and #8
- Fixed kernel doc as pointed out by Luca Ceresoli (patch #7)
- Send all patches to linux-i2c mailing list
- Rebased to current Linus' tree.
This reduces the list of prerequisite patches to two.
I updated
https://git.pengutronix.de/git/ukl/linux i2c-probe-new
accordingly.
Best regards
Uwe
Uwe Kleine-König (9):
misc: ad525x_dpot-i2c: Convert to i2c's .probe_new()
mtd: maps: pismo: Convert to i2c's .probe_new()
serial: sc16is7xx: Convert to i2c's .probe_new()
w1: ds2482: Convert to i2c's .probe_new()
media: i2c: ov5695: convert to i2c's .probe_new()
media: i2c: ov2685: convert to i2c's .probe_new()
i2c: Switch .probe() to not take an id parameter
i2c: mux: Convert all drivers to new .probe() callback
i2c: Convert drivers to new .probe() callback
drivers/i2c/i2c-core-base.c | 13 +++---------- drivers/i2c/i2c-slave-eeprom.c | 2 +- drivers/i2c/i2c-slave-testunit.c | 2 +- drivers/i2c/i2c-smbus.c | 2 +- drivers/i2c/muxes/i2c-mux-ltc4306.c | 2 +- drivers/i2c/muxes/i2c-mux-pca9541.c | 2 +- drivers/i2c/muxes/i2c-mux-pca954x.c | 2 +- drivers/media/i2c/ov2685.c | 5 ++--- drivers/media/i2c/ov5695.c | 5 ++--- drivers/misc/ad525x_dpot-i2c.c | 6 +++--- drivers/mtd/maps/pismo.c | 5 ++--- drivers/tty/serial/sc16is7xx.c | 6 +++--- drivers/w1/masters/ds2482.c | 5 ++--- include/linux/i2c.h | 18 +++++++++++------- 14 files changed, 34 insertions(+), 41 deletions(-)
base-commit: f3a2439f20d918930cc4ae8f76fe1c1afd26958f
prerequisite-patch-id: 256857b4eee79540b271b8d4899b9ba0aa3c4c27
prerequisite-patch-id: bb49c9c71311ac1f1056c562f20f26aa356c95a6
Signature · 6 lines
2.39.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v2 1/9 misc: ad525x_dpot-i2c: Convert to i2c's .probe_new()
.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function.
--- drivers/misc/ad525x_dpot-i2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/misc/ad525x_dpot-i2c.c +3 -3
@@ -50,9 +50,9 @@ static const struct ad_dpot_bus_ops bops = { .write_r8d16 = write_r8d16, }; -static int ad_dpot_i2c_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int ad_dpot_i2c_probe (struct i2c_client *client) { +const struct i2c_device_id *id =i2c_client_get_device_id (client);struct ad_dpot_bus_data bdata = { .client = client, .bops = &bops,
@@ -106,7 +106,7 @@ static struct i2c_driver ad_dpot_i2c_driver = { .driver = { .name = "ad_dpot", }, - .probe = ad_dpot_i2c_probe, + .probe_new = ad_dpot_i2c_probe, .remove = ad_dpot_i2c_remove, .id_table = ad_dpot_id, };
Signature · 1 line
2.39.1
PATCH v2 2/9 mtd: maps: pismo: Convert to i2c's .probe_new()
In reply to Uwe Kleine-KönigThe probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted.
--- drivers/mtd/maps/pismo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mtd/maps/pismo.c +2 -3
@@ -206,8 +206,7 @@ static void pismo_remove(struct i2c_client *client)kfree (pismo); } -static int pismo_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int pismo_probe (struct i2c_client *client) {struct pismo_pdata *pdata = client->dev.platform_data;struct pismo_eeprom eeprom;
@@ -260,7 +259,7 @@ static struct i2c_driver pismo_driver = { .driver = { .name = "pismo", }, - .probe = pismo_probe, + .probe_new = pismo_probe, .remove = pismo_remove, .id_table = pismo_id, };
Signature · 1 line
2.39.1
PATCH v2 3/9 serial: sc16is7xx: Convert to i2c's .probe_new()
In reply to Uwe Kleine-König.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function.
--- drivers/tty/serial/sc16is7xx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/sc16is7xx.c +3 -3
@@ -1666,9 +1666,9 @@ MODULE_ALIAS("spi:sc16is7xx");#endif #ifdef CONFIG_SERIAL_SC16IS7XX_I2C -static int sc16is7xx_i2c_probe (struct i2c_client *i2c, -const struct i2c_device_id *id) +static int sc16is7xx_i2c_probe (struct i2c_client *i2c) { +const struct i2c_device_id *id =i2c_client_get_device_id (i2c);const struct sc16is7xx_devtype *devtype;struct regmap *regmap;
@@ -1709,7 +1709,7 @@ static struct i2c_driver sc16is7xx_i2c_uart_driver = { .name = SC16IS7XX_NAME, .of_match_table = sc16is7xx_dt_ids, }, - .probe = sc16is7xx_i2c_probe, + .probe_new = sc16is7xx_i2c_probe, .remove = sc16is7xx_i2c_remove, .id_table = sc16is7xx_i2c_id_table, };
Signature · 1 line
2.39.1
PATCH v2 4/9 w1: ds2482: Convert to i2c's .probe_new()
In reply to Uwe Kleine-KönigThe probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted.
--- drivers/w1/masters/ds2482.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/w1/masters/ds2482.c +2 -3
@@ -442,8 +442,7 @@ static u8 ds2482_w1_set_pullup(void *data, int delay) } -static int ds2482_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int ds2482_probe (struct i2c_client *client) {struct ds2482_data *data;int err = -ENODEV ;
@@ -553,7 +552,7 @@ static struct i2c_driver ds2482_driver = { .driver = { .name = "ds2482", }, - .probe = ds2482_probe, + .probe_new = ds2482_probe, .remove = ds2482_remove, .id_table = ds2482_id, };
Signature · 1 line
2.39.1
PATCH v2 5/9 media: i2c: ov5695: convert to i2c's .probe_new()
In reply to Uwe Kleine-KönigThe probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted.
--- drivers/media/i2c/ov5695.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/i2c/ov5695.c +2 -3
@@ -1267,8 +1267,7 @@ static int ov5695_configure_regulators(struct ov5695 *ov5695) ov5695->supplies); } -static int ov5695_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int ov5695_probe (struct i2c_client *client) {struct device *dev = &client->dev;struct ov5695 *ov5695;
@@ -1393,7 +1392,7 @@ static struct i2c_driver ov5695_i2c_driver = { .pm = &ov5695_pm_ops, .of_match_table = of_match_ptr(ov5695_of_match), }, - .probe = &ov5695_probe, + .probe_new = &ov5695_probe, .remove = &ov5695_remove, };
Signature · 1 line
2.39.1
PATCH v2 6/9 media: i2c: ov2685: convert to i2c's .probe_new()
In reply to Uwe Kleine-KönigThe probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted.
--- drivers/media/i2c/ov2685.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/i2c/ov2685.c +2 -3
@@ -707,8 +707,7 @@ static int ov2685_configure_regulators(struct ov2685 *ov2685) ov2685->supplies); } -static int ov2685_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int ov2685_probe (struct i2c_client *client) {struct device *dev = &client->dev;struct ov2685 *ov2685;
@@ -830,7 +829,7 @@ static struct i2c_driver ov2685_i2c_driver = { .pm = &ov2685_pm_ops, .of_match_table = of_match_ptr(ov2685_of_match), }, - .probe = &ov2685_probe, + .probe_new = &ov2685_probe, .remove = &ov2685_remove, };
Signature · 1 line
2.39.1
PATCH v2 7/9 i2c: Switch .probe() to not take an id parameter
In reply to Uwe Kleine-KönigCommit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new() call-back type") introduced a new probe callback to convert i2c init routines to not take an i2c_device_id parameter. Now that all in-tree drivers are converted to the temporary .probe_new() callback, .probe() can be modified to match the desired prototype.
Now that .probe() and .probe_new() have the same semantic, they can be defined as members of an anonymous union to save some memory and simplify the core code a bit.
--- drivers/i2c/i2c-core-base.c | 11 ++--------- include/linux/i2c.h | 18 +++++++++++------- 2 files changed, 13 insertions(+), 16 deletions(-)
drivers/i2c/i2c-core-base.c +2 -9
@@ -561,15 +561,8 @@ static int i2c_device_probe(struct device *dev) goto err_detach_pm_domain; } -/* -* 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)); +if (driver->probe) + status = driver->probe (client);else status = -EINVAL ;
include/linux/i2c.h +11 -7
@@ -236,8 +236,8 @@ enum i2c_driver_flags {/** * struct i2c_driver - represent an I2C device driver * @class: What kind of i2c device we instantiate (for detect) -* @probe: Callback for device binding - soon to be deprecated -* @probe_new: New callback for device binding +* @probe: Callback for device binding +* @probe_new: Transitional callback for device binding - do not use * @remove: Callback for device unbinding * @shutdown: Callback for device shutdown * @alert: Alert callback, for example for the SMBus alert protocol
@@ -272,14 +272,18 @@ enum i2c_driver_flags {struct i2c_driver {unsigned int class; +union {/* Standard driver model interfaces */ -int (*probe)(struct i2c_client *client,const struct i2c_device_id *id); +int (*probe)(struct i2c_client *client); +/* +* Legacy callback that was part of a conversion of .probe(). +* Today it has the same semantic as .probe(). Don't use for new +* code. +*/ +int (*probe_new)(struct i2c_client *client); + };void (*remove)(struct i2c_client *client); -/* New driver model interface to aid the seamless removal of the -* current probe()'s, more commonly unused than used second parameter. -*/ -int (*probe_new)(struct i2c_client *client);/* driver model interfaces that don't relate to enumeration */ void (*shutdown)(struct i2c_client *client);
Signature · 1 line
2.39.1
PATCH v2 8/9 i2c: mux: Convert all drivers to new .probe() callback
In reply to Uwe Kleine-KönigNow that .probe() was changed not to get the id parameter, drivers can be converted back to that with the eventual goal to drop .probe_new().
Implement that for the i2c mux drivers.
--- drivers/i2c/muxes/i2c-mux-ltc4306.c | 2 +- drivers/i2c/muxes/i2c-mux-pca9541.c | 2 +- drivers/i2c/muxes/i2c-mux-pca954x.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/muxes/i2c-mux-ltc4306.c +1 -1
@@ -306,7 +306,7 @@ static struct i2c_driver ltc4306_driver = { .name = "ltc4306", .of_match_table = of_match_ptr(ltc4306_of_match), }, - .probe_new = ltc4306_probe, + .probe = ltc4306_probe, .remove = ltc4306_remove, .id_table = ltc4306_id, };
drivers/i2c/muxes/i2c-mux-pca9541.c +1 -1
@@ -336,7 +336,7 @@ static struct i2c_driver pca9541_driver = { .name = "pca9541", .of_match_table = of_match_ptr(pca9541_of_match), }, - .probe_new = pca9541_probe, + .probe = pca9541_probe, .remove = pca9541_remove, .id_table = pca9541_id, };
drivers/i2c/muxes/i2c-mux-pca954x.c +1 -1
@@ -554,7 +554,7 @@ static struct i2c_driver pca954x_driver = { .pm = &pca954x_pm, .of_match_table = pca954x_of_match, }, - .probe_new = pca954x_probe, + .probe = pca954x_probe, .remove = pca954x_remove, .id_table = pca954x_id, };
Signature · 1 line
2.39.1
PATCH v2 9/9 i2c: Convert drivers to new .probe() callback
In reply to Uwe Kleine-KönigNow that .probe() was changed not to get the id parameter, drivers can be converted back to that with the eventual goal to drop .probe_new().
Implement that for the i2c drivers that are part of the i2c core.
--- drivers/i2c/i2c-core-base.c | 2 +- drivers/i2c/i2c-slave-eeprom.c | 2 +- drivers/i2c/i2c-slave-testunit.c | 2 +- drivers/i2c/i2c-smbus.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/i2c-core-base.c +1 -1
@@ -1050,7 +1050,7 @@ static int dummy_probe(struct i2c_client *client)static struct i2c_driver dummy_driver = { .driver.name ="dummy" , - .probe_new = dummy_probe, + .probe = dummy_probe, .id_table = dummy_id, };
drivers/i2c/i2c-slave-eeprom.c +1 -1
@@ -207,7 +207,7 @@ static struct i2c_driver i2c_slave_eeprom_driver = { .driver = { .name = "i2c-slave-eeprom", }, - .probe_new = i2c_slave_eeprom_probe, + .probe = i2c_slave_eeprom_probe, .remove = i2c_slave_eeprom_remove, .id_table = i2c_slave_eeprom_id, };
drivers/i2c/i2c-slave-testunit.c +1 -1
@@ -171,7 +171,7 @@ static struct i2c_driver i2c_slave_testunit_driver = { .driver = { .name = "i2c-slave-testunit", }, - .probe_new = i2c_slave_testunit_probe, + .probe = i2c_slave_testunit_probe, .remove = i2c_slave_testunit_remove, .id_table = i2c_slave_testunit_id, };
drivers/i2c/i2c-smbus.c +1 -1
@@ -169,7 +169,7 @@ static struct i2c_driver smbalert_driver = { .driver = { .name = "smbus_alert", }, - .probe_new = smbalert_probe, + .probe = smbalert_probe, .remove = smbalert_remove, .id_table = smbalert_ids, };
Signature · 1 line
2.39.1
Hello,
Quoted 10 lines · Uwe Kleine-König
this is v2 of the series. I send it a bit earlier than I planned to do that initially because I failed to send v1 completely to the linux-i2c list.
Changes since (implicit) v1:
- Added Acks for patches #5, #6 and #8
- Fixed kernel doc as pointed out by Luca Ceresoli (patch #7)
- Send all patches to linux-i2c mailing list
- Rebased to current Linus' tree.
This reduces the list of prerequisite patches to two.
Quoted 5 lines
I updated
https://git.pengutronix.de/git/ukl/linux i2c-probe-new
accordingly.
Linus tree now contains all patches that are a prerequisite for this series. I rebased the above branch again on top of linus/master and now it contains only the change sets included in this series.
Also no unexpected new usages of .probe() appeared in Linus's tree (nor in next). Also there are no changes to any of the files touched by this series in next.
So this series is ready to be applied once Linus cuts -rc1.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Wolfram Sang
AppliedQuoted 2 lines
So this series is ready to be applied once Linus cuts -rc1.
I applied it to for-current now and plan to have it in -rc2. Thank you!
Quoted 4 lines · Wolfram Sang
Quoted 2 lines
So this series is ready to be applied once Linus cuts -rc1.
I applied it to for-current now and plan to have it in -rc2. Thank you!
Great, this is even quicker than I anticipated. I thought this will go into next first and into mainline only during the next merge window.
If you can convince Linus to take that for -rc2, fine for me.
Best regards and thanks,
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/