Skip to content

Commit ec1d222

Browse files
groeckgregkh
authored andcommitted
hwmom: (lm90) Fix citical alarm status for MAX6680/MAX6681
commit da7dc05 upstream. Tests with a real chip and a closer look into the datasheet reveals that the local and remote critical alarm status bits are swapped for MAX6680/MAX6681. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 441d387 commit ec1d222

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎drivers/hwmon/lm90.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
190190
#define LM90_HAVE_EXTENDED_TEMP (1 << 8) /* extended temperature support*/
191191
#define LM90_PAUSE_FOR_CONFIG (1 << 9) /* Pause conversion for config */
192192
#define LM90_HAVE_CRIT (1 << 10)/* Chip supports CRIT/OVERT register */
193+
#define LM90_HAVE_CRIT_ALRM_SWP (1 << 11)/* critical alarm bits swapped */
193194

194195
/* LM90 status */
195196
#define LM90_STATUS_LTHRM (1 << 0) /* local THERM limit tripped */
@@ -415,7 +416,8 @@ static const struct lm90_params lm90_params[] = {
415416
.reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
416417
},
417418
[max6680] = {
418-
.flags = LM90_HAVE_OFFSET | LM90_HAVE_CRIT,
419+
.flags = LM90_HAVE_OFFSET | LM90_HAVE_CRIT
420+
| LM90_HAVE_CRIT_ALRM_SWP,
419421
.alert_alarms = 0x7c,
420422
.max_convrate = 7,
421423
},
@@ -1191,6 +1193,7 @@ static const u8 lm90_temp_emerg_index[3] = {
11911193
static const u8 lm90_min_alarm_bits[3] = { 5, 3, 11 };
11921194
static const u8 lm90_max_alarm_bits[3] = { 6, 4, 12 };
11931195
static const u8 lm90_crit_alarm_bits[3] = { 0, 1, 9 };
1196+
static const u8 lm90_crit_alarm_bits_swapped[3] = { 1, 0, 9 };
11941197
static const u8 lm90_emergency_alarm_bits[3] = { 15, 13, 14 };
11951198
static const u8 lm90_fault_bits[3] = { 0, 2, 10 };
11961199

@@ -1216,7 +1219,10 @@ static int lm90_temp_read(struct device *dev, u32 attr, int channel, long *val)
12161219
*val = (data->alarms >> lm90_max_alarm_bits[channel]) & 1;
12171220
break;
12181221
case hwmon_temp_crit_alarm:
1219-
*val = (data->alarms >> lm90_crit_alarm_bits[channel]) & 1;
1222+
if (data->flags & LM90_HAVE_CRIT_ALRM_SWP)
1223+
*val = (data->alarms >> lm90_crit_alarm_bits_swapped[channel]) & 1;
1224+
else
1225+
*val = (data->alarms >> lm90_crit_alarm_bits[channel]) & 1;
12201226
break;
12211227
case hwmon_temp_emergency_alarm:
12221228
*val = (data->alarms >> lm90_emergency_alarm_bits[channel]) & 1;

0 commit comments

Comments
 (0)