aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2005-07-31 15:33:23 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 12:14:18 -0400
commitef8dec5d8b3e96e359f377f35cd8caff42fe6d58 (patch)
treeca83d278af5da3dfc9ef01f1d5bf479e67229d25 /include/linux
parent9fc6adfa9adf2be84119a3c2592287f33bd1dff2 (diff)
[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 <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/i2c-sensor.h133
1 files changed, 61 insertions, 72 deletions
diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h
index e832d3286a46..4facaa0b9054 100644
--- a/include/linux/i2c-sensor.h
+++ b/include/linux/i2c-sensor.h
@@ -22,22 +22,6 @@
22#ifndef _LINUX_I2C_SENSOR_H 22#ifndef _LINUX_I2C_SENSOR_H
23#define _LINUX_I2C_SENSOR_H 23#define _LINUX_I2C_SENSOR_H
24 24
25/* A structure containing detect information.
26 Force variables overrule all other variables; they force a detection on
27 that place. If a specific chip is given, the module blindly assumes this
28 chip type is present; if a general force (kind == 0) is given, the module
29 will still try to figure out what type of chip is present. This is useful
30 if for some reasons the detect for SMBus address space filled fails.
31 probe: insmod parameter. Initialize this list with I2C_CLIENT_END values.
32 A list of pairs. The first value is a bus number (ANY_I2C_BUS for any
33 I2C bus), the second is the address.
34 kind: The kind of chip. 0 equals any chip.
35*/
36struct i2c_force_data {
37 unsigned short *force;
38 unsigned short kind;
39};
40
41/* A structure containing the detect information. 25/* A structure containing the detect information.
42 normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_END. 26 normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_END.
43 A list of I2C addresses which should normally be examined. 27 A list of I2C addresses which should normally be examined.
@@ -50,14 +34,18 @@ struct i2c_force_data {
50 I2C bus), the second is the I2C address. These addresses are never 34 I2C bus), the second is the I2C address. These addresses are never
51 probed. This parameter overrules 'normal' and probe', but not the 35 probed. This parameter overrules 'normal' and probe', but not the
52 'force' lists. 36 'force' lists.
53 force_data: insmod parameters. A list, ending with an element of which 37 forces: insmod parameters. A list, ending with a NULL element.
54 the force field is NULL. 38 Force variables overrule all other variables; they force a detection on
39 that place. If a specific chip is given, the module blindly assumes this
40 chip type is present; if a general force (kind == 0) is given, the module
41 will still try to figure out what type of chip is present. This is useful
42 if for some reasons the detect for SMBus address space filled fails.
55*/ 43*/
56struct i2c_address_data { 44struct i2c_address_data {
57 unsigned short *normal_i2c; 45 unsigned short *normal_i2c;
58 unsigned short *probe; 46 unsigned short *probe;
59 unsigned short *ignore; 47 unsigned short *ignore;
60 struct i2c_force_data *forces; 48 unsigned short **forces;
61}; 49};
62 50
63#define SENSORS_MODULE_PARM_FORCE(name) \ 51#define SENSORS_MODULE_PARM_FORCE(name) \
@@ -88,7 +76,8 @@ struct i2c_address_data {
88 I2C_CLIENT_MODULE_PARM(force, \ 76 I2C_CLIENT_MODULE_PARM(force, \
89 "List of adapter,address pairs to boldly assume " \ 77 "List of adapter,address pairs to boldly assume " \
90 "to be present"); \ 78 "to be present"); \
91 static struct i2c_force_data forces[] = {{force,any_chip},{NULL}}; \ 79 static unsigned short *forces[] = { force, \
80 NULL }; \
92 SENSORS_INSMOD 81 SENSORS_INSMOD
93 82
94#define SENSORS_INSMOD_1(chip1) \ 83#define SENSORS_INSMOD_1(chip1) \
@@ -97,9 +86,9 @@ struct i2c_address_data {
97 "List of adapter,address pairs to boldly assume " \ 86 "List of adapter,address pairs to boldly assume " \
98 "to be present"); \ 87 "to be present"); \
99 SENSORS_MODULE_PARM_FORCE(chip1); \ 88 SENSORS_MODULE_PARM_FORCE(chip1); \
100 static struct i2c_force_data forces[] = {{force,any_chip},\ 89 static unsigned short *forces[] = { force, \
101 {force_ ## chip1,chip1}, \ 90 force_##chip1, \
102 {NULL}}; \ 91 NULL }; \
103 SENSORS_INSMOD 92 SENSORS_INSMOD
104 93
105#define SENSORS_INSMOD_2(chip1,chip2) \ 94#define SENSORS_INSMOD_2(chip1,chip2) \
@@ -109,10 +98,10 @@ struct i2c_address_data {
109 "to be present"); \ 98 "to be present"); \
110 SENSORS_MODULE_PARM_FORCE(chip1); \ 99 SENSORS_MODULE_PARM_FORCE(chip1); \
111 SENSORS_MODULE_PARM_FORCE(chip2); \ 100 SENSORS_MODULE_PARM_FORCE(chip2); \
112 static struct i2c_force_data forces[] = {{force,any_chip}, \ 101 static unsigned short *forces[] = { force, \
113 {force_ ## chip1,chip1}, \ 102 force_##chip1, \
114 {force_ ## chip2,chip2}, \ 103 force_##chip2, \
115 {NULL}}; \ 104 NULL }; \
116 SENSORS_INSMOD 105 SENSORS_INSMOD
117 106
118#define SENSORS_INSMOD_3(chip1,chip2,chip3) \ 107#define SENSORS_INSMOD_3(chip1,chip2,chip3) \
@@ -123,11 +112,11 @@ struct i2c_address_data {
123 SENSORS_MODULE_PARM_FORCE(chip1); \ 112 SENSORS_MODULE_PARM_FORCE(chip1); \
124 SENSORS_MODULE_PARM_FORCE(chip2); \ 113 SENSORS_MODULE_PARM_FORCE(chip2); \
125 SENSORS_MODULE_PARM_FORCE(chip3); \ 114 SENSORS_MODULE_PARM_FORCE(chip3); \
126 static struct i2c_force_data forces[] = {{force,any_chip}, \ 115 static unsigned short *forces[] = { force, \
127 {force_ ## chip1,chip1}, \ 116 force_##chip1, \
128 {force_ ## chip2,chip2}, \ 117 force_##chip2, \
129 {force_ ## chip3,chip3}, \ 118 force_##chip3, \
130 {NULL}}; \ 119 NULL }; \
131 SENSORS_INSMOD 120 SENSORS_INSMOD
132 121
133#define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \ 122#define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
@@ -139,12 +128,12 @@ struct i2c_address_data {
139 SENSORS_MODULE_PARM_FORCE(chip2); \ 128 SENSORS_MODULE_PARM_FORCE(chip2); \
140 SENSORS_MODULE_PARM_FORCE(chip3); \ 129 SENSORS_MODULE_PARM_FORCE(chip3); \
141 SENSORS_MODULE_PARM_FORCE(chip4); \ 130 SENSORS_MODULE_PARM_FORCE(chip4); \
142 static struct i2c_force_data forces[] = {{force,any_chip}, \ 131 static unsigned short *forces[] = { force, \
143 {force_ ## chip1,chip1}, \ 132 force_##chip1, \
144 {force_ ## chip2,chip2}, \ 133 force_##chip2, \
145 {force_ ## chip3,chip3}, \ 134 force_##chip3, \
146 {force_ ## chip4,chip4}, \ 135 force_##chip4, \
147 {NULL}}; \ 136 NULL}; \
148 SENSORS_INSMOD 137 SENSORS_INSMOD
149 138
150#define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \ 139#define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
@@ -157,13 +146,13 @@ struct i2c_address_data {
157 SENSORS_MODULE_PARM_FORCE(chip3); \ 146 SENSORS_MODULE_PARM_FORCE(chip3); \
158 SENSORS_MODULE_PARM_FORCE(chip4); \ 147 SENSORS_MODULE_PARM_FORCE(chip4); \
159 SENSORS_MODULE_PARM_FORCE(chip5); \ 148 SENSORS_MODULE_PARM_FORCE(chip5); \
160 static struct i2c_force_data forces[] = {{force,any_chip}, \ 149 static unsigned short *forces[] = { force, \
161 {force_ ## chip1,chip1}, \ 150 force_##chip1, \
162 {force_ ## chip2,chip2}, \ 151 force_##chip2, \
163 {force_ ## chip3,chip3}, \ 152 force_##chip3, \
164 {force_ ## chip4,chip4}, \ 153 force_##chip4, \
165 {force_ ## chip5,chip5}, \ 154 force_##chip5, \
166 {NULL}}; \ 155 NULL }; \
167 SENSORS_INSMOD 156 SENSORS_INSMOD
168 157
169#define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \ 158#define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
@@ -177,14 +166,14 @@ struct i2c_address_data {
177 SENSORS_MODULE_PARM_FORCE(chip4); \ 166 SENSORS_MODULE_PARM_FORCE(chip4); \
178 SENSORS_MODULE_PARM_FORCE(chip5); \ 167 SENSORS_MODULE_PARM_FORCE(chip5); \
179 SENSORS_MODULE_PARM_FORCE(chip6); \ 168 SENSORS_MODULE_PARM_FORCE(chip6); \
180 static struct i2c_force_data forces[] = {{force,any_chip}, \ 169 static unsigned short *forces[] = { force, \
181 {force_ ## chip1,chip1}, \ 170 force_##chip1, \
182 {force_ ## chip2,chip2}, \ 171 force_##chip2, \
183 {force_ ## chip3,chip3}, \ 172 force_##chip3, \
184 {force_ ## chip4,chip4}, \ 173 force_##chip4, \
185 {force_ ## chip5,chip5}, \ 174 force_##chip5, \
186 {force_ ## chip6,chip6}, \ 175 force_##chip6, \
187 {NULL}}; \ 176 NULL }; \
188 SENSORS_INSMOD 177 SENSORS_INSMOD
189 178
190#define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \ 179#define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \
@@ -199,15 +188,15 @@ struct i2c_address_data {
199 SENSORS_MODULE_PARM_FORCE(chip5); \ 188 SENSORS_MODULE_PARM_FORCE(chip5); \
200 SENSORS_MODULE_PARM_FORCE(chip6); \ 189 SENSORS_MODULE_PARM_FORCE(chip6); \
201 SENSORS_MODULE_PARM_FORCE(chip7); \ 190 SENSORS_MODULE_PARM_FORCE(chip7); \
202 static struct i2c_force_data forces[] = {{force,any_chip}, \ 191 static unsigned short *forces[] = { force, \
203 {force_ ## chip1,chip1}, \ 192 force_##chip1, \
204 {force_ ## chip2,chip2}, \ 193 force_##chip2, \
205 {force_ ## chip3,chip3}, \ 194 force_##chip3, \
206 {force_ ## chip4,chip4}, \ 195 force_##chip4, \
207 {force_ ## chip5,chip5}, \ 196 force_##chip5, \
208 {force_ ## chip6,chip6}, \ 197 force_##chip6, \
209 {force_ ## chip7,chip7}, \ 198 force_##chip7, \
210 {NULL}}; \ 199 NULL }; \
211 SENSORS_INSMOD 200 SENSORS_INSMOD
212 201
213#define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \ 202#define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \
@@ -223,16 +212,16 @@ struct i2c_address_data {
223 SENSORS_MODULE_PARM_FORCE(chip6); \ 212 SENSORS_MODULE_PARM_FORCE(chip6); \
224 SENSORS_MODULE_PARM_FORCE(chip7); \ 213 SENSORS_MODULE_PARM_FORCE(chip7); \
225 SENSORS_MODULE_PARM_FORCE(chip8); \ 214 SENSORS_MODULE_PARM_FORCE(chip8); \
226 static struct i2c_force_data forces[] = {{force,any_chip}, \ 215 static unsigned short *forces[] = { force, \
227 {force_ ## chip1,chip1}, \ 216 force_##chip1, \
228 {force_ ## chip2,chip2}, \ 217 force_##chip2, \
229 {force_ ## chip3,chip3}, \ 218 force_##chip3, \
230 {force_ ## chip4,chip4}, \ 219 force_##chip4, \
231 {force_ ## chip5,chip5}, \ 220 force_##chip5, \
232 {force_ ## chip6,chip6}, \ 221 force_##chip6, \
233 {force_ ## chip7,chip7}, \ 222 force_##chip7, \
234 {force_ ## chip8,chip8}, \ 223 force_##chip8, \
235 {NULL}}; \ 224 NULL }; \
236 SENSORS_INSMOD 225 SENSORS_INSMOD
237 226
238/* Detect function. It iterates over all possible addresses itself. For 227/* Detect function. It iterates over all possible addresses itself. For