From ef8dec5d8b3e96e359f377f35cd8caff42fe6d58 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:33:23 +0200 Subject: [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 Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-sensor-detect.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers/i2c/i2c-sensor-detect.c') diff --git a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c index 5aede3ca9cb..c952926c148 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, int (*found_proc) (struct i2c_adapter *, int, int)) { int addr, i, found, j, err; - struct i2c_force_data *this_force; int adapter_id = i2c_adapter_id(adapter); unsigned short *normal_i2c; unsigned short *probe; @@ -58,13 +57,13 @@ int i2c_detect(struct i2c_adapter *adapter, /* If it is in one of the force entries, we don't do any detection at all */ found = 0; - for (i = 0; !found && (this_force = address_data->forces + i, this_force->force); i++) { - for (j = 0; !found && (this_force->force[j] != I2C_CLIENT_END); j += 2) { - if ( ((adapter_id == this_force->force[j]) || - (this_force->force[j] == ANY_I2C_BUS)) && - (addr == this_force->force[j + 1]) ) { + for (i = 0; address_data->forces[i]; i++) { + for (j = 0; !found && (address_data->forces[i][j] != I2C_CLIENT_END); j += 2) { + if ( ((adapter_id == address_data->forces[i][j]) || + (address_data->forces[i][j] == ANY_I2C_BUS)) && + (addr == address_data->forces[i][j + 1]) ) { dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr); - if ((err = found_proc(adapter, addr, this_force->kind))) + if ((err = found_proc(adapter, addr, i))) return err; found = 1; } -- cgit v1.2.3