[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: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Jean Delvare 2005-07-27 22:14:49 +02:00 committed by Greg Kroah-Hartman
parent 1ff4e3065b
commit 7bef559455
37 changed files with 42 additions and 137 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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]) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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));

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);