diff options
author | Jean Delvare <khali@linux-fr.org> | 2005-07-31 15:20:43 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-05 12:14:18 -0400 |
commit | 9fc6adfa9adf2be84119a3c2592287f33bd1dff2 (patch) | |
tree | 6a8e52520c4f99e52de428afc6cd24b844fcb72d /drivers/i2c/i2c-core.c | |
parent | 5cb802293e87035920d47979107af8cf42a2f62a (diff) |
[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/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 38 |
1 files changed, 28 insertions, 10 deletions
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, | |||
662 | * Will not work for 10-bit addresses! | 662 | * Will not work for 10-bit addresses! |
663 | * ---------------------------------------------------- | 663 | * ---------------------------------------------------- |
664 | */ | 664 | */ |
665 | /* Return: kind (>= 0) if force found, -1 if not found */ | ||
666 | static inline int i2c_probe_forces(struct i2c_adapter *adapter, int addr, | ||
667 | unsigned short **forces) | ||
668 | { | ||
669 | unsigned short kind; | ||
670 | int j, adap_id = i2c_adapter_id(adapter); | ||
671 | |||
672 | for (kind = 0; forces[kind]; kind++) { | ||
673 | for (j = 0; forces[kind][j] != I2C_CLIENT_END; j += 2) { | ||
674 | if ((forces[kind][j] == adap_id || | ||
675 | forces[kind][j] == ANY_I2C_BUS) | ||
676 | && forces[kind][j + 1] == addr) { | ||
677 | dev_dbg(&adapter->dev, "found force parameter, " | ||
678 | "addr 0x%02x, kind %u\n", addr, kind); | ||
679 | return kind; | ||
680 | } | ||
681 | } | ||
682 | } | ||
683 | |||
684 | return -1; | ||
685 | } | ||
686 | |||
665 | int i2c_probe(struct i2c_adapter *adapter, | 687 | int i2c_probe(struct i2c_adapter *adapter, |
666 | struct i2c_client_address_data *address_data, | 688 | struct i2c_client_address_data *address_data, |
667 | int (*found_proc) (struct i2c_adapter *, int, int)) | 689 | int (*found_proc) (struct i2c_adapter *, int, int)) |
@@ -683,19 +705,15 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
683 | at all */ | 705 | at all */ |
684 | found = 0; | 706 | found = 0; |
685 | 707 | ||
686 | for (i = 0; !found && (address_data->force[i] != I2C_CLIENT_END); i += 2) { | 708 | if (address_data->forces) { |
687 | if (((adap_id == address_data->force[i]) || | 709 | int kind = i2c_probe_forces(adapter, addr, |
688 | (address_data->force[i] == ANY_I2C_BUS)) && | 710 | address_data->forces); |
689 | (addr == address_data->force[i+1])) { | 711 | if (kind >= 0) { /* force found */ |
690 | dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", | 712 | if ((err = found_proc(adapter, addr, kind))) |
691 | adap_id, addr); | ||
692 | if ((err = found_proc(adapter,addr,0))) | ||
693 | return err; | 713 | return err; |
694 | found = 1; | 714 | continue; |
695 | } | 715 | } |
696 | } | 716 | } |
697 | if (found) | ||
698 | continue; | ||
699 | 717 | ||
700 | /* If this address is in one of the ignores, we can forget about | 718 | /* If this address is in one of the ignores, we can forget about |
701 | it right now */ | 719 | it right now */ |