[PATCH] i2c: Rework client usage count, 2 of 3
authorJean Delvare <khali@linux-fr.org>
Sat, 26 Nov 2005 20:00:54 +0000 (21:00 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 6 Jan 2006 06:16:22 +0000 (22:16 -0800)
Make I2C_CLIENT_ALLOW_USE the default for all i2c clients. It doesn't
hurt if the usage count is actually never used for any given driver,
and allows for nice code simplifications in i2c-core.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
29 files changed:
arch/arm/mach-pxa/akita-ioexp.c
drivers/i2c/chips/rtc8564.c
drivers/i2c/i2c-core.c
drivers/media/video/adv7170.c
drivers/media/video/adv7175.c
drivers/media/video/bt819.c
drivers/media/video/bt832.c
drivers/media/video/bt856.c
drivers/media/video/cs53l32a.c
drivers/media/video/cx25840/cx25840-core.c
drivers/media/video/em28xx/em28xx-i2c.c
drivers/media/video/msp3400.c
drivers/media/video/saa6588.c
drivers/media/video/saa7110.c
drivers/media/video/saa7111.c
drivers/media/video/saa7114.c
drivers/media/video/saa7115.c
drivers/media/video/saa711x.c
drivers/media/video/saa7127.c
drivers/media/video/saa7134/saa6752hs.c
drivers/media/video/saa7185.c
drivers/media/video/tda9887.c
drivers/media/video/tuner-core.c
drivers/media/video/tvaudio.c
drivers/media/video/tveeprom.c
drivers/media/video/tvp5150.c
drivers/media/video/vpx3220.c
drivers/media/video/wm8775.c
include/linux/i2c.h

index 440ebb3c3db1129e093b92011289cc5177138c20..b6bff550c8e94e50eabd4986d5edb1ab1d40b03d 100644 (file)
@@ -133,7 +133,6 @@ static struct i2c_driver max7310_i2c_driver = {
 
 static struct i2c_client max7310_template = {
        name:   "akita-max7310",
-       flags:  I2C_CLIENT_ALLOW_USE,
        driver: &max7310_i2c_driver,
 };
 
index e586f75dd024ade3ab5bedf2efe70772fc30ee61..07494d39438191b783357340198e455aca028c96 100644 (file)
@@ -155,7 +155,6 @@ static int rtc8564_attach(struct i2c_adapter *adap, int addr, int kind)
 
        strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE);
        i2c_set_clientdata(new_client, d);
-       new_client->flags = I2C_CLIENT_ALLOW_USE;
        new_client->addr = addr;
        new_client->adapter = adap;
        new_client->driver = &rtc8564_driver;
index 2f0bc95293762b4d10a4f9547ec870c75e4d01e4..d16b4998c4c2f69ae9a17b21d8ec20fd53b9e369 100644 (file)
@@ -419,8 +419,7 @@ int i2c_attach_client(struct i2c_client *client)
                }
        }
 
-       if (client->flags & I2C_CLIENT_ALLOW_USE)
-               client->usage_count = 0;
+       client->usage_count = 0;
 
        client->dev.parent = &client->adapter->dev;
        client->dev.driver = &client->driver->driver;
@@ -443,8 +442,7 @@ 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->usage_count > 0) {
                dev_warn(&client->dev, "Client [%s] still busy, "
                         "can't detach\n", client->name);
                return -EBUSY;
@@ -499,12 +497,9 @@ int i2c_use_client(struct i2c_client *client)
        if (ret)
                return ret;
 
-       if (client->flags & I2C_CLIENT_ALLOW_USE) {
-               if (client->usage_count > 0)
-                       goto busy;
-               else 
-                       client->usage_count++;
-       }
+       if (client->usage_count > 0)
+               goto busy;
+       client->usage_count++;
 
        return 0;
  busy:
@@ -514,16 +509,13 @@ int i2c_use_client(struct i2c_client *client)
 
 int i2c_release_client(struct i2c_client *client)
 {
-       if(client->flags & I2C_CLIENT_ALLOW_USE) {
-               if(client->usage_count>0)
-                       client->usage_count--;
-               else {
-                       pr_debug("i2c-core: %s used one too many times\n",
-                               __FUNCTION__);
-                       return -EPERM;
-               }
+       if (!client->usage_count) {
+               pr_debug("i2c-core: %s used one too many times\n",
+                        __FUNCTION__);
+               return -EPERM;
        }
        
+       client->usage_count--;
        i2c_dec_use_client(client);
        
        return 0;
index c4f2265167a2c1173dade05635f29ba8e5c64e71..622b1619a7e334f86112674bb7d7de1c44052ee7 100644 (file)
@@ -420,7 +420,6 @@ adv7170_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_adv7170;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        if ((client->addr == I2C_ADV7170 >> 1) ||
            (client->addr == (I2C_ADV7170 >> 1) + 1)) {
                dname = adv7170_name;
index 4fc08b17d4d085933d0e420558f3d8e0b29b0560..d4859b4457153e11beb1e700a90754c04e8ddce2 100644 (file)
@@ -470,7 +470,6 @@ adv7175_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_adv7175;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        if ((client->addr == I2C_ADV7175 >> 1) ||
            (client->addr == (I2C_ADV7175 >> 1) + 1)) {
                dname = adv7175_name;
index 7bba69793b788474b36d87236229d6f5dab962c2..741e59af09919094bda003890aa38e6deaa2fe6f 100644 (file)
@@ -535,7 +535,6 @@ bt819_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_bt819;
-       client->flags = I2C_CLIENT_ALLOW_USE;
 
        decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL);
        if (decoder == NULL) {
index 0ba8652357e222b68f44ae19e04185eca5aa5c35..4ed13860b52362676e31e466510e38b7c334bc4a 100644 (file)
@@ -240,7 +240,6 @@ static struct i2c_driver driver = {
 static struct i2c_client client_template =
 {
        .name       = "bt832",
-       .flags      = I2C_CLIENT_ALLOW_USE,
        .driver     = &driver,
 };
 
index 4c9acd1e2c70c199d4203ebdca36d978a5a4b22e..d4bba8efac69ff33a2949f059eded88162590ed7 100644 (file)
@@ -323,7 +323,6 @@ bt856_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_bt856;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        strlcpy(I2C_NAME(client), "bt856", sizeof(I2C_NAME(client)));
 
        encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
index fce5d89b7b1560541c073b0efc949e601c1b3c2d..f442ce3ba74b037345f5bbb10e2ac3402cce7f91 100644 (file)
@@ -154,7 +154,6 @@ static int cs53l32a_attach(struct i2c_adapter *adapter, int address, int kind)
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        snprintf(client->name, sizeof(client->name) - 1, "cs53l32a");
 
        cs53l32a_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name);
index c66bc147ee715b38453962d37b1a8de7fd6f30ba..0b278abe879dbe796efcce644b13450d30b701b9 100644 (file)
@@ -773,7 +773,6 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_cx25840;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        snprintf(client->name, sizeof(client->name) - 1, "cx25840");
 
        cx25840_dbg("detecting cx25840 client on address 0x%x\n", address << 1);
index 7f5603054f02b7eaf17b5bebee6355cd9df8b00b..d14bcf4ceaeae621fad398f63cc4f7f74f139189 100644 (file)
@@ -497,7 +497,6 @@ static struct i2c_adapter em28xx_adap_template = {
 
 static struct i2c_client em28xx_client_template = {
        .name = "em28xx internal",
-       .flags = I2C_CLIENT_ALLOW_USE,
 };
 
 /* ----------------------------------------------------------- */
index 46328fb6fe80a5db62149089254c270aa3fd2b3a..c5e8ad3aac4adee5b9477f6e10f7edf90e159548 100644 (file)
@@ -1576,7 +1576,6 @@ static struct i2c_driver driver = {
 static struct i2c_client client_template =
 {
        .name      = "(unset)",
-       .flags     = I2C_CLIENT_ALLOW_USE,
        .driver    = &driver,
 };
 
index 18a0b7143e8bc4ce09e1886843904e454fb01a69..3d4076ca67c3ce97160b5480cfdcfbcfacbf0f64 100644 (file)
@@ -505,7 +505,6 @@ static struct i2c_driver driver = {
 
 static struct i2c_client client_template = {
        .name = "saa6588",
-       .flags = I2C_CLIENT_ALLOW_USE,
        .driver = &driver,
 };
 
index f266b35ceb350819dce35b95f04c9bd25f6f306a..8affa63c8b244d4f9eae8811589aeab1ab5addf1 100644 (file)
@@ -501,7 +501,6 @@ saa7110_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_saa7110;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client)));
 
        decoder = kmalloc(sizeof(struct saa7110), GFP_KERNEL);
index 687beaf11adc261577d916e7f5f2208a0ed4a864..2b2204564514ca80d5bc64db70332f46697075e4 100644 (file)
@@ -518,7 +518,6 @@ saa7111_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_saa7111;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        strlcpy(I2C_NAME(client), "saa7111", sizeof(I2C_NAME(client)));
 
        decoder = kmalloc(sizeof(struct saa7111), GFP_KERNEL);
index 4748cf0598c0903c4021519e1fcc05bae305a574..285f6c7a8f718f04cfc1eb0f4f93e83cd5f326f1 100644 (file)
@@ -859,7 +859,6 @@ saa7114_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_saa7114;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client)));
 
        decoder = kmalloc(sizeof(struct saa7114), GFP_KERNEL);
index b1079de938b7efecd32d49fc2d09fde9f6096281..79aadd2d408fc0e9becbdba10ee73ad9c8cbe438 100644 (file)
@@ -1270,7 +1270,6 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_saa7115;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        snprintf(client->name, sizeof(client->name) - 1, "saa7115");
 
        saa7115_dbg("detecting saa7115 client on address 0x%x\n", address << 1);
index 734a70919080648d5355a39d615221867fe7879f..44bfc047704c33b3c3a6ff10e5fd0774d500db63 100644 (file)
@@ -494,7 +494,6 @@ saa711x_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_saa711x;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        strlcpy(I2C_NAME(client), "saa711x", sizeof(I2C_NAME(client)));
        decoder = kmalloc(sizeof(struct saa711x), GFP_KERNEL);
        if (decoder == NULL) {
index a2fab98375079c08517147ffcf7c51d13be0ad0d..1f4b415994457dd08bb4349fa782e423b1658256 100644 (file)
@@ -719,7 +719,6 @@ static int saa7127_attach(struct i2c_adapter *adapter, int address, int kind)
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_saa7127;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        snprintf(client->name, sizeof(client->name) - 1, "saa7127");
 
        saa7127_dbg("detecting saa7127 client on address 0x%x\n", address << 1);
index 6fc298e0a03a57e5d6106a3a0617db3bdf6bcab7..68206060c92dce0d4ed11aeddb6cdc3f97c10989 100644 (file)
@@ -608,7 +608,6 @@ static struct i2c_driver driver = {
 static struct i2c_client client_template =
 {
        .name       = "saa6752hs",
-       .flags      = I2C_CLIENT_ALLOW_USE,
        .driver     = &driver,
 };
 
index e24aa16f2d8c33e8fa89c0657b3eb926763837c8..9f37585d3f7385c6db9b5e998850e2c40f538c12 100644 (file)
@@ -415,7 +415,6 @@ saa7185_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_saa7185;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        strlcpy(I2C_NAME(client), "saa7185", sizeof(I2C_NAME(client)));
 
        encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL);
index 049b44e0767be20d356df62f2bf5f382730a68fe..324f61bf714e3eaf43eb159e7909073a5dd01c91 100644 (file)
@@ -833,7 +833,6 @@ static struct i2c_driver driver = {
 static struct i2c_client client_template =
 {
        .name      = "tda9887",
-       .flags     = I2C_CLIENT_ALLOW_USE,
        .driver    = &driver,
 };
 
index 3c75121f638344200ddf3f63f0ee5385feb10be7..6328f0954e70075de82d1b441a1949ca5fdb2f4f 100644 (file)
@@ -755,7 +755,6 @@ static struct i2c_driver driver = {
 };
 static struct i2c_client client_template = {
        .name = "(tuner unset)",
-       .flags = I2C_CLIENT_ALLOW_USE,
        .driver = &driver,
 };
 
index 3565f35be7a1594103906224706aa70944274fbe..4f1f339283e0a33ccc239077f7eb9cfa1552ecec 100644 (file)
@@ -1713,7 +1713,6 @@ static struct i2c_driver driver = {
 static struct i2c_client client_template =
 {
        .name       = "(unset)",
-       .flags      = I2C_CLIENT_ALLOW_USE,
        .driver     = &driver,
 };
 
index 195bc51d4576c713d98d5bdada7ffd3a5c0a127d..d833b651073a077cf0d5016f573656c747bb06da 100644 (file)
@@ -751,7 +751,6 @@ tveeprom_detect_client(struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver_tveeprom;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        snprintf(client->name, sizeof(client->name), "tveeprom");
        i2c_attach_client(client);
 
index 4f3ee2091611835e5c791dc1d422d4618d61ce5d..3734554fc73b0ef3ca1f8e584f98c8ce4fe5e182 100644 (file)
@@ -714,7 +714,6 @@ static struct i2c_driver driver;
 
 static struct i2c_client client_template = {
        .name = "(unset)",
-       .flags = I2C_CLIENT_ALLOW_USE,
        .driver = &driver,
 };
 
index c66d28505bcdf687251d951b768852481f84a027..54bc888c3891d49e7e2d0a226a61ba5c44aab801 100644 (file)
@@ -631,7 +631,6 @@ vpx3220_detect_client (struct i2c_adapter *adapter,
        client->addr = address;
        client->adapter = adapter;
        client->driver = &vpx3220_i2c_driver;
-       client->flags = I2C_CLIENT_ALLOW_USE;
 
        /* Check for manufacture ID and part number */
        if (kind < 0) {
index 7b07717a3c678d5264a586fc26f137404d3f0ace..527c2591749ad0598fdcaeb039cd9f994638a723 100644 (file)
@@ -168,7 +168,6 @@ static int wm8775_attach(struct i2c_adapter *adapter, int address, int kind)
        client->addr = address;
        client->adapter = adapter;
        client->driver = &i2c_driver;
-       client->flags = I2C_CLIENT_ALLOW_USE;
        snprintf(client->name, sizeof(client->name) - 1, "wm8775");
 
        wm8775_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name);
index 4487c51897478f2926b7dbcc8dd79df8e87c1d75..8b4d4695de0efa3783de6af5afb57ef8a33ac411 100644 (file)
@@ -250,7 +250,6 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
 }
 
 /*flags for the client struct: */
-#define I2C_CLIENT_ALLOW_USE           0x01    /* Client allows access */
 #define I2C_CLIENT_PEC  0x04                   /* Use Packet Error Checking */
 #define I2C_CLIENT_TEN 0x10                    /* we have a ten bit chip address       */
                                                /* Must equal I2C_M_TEN below */