diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2010-10-28 14:31:43 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2010-10-28 14:31:43 -0400 |
commit | 4667bcb8d8fc081a804a798df70dc91241946e0a (patch) | |
tree | e04d375e9354fe65e6436c5b2f0651501f81e207 /drivers/hwmon/lm90.c | |
parent | 15b66ab69051c014d0ba9f46f7081a8a7e6ad1c3 (diff) |
hwmon: (lm90) Introduce chip parameter structure
Instead of using switch/case and if statements in probe, define chip specific
functionality in a parameter structure array.
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r-- | drivers/hwmon/lm90.c | 92 |
1 files changed, 60 insertions, 32 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 302d9eb9f275..9df08e1cc518 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -190,6 +190,63 @@ static const struct i2c_device_id lm90_id[] = { | |||
190 | MODULE_DEVICE_TABLE(i2c, lm90_id); | 190 | MODULE_DEVICE_TABLE(i2c, lm90_id); |
191 | 191 | ||
192 | /* | 192 | /* |
193 | * chip type specific parameters | ||
194 | */ | ||
195 | struct lm90_params { | ||
196 | u32 flags; /* Capabilities */ | ||
197 | u16 alert_alarms; /* Which alarm bits trigger ALERT# */ | ||
198 | /* Upper 8 bits for max6695/96 */ | ||
199 | }; | ||
200 | |||
201 | static const struct lm90_params lm90_params[] = { | ||
202 | [adm1032] = { | ||
203 | .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, | ||
204 | .alert_alarms = 0x7c, | ||
205 | }, | ||
206 | [adt7461] = { | ||
207 | .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, | ||
208 | .alert_alarms = 0x7c, | ||
209 | }, | ||
210 | [lm86] = { | ||
211 | .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, | ||
212 | .alert_alarms = 0x7b, | ||
213 | }, | ||
214 | [lm90] = { | ||
215 | .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, | ||
216 | .alert_alarms = 0x7b, | ||
217 | }, | ||
218 | [lm99] = { | ||
219 | .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, | ||
220 | .alert_alarms = 0x7b, | ||
221 | }, | ||
222 | [max6646] = { | ||
223 | .flags = LM90_HAVE_LOCAL_EXT, | ||
224 | .alert_alarms = 0x7c, | ||
225 | }, | ||
226 | [max6657] = { | ||
227 | .flags = LM90_HAVE_LOCAL_EXT, | ||
228 | .alert_alarms = 0x7c, | ||
229 | }, | ||
230 | [max6659] = { | ||
231 | .flags = LM90_HAVE_LOCAL_EXT | LM90_HAVE_EMERGENCY, | ||
232 | .alert_alarms = 0x7c, | ||
233 | }, | ||
234 | [max6680] = { | ||
235 | .flags = LM90_HAVE_OFFSET, | ||
236 | .alert_alarms = 0x7c, | ||
237 | }, | ||
238 | [max6696] = { | ||
239 | .flags = LM90_HAVE_LOCAL_EXT | LM90_HAVE_EMERGENCY | ||
240 | | LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3, | ||
241 | .alert_alarms = 0x187c, | ||
242 | }, | ||
243 | [w83l771] = { | ||
244 | .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT, | ||
245 | .alert_alarms = 0x7c, | ||
246 | }, | ||
247 | }; | ||
248 | |||
249 | /* | ||
193 | * Client data (each client gets its own) | 250 | * Client data (each client gets its own) |
194 | */ | 251 | */ |
195 | 252 | ||
@@ -199,7 +256,7 @@ struct lm90_data { | |||
199 | char valid; /* zero until following fields are valid */ | 256 | char valid; /* zero until following fields are valid */ |
200 | unsigned long last_updated; /* in jiffies */ | 257 | unsigned long last_updated; /* in jiffies */ |
201 | int kind; | 258 | int kind; |
202 | int flags; | 259 | u32 flags; |
203 | 260 | ||
204 | u8 config_orig; /* Original configuration register value */ | 261 | u8 config_orig; /* Original configuration register value */ |
205 | u16 alert_alarms; /* Which alarm bits trigger ALERT# */ | 262 | u16 alert_alarms; /* Which alarm bits trigger ALERT# */ |
@@ -1201,39 +1258,10 @@ static int lm90_probe(struct i2c_client *new_client, | |||
1201 | 1258 | ||
1202 | /* Different devices have different alarm bits triggering the | 1259 | /* Different devices have different alarm bits triggering the |
1203 | * ALERT# output */ | 1260 | * ALERT# output */ |
1204 | switch (data->kind) { | 1261 | data->alert_alarms = lm90_params[data->kind].alert_alarms; |
1205 | case lm90: | ||
1206 | case lm99: | ||
1207 | case lm86: | ||
1208 | data->alert_alarms = 0x7b; | ||
1209 | break; | ||
1210 | case max6696: | ||
1211 | data->alert_alarms = 0x187c; | ||
1212 | break; | ||
1213 | default: | ||
1214 | data->alert_alarms = 0x7c; | ||
1215 | break; | ||
1216 | } | ||
1217 | 1262 | ||
1218 | /* Set chip capabilities */ | 1263 | /* Set chip capabilities */ |
1219 | if (data->kind != max6657 && data->kind != max6659 | 1264 | data->flags = lm90_params[data->kind].flags; |
1220 | && data->kind != max6646 && data->kind != max6696) | ||
1221 | data->flags |= LM90_HAVE_OFFSET; | ||
1222 | |||
1223 | if (data->kind == max6657 || data->kind == max6659 | ||
1224 | || data->kind == max6646 || data->kind == max6696) | ||
1225 | data->flags |= LM90_HAVE_LOCAL_EXT; | ||
1226 | |||
1227 | if (data->kind != max6657 && data->kind != max6659 | ||
1228 | && data->kind != max6646 && data->kind != max6680 | ||
1229 | && data->kind != max6696) | ||
1230 | data->flags |= LM90_HAVE_REM_LIMIT_EXT; | ||
1231 | |||
1232 | if (data->kind == max6659 || data->kind == max6696) | ||
1233 | data->flags |= LM90_HAVE_EMERGENCY; | ||
1234 | |||
1235 | if (data->kind == max6696) | ||
1236 | data->flags |= LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3; | ||
1237 | 1265 | ||
1238 | /* Initialize the LM90 chip */ | 1266 | /* Initialize the LM90 chip */ |
1239 | lm90_init_client(new_client); | 1267 | lm90_init_client(new_client); |