diff options
author | Jean Delvare <khali@linux-fr.org> | 2005-07-31 21:20:43 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-05 09:14:18 -0700 |
commit | 9fc6adfa9adf2be84119a3c2592287f33bd1dff2 (patch) | |
tree | 6a8e52520c4f99e52de428afc6cd24b844fcb72d /drivers/i2c | |
parent | 5cb802293e87035920d47979107af8cf42a2f62a (diff) | |
download | linux-9fc6adfa9adf2be84119a3c2592287f33bd1dff2.tar.bz2 |
[PATCH] hwmon: hwmon vs i2c, second round (01/11)
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>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/chips/ds1374.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/m41t00.c | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/rtc8564.c | 1 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 38 |
4 files changed, 28 insertions, 13 deletions
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index a445736d8838..e2d1daf79880 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c @@ -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) diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 778d7e12859d..e516dadc453f 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c @@ -42,7 +42,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_addr, .probe = ignore, .ignore = ignore, - .force = ignore, }; ulong diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 588fc2261a91..0b5385c892b1 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c @@ -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); diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 19d8a994b3b7..372b5996d045 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -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 */ |