Skip to content

Commit

Permalink
i2c: Make remove callback return void
Browse files Browse the repository at this point in the history
The value returned by an i2c driver's remove function is mostly ignored.
(Only an error message is printed if the value is non-zero that the
error is ignored.)

So change the prototype of the remove function to return no value. This
way driver authors are not tempted to assume that passing an error to
the upper layer is a good idea. All drivers are adapted accordingly.
There is no intended change of behaviour, all callbacks were prepared to
return 0 before.

Reviewed-by: Peter Senna Tschudin <[email protected]>
Reviewed-by: Jeremy Kerr <[email protected]>
Reviewed-by: Benjamin Mugnier <[email protected]>
Reviewed-by: Javier Martinez Canillas <[email protected]>
Reviewed-by: Crt Mori <[email protected]>
Reviewed-by: Heikki Krogerus <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Marek Behún <[email protected]> # for leds-turris-omnia
Acked-by: Andy Shevchenko <[email protected]>
Reviewed-by: Petr Machata <[email protected]> # for mlxsw
Reviewed-by: Maximilian Luz <[email protected]> # for surface3_power
Acked-by: Srinivas Pandruvada <[email protected]> # for bmc150-accel-i2c + kxcjk-1013
Reviewed-by: Hans Verkuil <[email protected]> # for media/* + staging/media/*
Acked-by: Miguel Ojeda <[email protected]> # for auxdisplay/ht16k33 + auxdisplay/lcd2s
Reviewed-by: Luca Ceresoli <[email protected]> # for versaclock5
Reviewed-by: Ajay Gupta <[email protected]> # for ucsi_ccg
Acked-by: Jonathan Cameron <[email protected]> # for iio
Acked-by: Peter Rosin <[email protected]> # for i2c-mux-*, max9860
Acked-by: Adrien Grassein <[email protected]> # for lontium-lt8912b
Reviewed-by: Jean Delvare <[email protected]> # for hwmon, i2c-core and i2c/muxes
Acked-by: Corey Minyard <[email protected]> # for IPMI
Reviewed-by: Vladimir Oltean <[email protected]>
Acked-by: Dmitry Torokhov <[email protected]>
Acked-by: Sebastian Reichel <[email protected]> # for drivers/power
Acked-by: Krzysztof Hałasa <[email protected]>
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Wolfram Sang <[email protected]>
  • Loading branch information
Uwe Kleine-König authored and wsakernel committed Aug 16, 2022
1 parent 6a8f359 commit ed5c2f5
Show file tree
Hide file tree
Showing 619 changed files with 646 additions and 1,733 deletions.
2 changes: 1 addition & 1 deletion Documentation/i2c/writing-clients.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ those devices, and a remove() method to unbind.
::

static int foo_probe(struct i2c_client *client);
static int foo_remove(struct i2c_client *client);
static void foo_remove(struct i2c_client *client);

Remember that the i2c_driver does not create those client handles. The
handle may be used during foo_probe(). If foo_probe() reports success
Expand Down
3 changes: 1 addition & 2 deletions arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int mcu_probe(struct i2c_client *client)
return ret;
}

static int mcu_remove(struct i2c_client *client)
static void mcu_remove(struct i2c_client *client)
{
struct mcu *mcu = i2c_get_clientdata(client);

Expand All @@ -193,7 +193,6 @@ static int mcu_remove(struct i2c_client *client)

mcu_gpiochip_remove(mcu);
kfree(mcu);
return 0;
}

static const struct i2c_device_id mcu_ids[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/auxdisplay/ht16k33.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ static int ht16k33_probe(struct i2c_client *client)
return err;
}

static int ht16k33_remove(struct i2c_client *client)
static void ht16k33_remove(struct i2c_client *client)
{
struct ht16k33_priv *priv = i2c_get_clientdata(client);
struct ht16k33_fbdev *fbdev = &priv->fbdev;
Expand All @@ -796,8 +796,6 @@ static int ht16k33_remove(struct i2c_client *client)
device_remove_file(&client->dev, &dev_attr_map_seg14);
break;
}

return 0;
}

static const struct i2c_device_id ht16k33_i2c_match[] = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/auxdisplay/lcd2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,12 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c)
return err;
}

static int lcd2s_i2c_remove(struct i2c_client *i2c)
static void lcd2s_i2c_remove(struct i2c_client *i2c)
{
struct lcd2s_data *lcd2s = i2c_get_clientdata(i2c);

charlcd_unregister(lcd2s->charlcd);
charlcd_free(lcd2s->charlcd);
return 0;
}

static const struct i2c_device_id lcd2s_i2c_id[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/char/ipmi/ipmb_dev_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,12 @@ static int ipmb_probe(struct i2c_client *client)
return 0;
}

static int ipmb_remove(struct i2c_client *client)
static void ipmb_remove(struct i2c_client *client)
{
struct ipmb_dev *ipmb_dev = i2c_get_clientdata(client);

i2c_slave_unregister(client);
misc_deregister(&ipmb_dev->miscdev);

return 0;
}

static const struct i2c_device_id ipmb_id[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/char/ipmi/ipmi_ipmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static void ipmi_ipmb_request_events(void *send_info)
/* We don't fetch events here. */
}

static int ipmi_ipmb_remove(struct i2c_client *client)
static void ipmi_ipmb_remove(struct i2c_client *client)
{
struct ipmi_ipmb_dev *iidev = i2c_get_clientdata(client);

Expand All @@ -438,8 +438,6 @@ static int ipmi_ipmb_remove(struct i2c_client *client)
ipmi_ipmb_stop_thread(iidev);

ipmi_unregister_smi(iidev->intf);

return 0;
}

static int ipmi_ipmb_probe(struct i2c_client *client)
Expand Down
6 changes: 2 additions & 4 deletions drivers/char/ipmi/ipmi_ssif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,13 +1281,13 @@ static void shutdown_ssif(void *send_info)
}
}

static int ssif_remove(struct i2c_client *client)
static void ssif_remove(struct i2c_client *client)
{
struct ssif_info *ssif_info = i2c_get_clientdata(client);
struct ssif_addr_info *addr_info;

if (!ssif_info)
return 0;
return;

/*
* After this point, we won't deliver anything asychronously
Expand All @@ -1303,8 +1303,6 @@ static int ssif_remove(struct i2c_client *client)
}

kfree(ssif_info);

return 0;
}

static int read_response(struct i2c_client *client, unsigned char *resp)
Expand Down
4 changes: 1 addition & 3 deletions drivers/char/tpm/st33zp24/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,11 @@ static int st33zp24_i2c_probe(struct i2c_client *client,
* @param: client, the i2c_client description (TPM I2C description).
* @return: 0 in case of success.
*/
static int st33zp24_i2c_remove(struct i2c_client *client)
static void st33zp24_i2c_remove(struct i2c_client *client)
{
struct tpm_chip *chip = i2c_get_clientdata(client);

st33zp24_remove(chip);

return 0;
}

static const struct i2c_device_id st33zp24_i2c_id[] = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/char/tpm/tpm_i2c_atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,11 @@ static int i2c_atmel_probe(struct i2c_client *client,
return tpm_chip_register(chip);
}

static int i2c_atmel_remove(struct i2c_client *client)
static void i2c_atmel_remove(struct i2c_client *client)
{
struct device *dev = &(client->dev);
struct tpm_chip *chip = dev_get_drvdata(dev);
tpm_chip_unregister(chip);
return 0;
}

static const struct i2c_device_id i2c_atmel_id[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/char/tpm/tpm_i2c_infineon.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,15 +706,13 @@ static int tpm_tis_i2c_probe(struct i2c_client *client,
return rc;
}

static int tpm_tis_i2c_remove(struct i2c_client *client)
static void tpm_tis_i2c_remove(struct i2c_client *client)
{
struct tpm_chip *chip = tpm_dev.chip;

tpm_chip_unregister(chip);
release_locality(chip, tpm_dev.locality, 1);
tpm_dev.client = NULL;

return 0;
}

static struct i2c_driver tpm_tis_i2c_driver = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/char/tpm/tpm_i2c_nuvoton.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,11 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
return tpm_chip_register(chip);
}

static int i2c_nuvoton_remove(struct i2c_client *client)
static void i2c_nuvoton_remove(struct i2c_client *client)
{
struct tpm_chip *chip = i2c_get_clientdata(client);

tpm_chip_unregister(chip);
return 0;
}

static const struct i2c_device_id i2c_nuvoton_id[] = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/char/tpm/tpm_tis_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,12 @@ static int tpm_tis_i2c_probe(struct i2c_client *dev,
NULL);
}

static int tpm_tis_i2c_remove(struct i2c_client *client)
static void tpm_tis_i2c_remove(struct i2c_client *client)
{
struct tpm_chip *chip = i2c_get_clientdata(client);

tpm_chip_unregister(chip);
tpm_tis_remove(chip);
return 0;
}

static const struct i2c_device_id tpm_tis_i2c_id[] = {
Expand Down
6 changes: 2 additions & 4 deletions drivers/char/tpm/tpm_tis_i2c_cr50.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,20 +763,18 @@ static int tpm_cr50_i2c_probe(struct i2c_client *client)
* - 0: Success.
* - -errno: A POSIX error code.
*/
static int tpm_cr50_i2c_remove(struct i2c_client *client)
static void tpm_cr50_i2c_remove(struct i2c_client *client)
{
struct tpm_chip *chip = i2c_get_clientdata(client);
struct device *dev = &client->dev;

if (!chip) {
dev_crit(dev, "Could not get client data at remove, memory corruption ahead\n");
return 0;
return;
}

tpm_chip_unregister(chip);
tpm_cr50_release_locality(chip, true);

return 0;
}

static SIMPLE_DEV_PM_OPS(cr50_i2c_pm, tpm_pm_suspend, tpm_pm_resume);
Expand Down
3 changes: 1 addition & 2 deletions drivers/clk/clk-cdce706.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,9 @@ static int cdce706_probe(struct i2c_client *client)
cdce);
}

static int cdce706_remove(struct i2c_client *client)
static void cdce706_remove(struct i2c_client *client)
{
of_clk_del_provider(client->dev.of_node);
return 0;
}


Expand Down
4 changes: 1 addition & 3 deletions drivers/clk/clk-cs2000-cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ static int cs2000_version_print(struct cs2000_priv *priv)
return 0;
}

static int cs2000_remove(struct i2c_client *client)
static void cs2000_remove(struct i2c_client *client)
{
struct cs2000_priv *priv = i2c_get_clientdata(client);
struct device *dev = priv_to_dev(priv);
Expand All @@ -566,8 +566,6 @@ static int cs2000_remove(struct i2c_client *client)
of_clk_del_provider(np);

clk_hw_unregister(&priv->hw);

return 0;
}

static int cs2000_probe(struct i2c_client *client)
Expand Down
3 changes: 1 addition & 2 deletions drivers/clk/clk-si514.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,9 @@ static int si514_probe(struct i2c_client *client)
return 0;
}

static int si514_remove(struct i2c_client *client)
static void si514_remove(struct i2c_client *client)
{
of_clk_del_provider(client->dev.of_node);
return 0;
}

static const struct i2c_device_id si514_id[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/clk/clk-si5341.c
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,7 @@ static int si5341_probe(struct i2c_client *client)
return err;
}

static int si5341_remove(struct i2c_client *client)
static void si5341_remove(struct i2c_client *client)
{
struct clk_si5341 *data = i2c_get_clientdata(client);
int i;
Expand All @@ -1807,8 +1807,6 @@ static int si5341_remove(struct i2c_client *client)
if (data->clk[i].vddo_reg)
regulator_disable(data->clk[i].vddo_reg);
}

return 0;
}

static const struct i2c_device_id si5341_id[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/clk/clk-si5351.c
Original file line number Diff line number Diff line change
Expand Up @@ -1651,11 +1651,9 @@ static int si5351_i2c_probe(struct i2c_client *client)
return 0;
}

static int si5351_i2c_remove(struct i2c_client *client)
static void si5351_i2c_remove(struct i2c_client *client)
{
of_clk_del_provider(client->dev.of_node);

return 0;
}

static struct i2c_driver si5351_driver = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/clk/clk-si570.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,9 @@ static int si570_probe(struct i2c_client *client)
return 0;
}

static int si570_remove(struct i2c_client *client)
static void si570_remove(struct i2c_client *client)
{
of_clk_del_provider(client->dev.of_node);
return 0;
}

static const struct of_device_id clk_si570_of_match[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/clk/clk-versaclock5.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,16 +1138,14 @@ static int vc5_probe(struct i2c_client *client)
return ret;
}

static int vc5_remove(struct i2c_client *client)
static void vc5_remove(struct i2c_client *client)
{
struct vc5_driver_data *vc5 = i2c_get_clientdata(client);

of_clk_del_provider(client->dev.of_node);

if (vc5->chip_info->flags & VC5_HAS_INTERNAL_XTAL)
clk_unregister_fixed_rate(vc5->pin_xin);

return 0;
}

static int __maybe_unused vc5_suspend(struct device *dev)
Expand Down
6 changes: 2 additions & 4 deletions drivers/crypto/atmel-ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static int atmel_ecc_probe(struct i2c_client *client,
return ret;
}

static int atmel_ecc_remove(struct i2c_client *client)
static void atmel_ecc_remove(struct i2c_client *client)
{
struct atmel_i2c_client_priv *i2c_priv = i2c_get_clientdata(client);

Expand All @@ -358,16 +358,14 @@ static int atmel_ecc_remove(struct i2c_client *client)
* accessing the freed memory.
*/
dev_emerg(&client->dev, "Device is busy, expect memory corruption.\n");
return 0;
return;
}

crypto_unregister_kpp(&atmel_ecdh_nist_p256);

spin_lock(&driver_data.i2c_list_lock);
list_del(&i2c_priv->i2c_client_list_node);
spin_unlock(&driver_data.i2c_list_lock);

return 0;
}

#ifdef CONFIG_OF
Expand Down
6 changes: 2 additions & 4 deletions drivers/crypto/atmel-sha204a.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,16 @@ static int atmel_sha204a_probe(struct i2c_client *client,
return ret;
}

static int atmel_sha204a_remove(struct i2c_client *client)
static void atmel_sha204a_remove(struct i2c_client *client)
{
struct atmel_i2c_client_priv *i2c_priv = i2c_get_clientdata(client);

if (atomic_read(&i2c_priv->tfm_count)) {
dev_emerg(&client->dev, "Device is busy, will remove it anyhow\n");
return 0;
return;
}

kfree((void *)i2c_priv->hwrng.priv);

return 0;
}

static const struct of_device_id atmel_sha204a_dt_ids[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/extcon/extcon-rt8973a.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,13 +646,11 @@ static int rt8973a_muic_i2c_probe(struct i2c_client *i2c,
return 0;
}

static int rt8973a_muic_i2c_remove(struct i2c_client *i2c)
static void rt8973a_muic_i2c_remove(struct i2c_client *i2c)
{
struct rt8973a_muic_info *info = i2c_get_clientdata(i2c);

regmap_del_irq_chip(info->irq, info->irq_data);

return 0;
}

static const struct of_device_id rt8973a_dt_match[] = {
Expand Down
4 changes: 1 addition & 3 deletions drivers/gpio/gpio-adp5588.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,12 @@ static int adp5588_gpio_probe(struct i2c_client *client)
return 0;
}

static int adp5588_gpio_remove(struct i2c_client *client)
static void adp5588_gpio_remove(struct i2c_client *client)
{
struct adp5588_gpio *dev = i2c_get_clientdata(client);

if (dev->client->irq)
free_irq(dev->client->irq, dev);

return 0;
}

static const struct i2c_device_id adp5588_gpio_id[] = {
Expand Down
Loading

0 comments on commit ed5c2f5

Please sign in to comment.