Skip to content

Commit

Permalink
i2c: Remove all i2c_set_clientdata(client, NULL) in drivers
Browse files Browse the repository at this point in the history
I2C drivers can use the clientdata-pointer to point to private data. As I2C
devices are not really unregistered, but merely detached from their driver, it
used to be the drivers obligation to clear this pointer during remove() or a
failed probe(). As a couple of drivers forgot to do this, it was agreed that it
was cleaner if the i2c-core does this clearance when appropriate, as there is
no guarantee for the lifetime of the clientdata-pointer after remove() anyhow.
This feature was added to the core with commit
e4a7b9b to fix the faulty drivers.

As there is no need anymore to clear the clientdata-pointer, remove all current
occurrences in the drivers to simplify the code and prevent confusion.

Signed-off-by: Wolfram Sang <[email protected]>
Acked-by: Mark Brown <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Richard Purdie <[email protected]>
Acked-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
  • Loading branch information
Wolfram Sang authored and Jean Delvare committed Jun 3, 2010
1 parent 35bfc35 commit fbae3fb
Show file tree
Hide file tree
Showing 75 changed files with 4 additions and 141 deletions.
2 changes: 0 additions & 2 deletions drivers/hwmon/adt7411.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ static int __devinit adt7411_probe(struct i2c_client *client,
exit_remove:
sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
exit_free:
i2c_set_clientdata(client, NULL);
kfree(data);
return ret;
}
Expand All @@ -327,7 +326,6 @@ static int __devexit adt7411_remove(struct i2c_client *client)

hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
i2c_set_clientdata(client, NULL);
kfree(data);
return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/hwmon/asc7621.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,6 @@ asc7621_probe(struct i2c_client *client, const struct i2c_device_id *id)
&(asc7621_params[i].sda.dev_attr));
}

i2c_set_clientdata(client, NULL);
kfree(data);
return err;
}
Expand Down Expand Up @@ -1196,7 +1195,6 @@ static int asc7621_remove(struct i2c_client *client)
&(asc7621_params[i].sda.dev_attr));
}

i2c_set_clientdata(client, NULL);
kfree(data);
return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/hwmon/f75375s.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ static int f75375_probe(struct i2c_client *client,
sysfs_remove_group(&client->dev.kobj, &f75375_group);
exit_free:
kfree(data);
i2c_set_clientdata(client, NULL);
return err;
}

Expand All @@ -672,7 +671,6 @@ static int f75375_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &f75375_group);
kfree(data);
i2c_set_clientdata(client, NULL);
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions drivers/hwmon/g760a.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ static int g760a_probe(struct i2c_client *client,
sysfs_remove_group(&client->dev.kobj, &g760a_group);
error_sysfs_create_group:
kfree(data);
i2c_set_clientdata(client, NULL);

return err;
}
Expand All @@ -247,7 +246,6 @@ static int g760a_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &g760a_group);
kfree(data);
i2c_set_clientdata(client, NULL);

return 0;
}
Expand Down
1 change: 0 additions & 1 deletion drivers/hwmon/lm73.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ static int lm73_remove(struct i2c_client *client)

hwmon_device_unregister(hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &lm73_group);
i2c_set_clientdata(client, NULL);
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions drivers/hwmon/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
exit_remove:
sysfs_remove_group(&client->dev.kobj, &lm75_group);
exit_free:
i2c_set_clientdata(client, NULL);
kfree(data);
return status;
}
Expand All @@ -204,7 +203,6 @@ static int lm75_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &lm75_group);
lm75_write_value(client, LM75_REG_CONF, data->orig_conf);
i2c_set_clientdata(client, NULL);
kfree(data);
return 0;
}
Expand Down
1 change: 0 additions & 1 deletion drivers/hwmon/lm95241.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ static int lm95241_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &lm95241_group);

i2c_set_clientdata(client, NULL);
kfree(data);
return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/hwmon/tmp102.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ static int __devinit tmp102_probe(struct i2c_client *client,
fail_restore_config:
tmp102_write_reg(client, TMP102_CONF_REG, tmp102->config_orig);
fail_free:
i2c_set_clientdata(client, NULL);
kfree(tmp102);

return status;
Expand All @@ -247,7 +246,6 @@ static int __devexit tmp102_remove(struct i2c_client *client)
config | TMP102_CONF_SD);
}

i2c_set_clientdata(client, NULL);
kfree(tmp102);

return 0;
Expand Down
2 changes: 0 additions & 2 deletions drivers/hwmon/tmp421.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ static int tmp421_probe(struct i2c_client *client,
sysfs_remove_group(&client->dev.kobj, &tmp421_group);

exit_free:
i2c_set_clientdata(client, NULL);
kfree(data);

return err;
Expand All @@ -308,7 +307,6 @@ static int tmp421_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &tmp421_group);

i2c_set_clientdata(client, NULL);
kfree(data);

return 0;
Expand Down
2 changes: 0 additions & 2 deletions drivers/hwmon/w83781d.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,6 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id)
if (data->lm75[1])
i2c_unregister_device(data->lm75[1]);
ERROR3:
i2c_set_clientdata(client, NULL);
kfree(data);
ERROR1:
return err;
Expand All @@ -1219,7 +1218,6 @@ w83781d_remove(struct i2c_client *client)
if (data->lm75[1])
i2c_unregister_device(data->lm75[1]);

i2c_set_clientdata(client, NULL);
kfree(data);

return 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/i2c/i2c-smbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ static int smbalert_remove(struct i2c_client *ara)

cancel_work_sync(&alert->alert);

i2c_set_clientdata(ara, NULL);
kfree(alert);
return 0;
}
Expand Down
1 change: 0 additions & 1 deletion drivers/input/keyboard/adp5588-keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ static int __devexit adp5588_remove(struct i2c_client *client)
free_irq(client->irq, kpad);
cancel_delayed_work_sync(&kpad->work);
input_unregister_device(kpad->input);
i2c_set_clientdata(client, NULL);
kfree(kpad);

return 0;
Expand Down
2 changes: 0 additions & 2 deletions drivers/input/keyboard/lm8323.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,6 @@ static int __devexit lm8323_remove(struct i2c_client *client)
struct lm8323_chip *lm = i2c_get_clientdata(client);
int i;

i2c_set_clientdata(client, NULL);

disable_irq_wake(client->irq);
free_irq(client->irq, lm);
cancel_work_sync(&lm->work);
Expand Down
1 change: 0 additions & 1 deletion drivers/input/keyboard/max7359_keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ static int __devexit max7359_remove(struct i2c_client *client)

free_irq(client->irq, keypad);
input_unregister_device(keypad->input_dev);
i2c_set_clientdata(client, NULL);
kfree(keypad);

return 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/input/keyboard/qt2160.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ static int __devexit qt2160_remove(struct i2c_client *client)
input_unregister_device(qt2160->input);
kfree(qt2160);

i2c_set_clientdata(client, NULL);
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions drivers/input/keyboard/tca6416-keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ static int __devexit tca6416_keypad_remove(struct i2c_client *client)
input_unregister_device(chip->input);
kfree(chip);

i2c_set_clientdata(client, NULL);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion drivers/input/misc/ad714x-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ static int __devexit ad714x_i2c_remove(struct i2c_client *client)
struct ad714x_chip *chip = i2c_get_clientdata(client);

ad714x_remove(chip);
i2c_set_clientdata(client, NULL);

return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/input/misc/pcf8574_keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ static int __devexit pcf8574_kp_remove(struct i2c_client *client)
input_unregister_device(lp->idev);
kfree(lp);

i2c_set_clientdata(client, NULL);

return 0;
}

Expand Down
1 change: 0 additions & 1 deletion drivers/input/mouse/synaptics_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ static int __devexit synaptics_i2c_remove(struct i2c_client *client)
free_irq(client->irq, touch);

input_unregister_device(touch->input);
i2c_set_clientdata(client, NULL);
kfree(touch);

return 0;
Expand Down
5 changes: 1 addition & 4 deletions drivers/input/touchscreen/ad7879.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,8 @@ static int __devinit ad7879_probe(struct i2c_client *client,
ts->bus = client;

error = ad7879_construct(client, ts);
if (error) {
i2c_set_clientdata(client, NULL);
if (error)
kfree(ts);
}

return error;
}
Expand All @@ -825,7 +823,6 @@ static int __devexit ad7879_remove(struct i2c_client *client)
struct ad7879 *ts = dev_get_drvdata(&client->dev);

ad7879_destroy(client, ts);
i2c_set_clientdata(client, NULL);
kfree(ts);

return 0;
Expand Down
2 changes: 0 additions & 2 deletions drivers/input/touchscreen/eeti_ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
input = NULL; /* so we dont try to free it below */
err1:
input_free_device(input);
i2c_set_clientdata(client, NULL);
kfree(priv);
err0:
return err;
Expand All @@ -256,7 +255,6 @@ static int __devexit eeti_ts_remove(struct i2c_client *client)
enable_irq(priv->irq);

input_unregister_device(priv->input);
i2c_set_clientdata(client, NULL);
kfree(priv);

return 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/input/touchscreen/mcs5000_ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ static int __devexit mcs5000_ts_remove(struct i2c_client *client)
free_irq(client->irq, data);
input_unregister_device(data->input_dev);
kfree(data);
i2c_set_clientdata(client, NULL);

return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/input/touchscreen/tsc2007.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ static int __devexit tsc2007_remove(struct i2c_client *client)
struct tsc2007 *ts = i2c_get_clientdata(client);
struct tsc2007_platform_data *pdata = client->dev.platform_data;

i2c_set_clientdata(client, NULL);

tsc2007_free_irq(ts);

if (pdata->exit_platform_hw)
Expand Down
2 changes: 0 additions & 2 deletions drivers/leds/leds-bd2802.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,6 @@ static int __devinit bd2802_probe(struct i2c_client *client,
for (i--; i >= 0; i--)
device_remove_file(&led->client->dev, bd2802_attributes[i]);
failed_free:
i2c_set_clientdata(client, NULL);
kfree(led);

return ret;
Expand All @@ -759,7 +758,6 @@ static int __exit bd2802_remove(struct i2c_client *client)
bd2802_disable_adv_conf(led);
for (i = 0; i < ARRAY_SIZE(bd2802_attributes); i++)
device_remove_file(&led->client->dev, bd2802_attributes[i]);
i2c_set_clientdata(client, NULL);
kfree(led);

return 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/leds/leds-lp3944.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ static int __devexit lp3944_remove(struct i2c_client *client)
}

kfree(data);
i2c_set_clientdata(client, NULL);

return 0;
}
Expand Down
5 changes: 1 addition & 4 deletions drivers/leds/leds-pca9532.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,8 @@ static int pca9532_probe(struct i2c_client *client,
mutex_init(&data->update_lock);

err = pca9532_configure(client, data, pca9532_pdata);
if (err) {
if (err)
kfree(data);
i2c_set_clientdata(client, NULL);
}

return err;
}
Expand Down Expand Up @@ -351,7 +349,6 @@ static int pca9532_remove(struct i2c_client *client)
}

kfree(data);
i2c_set_clientdata(client, NULL);
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions drivers/leds/leds-pca955x.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ static int __devinit pca955x_probe(struct i2c_client *client,
}

kfree(pca955x);
i2c_set_clientdata(client, NULL);

return err;
}
Expand All @@ -358,7 +357,6 @@ static int __devexit pca955x_remove(struct i2c_client *client)
}

kfree(pca955x);
i2c_set_clientdata(client, NULL);

return 0;
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/macintosh/therm_adt746x.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ remove_thermostat(struct i2c_client *client)

thermostat = NULL;

i2c_set_clientdata(client, NULL);
kfree(th);

return 0;
Expand Down Expand Up @@ -400,7 +399,6 @@ static int probe_thermostat(struct i2c_client *client,
rc = read_reg(th, CONFIG_REG);
if (rc < 0) {
dev_err(&client->dev, "Thermostat failed to read config!\n");
i2c_set_clientdata(client, NULL);
kfree(th);
return -ENODEV;
}
Expand Down
5 changes: 1 addition & 4 deletions drivers/macintosh/windfarm_lm75_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ static int wf_lm75_probe(struct i2c_client *client,
i2c_set_clientdata(client, lm);

rc = wf_register_sensor(&lm->sens);
if (rc) {
i2c_set_clientdata(client, NULL);
if (rc)
kfree(lm);
}

return rc;
}
Expand Down Expand Up @@ -216,7 +214,6 @@ static int wf_lm75_remove(struct i2c_client *client)
/* release sensor */
wf_unregister_sensor(&lm->sens);

i2c_set_clientdata(client, NULL);
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion drivers/macintosh/windfarm_max6690_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ static int wf_max6690_probe(struct i2c_client *client,

rc = wf_register_sensor(&max->sens);
if (rc) {
i2c_set_clientdata(client, NULL);
kfree(max);
}

Expand Down
1 change: 0 additions & 1 deletion drivers/macintosh/windfarm_smu_sat.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ static int wf_sat_remove(struct i2c_client *client)
/* XXX TODO */

sat->i2c = NULL;
i2c_set_clientdata(client, NULL);
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion drivers/media/radio/si470x/radio-si470x-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ static __devexit int si470x_i2c_remove(struct i2c_client *client)
cancel_work_sync(&radio->radio_work);
video_unregister_device(radio->videodev);
kfree(radio);
i2c_set_clientdata(client, NULL);

return 0;
}
Expand Down
Loading

0 comments on commit fbae3fb

Please sign in to comment.