提交 7bef5594 编写于 作者: J Jean Delvare 提交者: Greg Kroah-Hartman

[PATCH] I2C: refactor message in i2c_detach_client

We could refactor the error message 34 different i2c drivers print if
i2c_detach_client() fails in this function itself. Saves quite a few
lines of code. Documentation is updated to reflect that change.

Note that this patch should be applied after Rudolf Marek's w83792d
patches.
Signed-off-by: NJean Delvare <khali@linux-fr.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 1ff4e306
......@@ -94,7 +94,8 @@ Technical changes:
limited to the strictly necessary steps.
* [Detach] Get rid of data, remove the call to
i2c_deregister_entry.
i2c_deregister_entry. Do not log an error message if
i2c_detach_client fails, as i2c-core will now do it for you.
* [Update] Don't access client->data directly, use
i2c_get_clientdata(client) instead.
......
......@@ -489,10 +489,8 @@ much simpler than the attachment code, fortunately!
/* SENSORS ONLY END */
/* Try to detach the client from i2c space */
if ((err = i2c_detach_client(client))) {
printk("foo.o: Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
/* HYBRID SENSORS CHIP ONLY START */
if i2c_is_isa_client(client)
......
......@@ -328,10 +328,8 @@ static int adm1021_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -517,11 +517,8 @@ static int adm1025_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -645,11 +645,8 @@ static int adm9240_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -867,11 +867,8 @@ static int asb100_detach_client(struct i2c_client *client)
if (data)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "client deregistration failed; "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
/* main client */
if (data)
......
......@@ -282,11 +282,8 @@ static int ds1621_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
......
......@@ -383,11 +383,8 @@ static int fscher_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -549,11 +549,8 @@ static int fscpos_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, client"
" not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
}
......
......@@ -492,11 +492,8 @@ static int gl518_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -654,11 +654,8 @@ static int gl520_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -945,11 +945,8 @@ static int it87_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
if(i2c_is_isa_client(client))
release_region(client->addr, IT87_EXTENT);
......
......@@ -520,11 +520,8 @@ static int lm63_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -683,11 +683,8 @@ static int lm78_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
if(i2c_is_isa_client(client))
release_region(client->addr, LM78_EXTENT);
......
......@@ -510,11 +510,8 @@ static int lm80_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -363,11 +363,8 @@ static int lm83_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -734,11 +734,8 @@ static int lm87_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -562,11 +562,8 @@ static int lm90_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -399,11 +399,8 @@ static int lm92_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -322,11 +322,8 @@ static int max1619_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -984,11 +984,8 @@ static int pc87360_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((i = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((i = i2c_detach_client(client)))
return i;
}
for (i = 0; i < 3; i++) {
if (data->address[i]) {
......
......@@ -618,11 +618,8 @@ static int sis5595_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
release_region(client->addr, SIS5595_EXTENT);
......
......@@ -214,11 +214,8 @@ static int smsc47b397_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
release_region(client->addr, SMSC_EXTENT);
kfree(data);
......
......@@ -497,11 +497,8 @@ static int smsc47m1_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
release_region(client->addr, SMSC_EXTENT);
kfree(data);
......
......@@ -700,11 +700,8 @@ static int via686a_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
release_region(client->addr, VIA686A_EXTENT);
kfree(data);
......
......@@ -774,11 +774,8 @@ static int w83627ehf_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
release_region(client->addr, REGION_LENGTH);
kfree(data);
......
......@@ -1157,11 +1157,8 @@ static int w83627hf_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
release_region(client->addr, WINB_EXTENT);
kfree(data);
......
......@@ -1299,11 +1299,8 @@ w83781d_detach_client(struct i2c_client *client)
if (i2c_is_isa_client(client))
release_region(client->addr, W83781D_EXTENT);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
/* main client */
if (data)
......
......@@ -1396,11 +1396,8 @@ w83792d_detach_client(struct i2c_client *client)
if (data)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
/* main client */
if (data)
......
......@@ -267,11 +267,8 @@ static int w83l785ts_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(data);
return 0;
......
......@@ -353,11 +353,8 @@ static int ds1337_detach_client(struct i2c_client *client)
int err;
struct ds1337_data *data = i2c_get_clientdata(client);
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
list_del(&data->list);
kfree(data);
......
......@@ -230,10 +230,8 @@ static int eeprom_detach_client(struct i2c_client *client)
int err;
err = i2c_detach_client(client);
if (err) {
dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
if (err)
return err;
}
kfree(i2c_get_clientdata(client));
......
......@@ -242,10 +242,8 @@ static int max6875_detach_client(struct i2c_client *client)
int err;
err = i2c_detach_client(client);
if (err) {
dev_err(&client->dev, "i2c_detach_client() failed\n");
if (err)
return err;
}
kfree(i2c_get_clientdata(client));
return 0;
}
......
......@@ -163,10 +163,8 @@ static int pca9539_detach_client(struct i2c_client *client)
{
int err;
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(i2c_get_clientdata(client));
return 0;
......
......@@ -185,11 +185,8 @@ static int pcf8574_detach_client(struct i2c_client *client)
{
int err;
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(i2c_get_clientdata(client));
return 0;
......
......@@ -240,11 +240,8 @@ static int pcf8591_detach_client(struct i2c_client *client)
{
int err;
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
if ((err = i2c_detach_client(client)))
return err;
}
kfree(i2c_get_clientdata(client));
return 0;
......
......@@ -449,8 +449,12 @@ int i2c_detach_client(struct i2c_client *client)
struct i2c_adapter *adapter = client->adapter;
int res = 0;
if ((client->flags & I2C_CLIENT_ALLOW_USE) && (client->usage_count > 0))
if ((client->flags & I2C_CLIENT_ALLOW_USE)
&& (client->usage_count > 0)) {
dev_warn(&client->dev, "Client [%s] still busy, "
"can't detach\n", client->name);
return -EBUSY;
}
if (adapter->client_unregister) {
res = adapter->client_unregister(client);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册