]> err.no Git - linux-2.6/commitdiff
[PATCH] hwmon: hwmon vs i2c, second round (01/11)
authorJean Delvare <khali@linux-fr.org>
Sun, 31 Jul 2005 19:20:43 +0000 (21:20 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 5 Sep 2005 16:14:18 +0000 (09:14 -0700)
Add support for kind-forced addresses to i2c_probe, like i2c_detect
has for (essentially) hardware monitoring drivers.

Note that this change will slightly increase the size of the drivers
using I2C_CLIENT_INSMOD, with no immediate benefit. This is a
requirement if we want to merge i2c_probe and i2c_detect though, and
seems a reasonable price to pay in comparison with the previous
cleanups which saved much more than that (such as the i2c-isa cleanup
or the i2c address ranges removal.)

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
15 files changed:
drivers/i2c/chips/ds1374.c
drivers/i2c/chips/m41t00.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/bt856.c
drivers/media/video/saa7110.c
drivers/media/video/saa7111.c
drivers/media/video/saa7114.c
drivers/media/video/saa7185.c
drivers/media/video/tuner-3036.c
drivers/media/video/vpx3220.c
include/linux/i2c.h

index a445736d8838c46df70ab7c23d3a396d33915145..e2d1daf79880eeaa59fa92fd822b7755b8882e8d 100644 (file)
@@ -53,7 +53,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c = normal_addr,
        .probe = ignore,
        .ignore = ignore,
-       .force = ignore,
 };
 
 static ulong ds1374_read_rtc(void)
index 778d7e12859dd0de54ed2b877c6d0ffcee72dfee..e516dadc453fe50506cd606e7259d82f113acc0c 100644 (file)
@@ -42,7 +42,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_addr,
        .probe                  = ignore,
        .ignore                 = ignore,
-       .force                  = ignore,
 };
 
 ulong
index 588fc2261a91e5f3695a8c4234ece5c9b364553f..0b5385c892b1ae827fcb9d3345a77787fe56f5cb 100644 (file)
@@ -67,7 +67,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_addr,
        .probe                  = ignore,
        .ignore                 = ignore,
-       .force                  = ignore,
 };
 
 static int rtc8564_read_mem(struct i2c_client *client, struct mem *mem);
index 19d8a994b3b7c6917618db3f46b28360a3e376fc..372b5996d045ac1970ff45f7a15cafae04a8d9ad 100644 (file)
@@ -662,6 +662,28 @@ int i2c_control(struct i2c_client *client,
  * Will not work for 10-bit addresses!
  * ----------------------------------------------------
  */
+/* Return: kind (>= 0) if force found, -1 if not found */
+static inline int i2c_probe_forces(struct i2c_adapter *adapter, int addr,
+                                  unsigned short **forces)
+{
+       unsigned short kind;
+       int j, adap_id = i2c_adapter_id(adapter);
+
+       for (kind = 0; forces[kind]; kind++) {
+               for (j = 0; forces[kind][j] != I2C_CLIENT_END; j += 2) {
+                       if ((forces[kind][j] == adap_id ||
+                            forces[kind][j] == ANY_I2C_BUS)
+                        && forces[kind][j + 1] == addr) {
+                               dev_dbg(&adapter->dev, "found force parameter, "
+                                       "addr 0x%02x, kind %u\n", addr, kind);
+                               return kind;
+                       }
+               }
+       }
+
+       return -1;
+}
+
 int i2c_probe(struct i2c_adapter *adapter,
              struct i2c_client_address_data *address_data,
              int (*found_proc) (struct i2c_adapter *, int, int))
@@ -683,19 +705,15 @@ int i2c_probe(struct i2c_adapter *adapter,
                   at all */
                found = 0;
 
-               for (i = 0; !found && (address_data->force[i] != I2C_CLIENT_END); i += 2) {
-                       if (((adap_id == address_data->force[i]) || 
-                            (address_data->force[i] == ANY_I2C_BUS)) &&
-                            (addr == address_data->force[i+1])) {
-                               dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n",
-                                       adap_id, addr);
-                               if ((err = found_proc(adapter,addr,0)))
+               if (address_data->forces) {
+                       int kind = i2c_probe_forces(adapter, addr,
+                                                   address_data->forces);
+                       if (kind >= 0) { /* force found */
+                               if ((err = found_proc(adapter, addr, kind)))
                                        return err;
-                               found = 1;
+                               continue;
                        }
                }
-               if (found) 
-                       continue;
 
                /* If this address is in one of the ignores, we can forget about
                   it right now */
index 48989eda2400a120e5fea0a7e74bc500309d10e5..52e32f05d625b2fc9c0bcba9caa2aa60b9ac8878 100644 (file)
@@ -391,7 +391,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_adv7170;
index f898b65863741162d6269cf062d625e51660d3be..b5ed9544bdea14702564a7037f96ed9bc388e3ca 100644 (file)
@@ -441,7 +441,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_adv7175;
index 8733588f6db3db1905628cc1ba99a4c62c51ec9e..c6cfa7c48b04e5d5547437ab6703f61d25653dc2 100644 (file)
@@ -507,7 +507,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_bt819;
index a5d529ccf3ad174fb1aead3cac87e48f03dcebd2..c13d2865886882b36c3a8ee91f4a39a11e8c0362 100644 (file)
@@ -295,7 +295,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_bt856;
index 22d055d8a695591d04b65107a6034488c462dcb5..e116bdbed310945a3cb51f0975bac25e6776c0c7 100644 (file)
@@ -470,7 +470,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7110;
index fcd897382fcfc0fe5dc1271db95a6ae0079634ca..f18df53d98ff16c7b7b1027b5d0e5057ae7510c3 100644 (file)
@@ -489,7 +489,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7111;
index 2ba997f5ef1d50c20a785eadc3a2bfba2f3779f8..e0c70f54f0737f93cc8aa519fb588b93c0794eed 100644 (file)
@@ -827,7 +827,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7114;
index 108e7a4a02734dbd9d1e803a0a40ab5ac2ad3691..e93412f4407cb9d7fa1008d4c21a9e018555d534 100644 (file)
@@ -387,7 +387,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7185;
index 7d825e510ffd577a891c281e941658713b3a729e..103def1abe3cf6158cbceec3e36c9fbe1c3bd0fb 100644 (file)
@@ -41,7 +41,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c     = normal_i2c,
        .probe          = &ignore,
        .ignore         = &ignore,
-       .force          = &ignore,
 };
 
 /* ---------------------------------------------------------------------- */
index 5dbd9f6bf353b4730309411e514a4ba0c77a6a54..4437bdebe24f64676c3249961326aa3c1c17505d 100644 (file)
@@ -576,7 +576,6 @@ static struct i2c_client_address_data addr_data = {
        .normal_i2c             = normal_i2c,
        .probe                  = &ignore,
        .ignore                 = &ignore,
-       .force                  = &ignore,
 };
 
 static struct i2c_driver vpx3220_i2c_driver;
index ad1c0fb164bca2925b69c5ad923a80ce12847f6d..9419bc5584ad9559d7cb1dee80ebb7042e509bc1 100644 (file)
@@ -48,7 +48,6 @@ struct i2c_algorithm;
 struct i2c_adapter;
 struct i2c_client;
 struct i2c_driver;
-struct i2c_client_address_data;
 union i2c_smbus_data;
 
 /*
@@ -301,7 +300,7 @@ struct i2c_client_address_data {
        unsigned short *normal_i2c;
        unsigned short *probe;
        unsigned short *ignore;
-       unsigned short *force;
+       unsigned short **forces;
 };
 
 /* Internal numbers to terminate lists */
@@ -575,11 +574,15 @@ union i2c_smbus_data {
   I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
+       static unsigned short *addr_forces[] = {                        \
+                       force,                                          \
+                       NULL                                            \
+               };                                                      \
        static struct i2c_client_address_data addr_data = {             \
                        .normal_i2c =           normal_i2c,             \
                        .probe =                probe,                  \
                        .ignore =               ignore,                 \
-                       .force =                force,                  \
+                       .forces =               addr_forces,            \
                }
 
 #endif /* _LINUX_I2C_H */