[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>
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index 2a34139..da3e2c9 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -328,10 +328,8 @@
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;
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index bdba01e..181dadf 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -517,11 +517,8 @@
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;
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index d521000..82edf28 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -645,11 +645,8 @@
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;
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index 290f7d2..c6a2c94 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -867,11 +867,8 @@
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)
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index 4a316a7..3ac37e9 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -282,11 +282,8 @@
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);
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c
index c7caa95..ddf22fb 100644
--- a/drivers/hwmon/fscher.c
+++ b/drivers/hwmon/fscher.c
@@ -383,11 +383,8 @@
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;
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c
index fd75e44..489870a 100644
--- a/drivers/hwmon/fscpos.c
+++ b/drivers/hwmon/fscpos.c
@@ -549,11 +549,8 @@
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;
}
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 34d85b1..63a2756 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -492,11 +492,8 @@
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;
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index b129d15..ff71eb7 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -654,11 +654,8 @@
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;
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 0a8d795..b1719f4 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -945,11 +945,8 @@
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);
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index e19b11f..736126d 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -520,11 +520,8 @@
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;
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index 784935f..21b767a 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -683,11 +683,8 @@
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);
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index fa2cb17..36a0cda 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -510,11 +510,8 @@
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;
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index 0223b4d..f3557f8 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -363,11 +363,8 @@
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;
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index 1dc3bf5..f0ffe58 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -734,11 +734,8 @@
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;
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 4b914ec..fbf9dac 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -562,11 +562,8 @@
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;
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index 9c43120..9740ee2 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -399,11 +399,8 @@
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;
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 5f03765..a53d7df 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -322,11 +322,8 @@
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;
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index 4041488..1f1b3ca 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -984,11 +984,8 @@
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]) {
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 6724629..55716cb 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -618,11 +618,8 @@
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);
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index dddc94a..7fe7157 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -214,11 +214,8 @@
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);
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 8126fdd..9da5d54 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -497,11 +497,8 @@
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);
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index cd3732c..d9251fb 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -700,11 +700,8 @@
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);
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index b14801c..b60efe8 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -774,11 +774,8 @@
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);
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 9e31f55..f1ae0e00 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -1157,11 +1157,8 @@
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);
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 7071855..66835c1 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1299,11 +1299,8 @@
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)
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 05f9b92..ea0c351 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -1396,11 +1396,8 @@
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)
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 9cd1939..213fb17 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -267,11 +267,8 @@
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;