[PATCH] I2C: refactor message in i2c_detach_client
authorJean Delvare <khali@linux-fr.org>
Wed, 27 Jul 2005 20:14:49 +0000 (22:14 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 5 Sep 2005 16:14:14 +0000 (09:14 -0700)
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>
37 files changed:
Documentation/i2c/porting-clients
Documentation/i2c/writing-clients
drivers/hwmon/adm1021.c
drivers/hwmon/adm1025.c
drivers/hwmon/adm9240.c
drivers/hwmon/asb100.c
drivers/hwmon/ds1621.c
drivers/hwmon/fscher.c
drivers/hwmon/fscpos.c
drivers/hwmon/gl518sm.c
drivers/hwmon/gl520sm.c
drivers/hwmon/it87.c
drivers/hwmon/lm63.c
drivers/hwmon/lm78.c
drivers/hwmon/lm80.c
drivers/hwmon/lm83.c
drivers/hwmon/lm87.c
drivers/hwmon/lm90.c
drivers/hwmon/lm92.c
drivers/hwmon/max1619.c
drivers/hwmon/pc87360.c
drivers/hwmon/sis5595.c
drivers/hwmon/smsc47b397.c
drivers/hwmon/smsc47m1.c
drivers/hwmon/via686a.c
drivers/hwmon/w83627ehf.c
drivers/hwmon/w83627hf.c
drivers/hwmon/w83781d.c
drivers/hwmon/w83792d.c
drivers/hwmon/w83l785ts.c
drivers/i2c/chips/ds1337.c
drivers/i2c/chips/eeprom.c
drivers/i2c/chips/max6875.c
drivers/i2c/chips/pca9539.c
drivers/i2c/chips/pcf8574.c
drivers/i2c/chips/pcf8591.c
drivers/i2c/i2c-core.c

index 105c6186b912829487d1cef3b4e0566c9a8f89d0..68bcd66e36b15edfad79b91137e5bc6ed9a359ee 100644 (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.
index 522ae01d2e7f1b01b4edf2946ecbcc2fb97a072f..7e2a8f11c220299a8f6a101c1b1ac3255fbb49a0 100644 (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)
index 2a341390d92ec0c9b17f276bf1c92991ce704158..da3e2c9f705f46b504abb33b986a396886a4023c 100644 (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;
index bdba01e2f3ed97b5751575dc3772f63981298e81..181dadf420028d1b6c61e64a6f9d35166e7c2ac2 100644 (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;
index d52100027665eaa28e670c4dc6646655b64cc099..82edf286ebdc878e7b4686b4019797efe73d8db7 100644 (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;
index 290f7d2ac0a8194f20a5507e33ea046a13856b30..c6a2c94fad36e1b8b4438b584e51ffe778763f1f 100644 (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)
index 4a316a7f798046cc973913a3d1cf1fa0f32b5903..3ac37e95d2efd0fe5c5ecb164d70680c15d6f4a9 100644 (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);
 
index c7caa95c643b452ceb31aba67d836e54dcbf0bc7..ddf22fbf4ed14b597c62f4d07de9c8ee935e69fd 100644 (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;
index fd75e444e7580ccb47fc48f4860ff0f54b7063dd..489870ad6056ea2c8a8933bb959effe0b00f634c 100644 (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;
 }
index 34d85b1e55397f6592b2b3b4b607172cee17f37c..63a2756c283a97a3f9c2bf89b1e523616a38df64 100644 (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;
index b129d153deabadd0eff579209660780bf2d56cef..ff71eb7ac6819fd73ad2eb2f6eb254d391b2b806 100644 (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;
index 0a8d795f15c2e242653dc160beb9102a2430384b..b1719f4097efbdaa6e8fead081353aa59c6aa5f5 100644 (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);
index e19b11fd4816954050daf9a710bbec9593e27cc8..736126d73aa25e430e594ef76e0e3f58cbbb6eaf 100644 (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;
index 784935f77016af6af0187070c543ac81622e9daf..21b767a66bbd93c5a2365107529cd1fce622ddbc 100644 (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);
index fa2cb17018cc45ff1c5d3c67d57f9004fe37b342..36a0cda36a7d076df221375a4a3b62218a95c310 100644 (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;
index 0223b4d2ce1dae9858b21d2ae8e6d9168c3a1575..f3557f8826a9ef738b5d729c7fa56cc4322fd364 100644 (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;
index 1dc3bf52b40d9d6c25f08f1d0db19182a201537d..f0ffe58e3670eac30a61050fbccd0fd94c397c23 100644 (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;
index 4b914ec205fa914d481d6f722749155c2fa3fb20..fbf9dac41ee5fa85f5c91bfe186800424d9774ec 100644 (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;
index 9c43120d6bd78386f2fcf59ee6c6d3ddd9a7976a..9740ee264051ef5f3a0e5ebf99431999e91a7ece 100644 (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;
index 5f0376575c625db392fb7fa509e1c67471ef858f..a53d7df92ba231314323d3f8adc67f97fb7359e7 100644 (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;
index 4041488de6f14719660c790fdbb1bbc1395ad69d..1f1b3ca23f6f68bbf14af8e4e86b74c82f548dda 100644 (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]) {
index 67246299a30814e50ddfbf422046d909036b85ad..55716cb579aa587b741a6b2a50902ac2328c3cef 100644 (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);
 
index dddc94a7649b9d1d99877a1d4783701bb68200d1..7fe71576dea4b7416e6b15ae387e56dc6238da1d 100644 (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);
index 8126fdd7cbee24f68e813b907888977be3932afb..9da5d546e861ad1bc7bd69e90c3d57e7b76b0944 100644 (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);
index cd3732c366716a6fddc29c7355714d3fddf0b2b3..d9251fb0b625c5633a9799b1801700b7041f7aea 100644 (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);
index b14801cd615d5881d5738a56bf29e502ade7bf30..b60efe8f8b26691a70bc64f5617d362b68e7a2be 100644 (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);
 
index 9e31f5559ccce0b755368ce1f4e63aa869b7e25d..f1ae0e00691bdd9714557f25435e4d057aa0705c 100644 (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);
index 70718559de7590ee35c6ce24ef61c848767d8e0e..66835c1e3f682e7d77a5236370201bb58bb2d32d 100644 (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)
index 05f9b92ad3e73d316ed0457ec2a52e272462fd89..ea0c3519e03ad7af54c8ec6743dd3ded47e4274d 100644 (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)
index 9cd1939cd040f9d07ae2620151662ca55d4f2481..213fb170d3973834e786020b909a4fd3b77f7340 100644 (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;
index 6ac0a6e0076964c0d4bf8c4a3276846ce5f3b77d..8ab4e2348cdad44b708a36e4712a4c20f8c266dd 100644 (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);
index 88f83bac38453e4c2f3aa531a34b92b3d34056f3..9466ada68932021ef4147c972b4794f1717bd860 100644 (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));
 
index d1d48586b90e14b0cac60d60040329d65c39c91e..52fd6bf291333b676214ffa63b6aae85fb7ef756 100644 (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;
 }
index c5b052363d9a38c13bd8e736a1f0148d08facc4a..1500b1842ce5a0c1e7281c5730d06cf0c997be50 100644 (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;
index 7a1fa791463032a1efe57d48eb322c218b56a059..a109dfd3dbe7ec322a99e37f55b117e1a17221dd 100644 (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;
index 225b512dd4ad1075b671bc742b56689f81acf8c9..7fce0fc048d9f20699c75a852c8d60c65ac088ca 100644 (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;
index 7a7837ae311484d40394b82147dd300d131fe778..b0bceb2fb8b1110b677a45ffb1dc964a2811eb37 100644 (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);