@@ -189,6 +189,63 @@ static const struct i2c_device_id lm90_id[] = {
189189};
190190MODULE_DEVICE_TABLE (i2c , lm90_id );
191191
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+
192249/*
193250 * Client data (each client gets its own)
194251 */
@@ -199,7 +256,7 @@ struct lm90_data {
199256 char valid ; /* zero until following fields are valid */
200257 unsigned long last_updated ; /* in jiffies */
201258 int kind ;
202- int flags ;
259+ u32 flags ;
203260
204261 u8 config_orig ; /* Original configuration register value */
205262 u16 alert_alarms ; /* Which alarm bits trigger ALERT# */
@@ -1201,39 +1258,10 @@ static int lm90_probe(struct i2c_client *new_client,
12011258
12021259 /* Different devices have different alarm bits triggering the
12031260 * ALERT# output */
1204- switch (data -> kind ) {
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- }
1261+ data -> alert_alarms = lm90_params [data -> kind ].alert_alarms ;
12171262
12181263 /* Set chip capabilities */
1219- if (data -> kind != max6657 && data -> kind != max6659
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 ;
1264+ data -> flags = lm90_params [data -> kind ].flags ;
12371265
12381266 /* Initialize the LM90 chip */
12391267 lm90_init_client (new_client );
0 commit comments