aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2005-07-31 15:33:23 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 12:14:18 -0400
commitef8dec5d8b3e96e359f377f35cd8caff42fe6d58 (patch)
treeca83d278af5da3dfc9ef01f1d5bf479e67229d25 /drivers/i2c
parent9fc6adfa9adf2be84119a3c2592287f33bd1dff2 (diff)
[PATCH] hwmon: hwmon vs i2c, second round (02/11)
The way i2c-sensor handles forced addresses could be optimized. It defines a structure (i2c_force_data) to associate a module parameter with a given kind value, but in fact this kind value is always the index of the structure in each array it is used in. So this additional value can be omitted, and still be deduced in the code handling these arrays. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-sensor-detect.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c
index 5aede3ca9cb0..c952926c1482 100644
--- a/drivers/i2c/i2c-sensor-detect.c
+++ b/drivers/i2c/i2c-sensor-detect.c
@@ -32,7 +32,6 @@ int i2c_detect(struct i2c_adapter *adapter,
32 int (*found_proc) (struct i2c_adapter *, int, int)) 32 int (*found_proc) (struct i2c_adapter *, int, int))
33{ 33{
34 int addr, i, found, j, err; 34 int addr, i, found, j, err;
35 struct i2c_force_data *this_force;
36 int adapter_id = i2c_adapter_id(adapter); 35 int adapter_id = i2c_adapter_id(adapter);
37 unsigned short *normal_i2c; 36 unsigned short *normal_i2c;
38 unsigned short *probe; 37 unsigned short *probe;
@@ -58,13 +57,13 @@ int i2c_detect(struct i2c_adapter *adapter,
58 /* If it is in one of the force entries, we don't do any 57 /* If it is in one of the force entries, we don't do any
59 detection at all */ 58 detection at all */
60 found = 0; 59 found = 0;
61 for (i = 0; !found && (this_force = address_data->forces + i, this_force->force); i++) { 60 for (i = 0; address_data->forces[i]; i++) {
62 for (j = 0; !found && (this_force->force[j] != I2C_CLIENT_END); j += 2) { 61 for (j = 0; !found && (address_data->forces[i][j] != I2C_CLIENT_END); j += 2) {
63 if ( ((adapter_id == this_force->force[j]) || 62 if ( ((adapter_id == address_data->forces[i][j]) ||
64 (this_force->force[j] == ANY_I2C_BUS)) && 63 (address_data->forces[i][j] == ANY_I2C_BUS)) &&
65 (addr == this_force->force[j + 1]) ) { 64 (addr == address_data->forces[i][j + 1]) ) {
66 dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr); 65 dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr);
67 if ((err = found_proc(adapter, addr, this_force->kind))) 66 if ((err = found_proc(adapter, addr, i)))
68 return err; 67 return err;
69 found = 1; 68 found = 1;
70 } 69 }