aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/Makefile2
-rw-r--r--drivers/i2c/i2c-sensor-detect.c125
-rw-r--r--drivers/i2c/i2c-sensor-vid.c5
3 files changed, 6 insertions, 126 deletions
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index cd170395a8c7..71d68ad0e5ce 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -7,7 +7,7 @@ obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o
7obj-$(CONFIG_I2C_SENSOR) += i2c-sensor.o 7obj-$(CONFIG_I2C_SENSOR) += i2c-sensor.o
8obj-y += busses/ chips/ algos/ 8obj-y += busses/ chips/ algos/
9 9
10i2c-sensor-objs := i2c-sensor-detect.o i2c-sensor-vid.o 10i2c-sensor-objs := i2c-sensor-vid.o
11 11
12 12
13ifeq ($(CONFIG_I2C_DEBUG_CORE),y) 13ifeq ($(CONFIG_I2C_DEBUG_CORE),y)
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 @@
1/*
2 i2c-sensor-detect.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1998 - 2001 Frodo Looijaard <frodol@dds.nl> and
5 Mark D. Studebaker <mdsxyz123@yahoo.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include <linux/module.h>
23#include <linux/kernel.h>
24#include <linux/i2c.h>
25#include <linux/i2c-sensor.h>
26
27static unsigned short empty[] = {I2C_CLIENT_END};
28
29/* Won't work for 10-bit addresses! */
30int i2c_detect(struct i2c_adapter *adapter,
31 struct i2c_client_address_data *address_data,
32 int (*found_proc) (struct i2c_adapter *, int, int))
33{
34 int addr, i, found, j, err;
35 int adapter_id = i2c_adapter_id(adapter);
36 unsigned short *normal_i2c;
37 unsigned short *probe;
38 unsigned short *ignore;
39
40 /* Forget it if we can't probe using SMBUS_QUICK */
41 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK))
42 return -1;
43
44 /* Use default "empty" list if the adapter doesn't specify any */
45 normal_i2c = probe = ignore = empty;
46 if (address_data->normal_i2c)
47 normal_i2c = address_data->normal_i2c;
48 if (address_data->probe)
49 probe = address_data->probe;
50 if (address_data->ignore)
51 ignore = address_data->ignore;
52
53 for (addr = 0x00; addr <= 0x7f; addr++) {
54 if (i2c_check_addr(adapter, addr))
55 continue;
56
57 /* If it is in one of the force entries, we don't do any
58 detection at all */
59 found = 0;
60 for (i = 0; address_data->forces[i]; i++) {
61 for (j = 0; !found && (address_data->forces[i][j] != I2C_CLIENT_END); j += 2) {
62 if ( ((adapter_id == address_data->forces[i][j]) ||
63 (address_data->forces[i][j] == ANY_I2C_BUS)) &&
64 (addr == address_data->forces[i][j + 1]) ) {
65 dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr);
66 if ((err = found_proc(adapter, addr, i)))
67 return err;
68 found = 1;
69 }
70 }
71 }
72 if (found)
73 continue;
74
75 /* If this address is in one of the ignores, we can forget about it
76 right now */
77 for (i = 0; !found && (ignore[i] != I2C_CLIENT_END); i += 2) {
78 if ( ((adapter_id == ignore[i]) ||
79 (ignore[i] == ANY_I2C_BUS)) &&
80 (addr == ignore[i + 1])) {
81 dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr);
82 found = 1;
83 }
84 }
85 if (found)
86 continue;
87
88 /* Now, we will do a detection, but only if it is in the normal or
89 probe entries */
90 for (i = 0; !found && (normal_i2c[i] != I2C_CLIENT_END); i += 1) {
91 if (addr == normal_i2c[i]) {
92 found = 1;
93 dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x\n", adapter_id, addr);
94 }
95 }
96
97 for (i = 0;
98 !found && (probe[i] != I2C_CLIENT_END);
99 i += 2) {
100 if (((adapter_id == probe[i]) ||
101 (probe[i] == ANY_I2C_BUS))
102 && (addr == probe[i + 1])) {
103 dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
104 found = 1;
105 }
106 }
107 if (!found)
108 continue;
109
110 /* OK, so we really should examine this address. First check
111 whether there is some client here at all! */
112 if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0)
113 if ((err = found_proc(adapter, addr, -1)))
114 return err;
115 }
116 return 0;
117}
118
119EXPORT_SYMBOL(i2c_detect);
120
121MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
122 "Rudolf Marek <r.marek@sh.cvut.cz>");
123
124MODULE_DESCRIPTION("i2c-sensor driver");
125MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/i2c-sensor-vid.c b/drivers/i2c/i2c-sensor-vid.c
index 922e22f054bb..b8ef289fc80e 100644
--- a/drivers/i2c/i2c-sensor-vid.c
+++ b/drivers/i2c/i2c-sensor-vid.c
@@ -96,3 +96,8 @@ int i2c_which_vrm(void)
96#endif 96#endif
97 97
98EXPORT_SYMBOL(i2c_which_vrm); 98EXPORT_SYMBOL(i2c_which_vrm);
99
100MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>");
101
102MODULE_DESCRIPTION("i2c-sensor driver");
103MODULE_LICENSE("GPL");