From 4926c0d4de77c5396a274ee7941ed7fc02afed26 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 19 Jul 2005 23:57:54 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (6/9) Kill all isa-related stuff from i2c_detect, it's not used anymore. This is one major step in the directiom of merging i2c_probe and i2c_detect. The last obstacle I can think of is the different way forced addresses work between sensors and non-sensors i2c drivers. I'll deal with that in a later patchset. Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-sensor-detect.c | 45 ++++++++++++----------------------------- 1 file changed, 13 insertions(+), 32 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 f99a8161a9f1..5aede3ca9cb0 100644 --- a/drivers/i2c/i2c-sensor-detect.c +++ b/drivers/i2c/i2c-sensor-detect.c @@ -25,42 +25,34 @@ #include static unsigned short empty[] = {I2C_CLIENT_END}; -static unsigned int empty_isa[] = {I2C_CLIENT_ISA_END}; -/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */ +/* Won't work for 10-bit addresses! */ int i2c_detect(struct i2c_adapter *adapter, struct i2c_address_data *address_data, int (*found_proc) (struct i2c_adapter *, int, int)) { int addr, i, found, j, err; struct i2c_force_data *this_force; - int is_isa = i2c_is_isa_adapter(adapter); - int adapter_id = - is_isa ? ANY_I2C_ISA_BUS : i2c_adapter_id(adapter); + int adapter_id = i2c_adapter_id(adapter); unsigned short *normal_i2c; - unsigned int *normal_isa; unsigned short *probe; unsigned short *ignore; /* Forget it if we can't probe using SMBUS_QUICK */ - if ((!is_isa) && - !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) return -1; /* Use default "empty" list if the adapter doesn't specify any */ normal_i2c = probe = ignore = empty; - normal_isa = empty_isa; if (address_data->normal_i2c) normal_i2c = address_data->normal_i2c; - if (address_data->normal_isa) - normal_isa = address_data->normal_isa; if (address_data->probe) probe = address_data->probe; if (address_data->ignore) ignore = address_data->ignore; - for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) { - if (!is_isa && i2c_check_addr(adapter, addr)) + for (addr = 0x00; addr <= 0x7f; addr++) { + if (i2c_check_addr(adapter, addr)) continue; /* If it is in one of the force entries, we don't do any @@ -69,7 +61,7 @@ int i2c_detect(struct i2c_adapter *adapter, 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) && !is_isa)) && + (this_force->force[j] == ANY_I2C_BUS)) && (addr == this_force->force[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))) @@ -85,8 +77,7 @@ int i2c_detect(struct i2c_adapter *adapter, right now */ for (i = 0; !found && (ignore[i] != I2C_CLIENT_END); i += 2) { if ( ((adapter_id == ignore[i]) || - ((ignore[i] == ANY_I2C_BUS) && - !is_isa)) && + (ignore[i] == ANY_I2C_BUS)) && (addr == ignore[i + 1])) { dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr); found = 1; @@ -97,19 +88,10 @@ int i2c_detect(struct i2c_adapter *adapter, /* Now, we will do a detection, but only if it is in the normal or probe entries */ - if (is_isa) { - for (i = 0; !found && (normal_isa[i] != I2C_CLIENT_ISA_END); i += 1) { - if (addr == normal_isa[i]) { - dev_dbg(&adapter->dev, "found normal isa entry for adapter %d, addr %04x\n", adapter_id, addr); - found = 1; - } - } - } else { - for (i = 0; !found && (normal_i2c[i] != I2C_CLIENT_END); i += 1) { - if (addr == normal_i2c[i]) { - found = 1; - dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x\n", adapter_id, addr); - } + for (i = 0; !found && (normal_i2c[i] != I2C_CLIENT_END); i += 1) { + if (addr == normal_i2c[i]) { + found = 1; + dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x\n", adapter_id, addr); } } @@ -117,7 +99,7 @@ int i2c_detect(struct i2c_adapter *adapter, !found && (probe[i] != I2C_CLIENT_END); i += 2) { if (((adapter_id == probe[i]) || - ((probe[i] == ANY_I2C_BUS) && !is_isa)) + (probe[i] == ANY_I2C_BUS)) && (addr == probe[i + 1])) { dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr); found = 1; @@ -128,8 +110,7 @@ int i2c_detect(struct i2c_adapter *adapter, /* OK, so we really should examine this address. First check whether there is some client here at all! */ - if (is_isa || - (i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0)) + if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0) if ((err = found_proc(adapter, addr, -1))) return err; } -- cgit v1.2.3 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 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, 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 From b78ec31582c60578ee1d3bb470791d6dde96ccf7 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:36:24 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (03/11) We now have two identical structures, i2c_address_data in i2c-sensor.h and i2c_client_address_data in i2c.h. We can kill one of them, I choose to keep the one in i2c.h as it makes more sense (this structure is not specific to sensors.) Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-sensor-detect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 c952926c1482..70fcf7281988 100644 --- a/drivers/i2c/i2c-sensor-detect.c +++ b/drivers/i2c/i2c-sensor-detect.c @@ -28,7 +28,7 @@ static unsigned short empty[] = {I2C_CLIENT_END}; /* Won't work for 10-bit addresses! */ int i2c_detect(struct i2c_adapter *adapter, - struct i2c_address_data *address_data, + struct i2c_client_address_data *address_data, int (*found_proc) (struct i2c_adapter *, int, int)) { int addr, i, found, j, err; -- cgit v1.2.3 From 96478ef3f3f71fa929cc905cc794993e312d9a5d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:45:27 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (05/11) The i2c_detect function has no more user, delete it. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-sensor-detect.c | 125 ---------------------------------------- 1 file changed, 125 deletions(-) delete mode 100644 drivers/i2c/i2c-sensor-detect.c (limited to 'drivers/i2c/i2c-sensor-detect.c') diff --git a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c deleted file mode 100644 index 70fcf7281988..000000000000 --- a/drivers/i2c/i2c-sensor-detect.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - i2c-sensor-detect.c - Part of lm_sensors, Linux kernel modules for hardware - monitoring - Copyright (c) 1998 - 2001 Frodo Looijaard and - Mark D. Studebaker - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include -#include -#include -#include - -static unsigned short empty[] = {I2C_CLIENT_END}; - -/* Won't work for 10-bit addresses! */ -int i2c_detect(struct i2c_adapter *adapter, - struct i2c_client_address_data *address_data, - int (*found_proc) (struct i2c_adapter *, int, int)) -{ - int addr, i, found, j, err; - int adapter_id = i2c_adapter_id(adapter); - unsigned short *normal_i2c; - unsigned short *probe; - unsigned short *ignore; - - /* Forget it if we can't probe using SMBUS_QUICK */ - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) - return -1; - - /* Use default "empty" list if the adapter doesn't specify any */ - normal_i2c = probe = ignore = empty; - if (address_data->normal_i2c) - normal_i2c = address_data->normal_i2c; - if (address_data->probe) - probe = address_data->probe; - if (address_data->ignore) - ignore = address_data->ignore; - - for (addr = 0x00; addr <= 0x7f; addr++) { - if (i2c_check_addr(adapter, addr)) - continue; - - /* If it is in one of the force entries, we don't do any - detection at all */ - found = 0; - 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, i))) - return err; - found = 1; - } - } - } - if (found) - continue; - - /* If this address is in one of the ignores, we can forget about it - right now */ - for (i = 0; !found && (ignore[i] != I2C_CLIENT_END); i += 2) { - if ( ((adapter_id == ignore[i]) || - (ignore[i] == ANY_I2C_BUS)) && - (addr == ignore[i + 1])) { - dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr); - found = 1; - } - } - if (found) - continue; - - /* Now, we will do a detection, but only if it is in the normal or - probe entries */ - for (i = 0; !found && (normal_i2c[i] != I2C_CLIENT_END); i += 1) { - if (addr == normal_i2c[i]) { - found = 1; - dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x\n", adapter_id, addr); - } - } - - for (i = 0; - !found && (probe[i] != I2C_CLIENT_END); - i += 2) { - if (((adapter_id == probe[i]) || - (probe[i] == ANY_I2C_BUS)) - && (addr == probe[i + 1])) { - dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr); - found = 1; - } - } - if (!found) - continue; - - /* OK, so we really should examine this address. First check - whether there is some client here at all! */ - if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0) - if ((err = found_proc(adapter, addr, -1))) - return err; - } - return 0; -} - -EXPORT_SYMBOL(i2c_detect); - -MODULE_AUTHOR("Frodo Looijaard , " - "Rudolf Marek "); - -MODULE_DESCRIPTION("i2c-sensor driver"); -MODULE_LICENSE("GPL"); -- cgit v1.2.3