Skip to content

Commit

Permalink
Merge tag 'i2c-for-6.3-rc2' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/wsa/linux

Pull i2c updates from Wolfram Sang:
 "This marks the end of a transition to let I2C have the same probe
  semantics as other subsystems. Uwe took care that no drivers in the
  current tree nor in -next use the deprecated .probe call. So, it is a
  good time to switch to the new, standard semantics now.

  There is also a regression fix:

   - regression fix for the notifier handling of the I2C core

   - final coversions of drivers away from deprecated .probe

   - make .probe_new the standard probe and convert I2C core to use it

* tag 'i2c-for-6.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: dev: Fix bus callback return values
  i2c: Convert drivers to new .probe() callback
  i2c: mux: Convert all drivers to new .probe() callback
  i2c: Switch .probe() to not take an id parameter
  media: i2c: ov2685: convert to i2c's .probe_new()
  media: i2c: ov5695: convert to i2c's .probe_new()
  w1: ds2482: Convert to i2c's .probe_new()
  serial: sc16is7xx: Convert to i2c's .probe_new()
  mtd: maps: pismo: Convert to i2c's .probe_new()
  misc: ad525x_dpot-i2c: Convert to i2c's .probe_new()
  • Loading branch information
Linus Torvalds committed Mar 11, 2023
2 parents e25c54d + 9e5f81f commit 81ff855
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 47 deletions.
13 changes: 3 additions & 10 deletions drivers/i2c/i2c-core-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1057,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,
};

Expand Down
24 changes: 18 additions & 6 deletions drivers/i2c/i2c-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ static void i2cdev_dev_release(struct device *dev)
kfree(i2c_dev);
}

static int i2cdev_attach_adapter(struct device *dev, void *dummy)
static int i2cdev_attach_adapter(struct device *dev)
{
struct i2c_adapter *adap;
struct i2c_dev *i2c_dev;
Expand Down Expand Up @@ -685,7 +685,7 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy)
return NOTIFY_DONE;
}

static int i2cdev_detach_adapter(struct device *dev, void *dummy)
static int i2cdev_detach_adapter(struct device *dev)
{
struct i2c_adapter *adap;
struct i2c_dev *i2c_dev;
Expand All @@ -711,9 +711,9 @@ static int i2cdev_notifier_call(struct notifier_block *nb, unsigned long action,

switch (action) {
case BUS_NOTIFY_ADD_DEVICE:
return i2cdev_attach_adapter(dev, NULL);
return i2cdev_attach_adapter(dev);
case BUS_NOTIFY_DEL_DEVICE:
return i2cdev_detach_adapter(dev, NULL);
return i2cdev_detach_adapter(dev);
}

return NOTIFY_DONE;
Expand All @@ -725,6 +725,18 @@ static struct notifier_block i2cdev_notifier = {

/* ------------------------------------------------------------------------- */

static int __init i2c_dev_attach_adapter(struct device *dev, void *dummy)
{
i2cdev_attach_adapter(dev);
return 0;
}

static int __exit i2c_dev_detach_adapter(struct device *dev, void *dummy)
{
i2cdev_detach_adapter(dev);
return 0;
}

/*
* module load/unload record keeping
*/
Expand Down Expand Up @@ -752,7 +764,7 @@ static int __init i2c_dev_init(void)
goto out_unreg_class;

/* Bind to already existing adapters right away */
i2c_for_each_dev(NULL, i2cdev_attach_adapter);
i2c_for_each_dev(NULL, i2c_dev_attach_adapter);

return 0;

Expand All @@ -768,7 +780,7 @@ static int __init i2c_dev_init(void)
static void __exit i2c_dev_exit(void)
{
bus_unregister_notifier(&i2c_bus_type, &i2cdev_notifier);
i2c_for_each_dev(NULL, i2cdev_detach_adapter);
i2c_for_each_dev(NULL, i2c_dev_detach_adapter);
class_destroy(i2c_dev_class);
unregister_chrdev_region(MKDEV(I2C_MAJOR, 0), I2C_MINORS);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/i2c-slave-eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/i2c-slave-testunit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/i2c-smbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/muxes/i2c-mux-ltc4306.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/muxes/i2c-mux-pca9541.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/muxes/i2c-mux-pca954x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
5 changes: 2 additions & 3 deletions drivers/media/i2c/ov2685.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};

Expand Down
5 changes: 2 additions & 3 deletions drivers/media/i2c/ov5695.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};

Expand Down
6 changes: 3 additions & 3 deletions drivers/misc/ad525x_dpot-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
};
Expand Down
5 changes: 2 additions & 3 deletions drivers/mtd/maps/pismo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
Expand Down
6 changes: 3 additions & 3 deletions drivers/tty/serial/sc16is7xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
};
Expand Down
5 changes: 2 additions & 3 deletions drivers/w1/masters/ds2482.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
Expand Down
18 changes: 11 additions & 7 deletions include/linux/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 81ff855

Please sign in to comment.