summaryrefslogtreecommitdiff
path: root/drivers/hwmon/lm90.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2021-11-22 08:13:58 -0800
committerGuenter Roeck <linux@roeck-us.net>2022-07-13 08:38:17 -0700
commitb977ed27c4dbbb65eb6c00a3bd89e5907d4c2042 (patch)
tree2cbf4eedbcb4bcf8a93e65efe5e6439d02fc251c /drivers/hwmon/lm90.c
parenta8ddcc5750a94527ceead3de59f1f6ebc3e58115 (diff)
hwmon: (lm90) Use single flag to indicate extended temperature support
Since temperature conversion functions are now unified, there is no need to keep "the chip supports a configurable extended temperature range" and "the chip has extended temperature range enabled" flags separate. Use a single flag instead to reflect both. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r--drivers/hwmon/lm90.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index f162391eafc2..9c0ad8217dd1 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -164,11 +164,8 @@ enum chips { adm1032, adt7461, adt7461a, g781, lm86, lm90, lm99,
#define TMP461_REG_CHEN 0x16
#define TMP461_REG_DFC 0x24
-/*
- * Device flags
- */
-#define LM90_FLAG_ADT7461_EXT BIT(0) /* ADT7461 extended mode */
/* Device features */
+#define LM90_HAVE_EXTENDED_TEMP BIT(0) /* extended temperature support */
#define LM90_HAVE_OFFSET BIT(1) /* temperature offset register */
#define LM90_HAVE_UNSIGNED_TEMP BIT(2) /* temperatures are unsigned */
#define LM90_HAVE_REM_LIMIT_EXT BIT(3) /* extended remote limit */
@@ -176,12 +173,11 @@ enum chips { adm1032, adt7461, adt7461a, g781, lm86, lm90, lm99,
#define LM90_HAVE_EMERGENCY_ALARM BIT(5)/* emergency alarm */
#define LM90_HAVE_TEMP3 BIT(6) /* 3rd temperature sensor */
#define LM90_HAVE_BROKEN_ALERT BIT(7) /* Broken alert */
-#define LM90_HAVE_EXTENDED_TEMP BIT(8) /* extended temperature support */
-#define LM90_PAUSE_FOR_CONFIG BIT(9) /* Pause conversion for config */
-#define LM90_HAVE_CRIT BIT(10) /* Chip supports CRIT/OVERT register */
-#define LM90_HAVE_CRIT_ALRM_SWP BIT(11) /* critical alarm bits swapped */
-#define LM90_HAVE_PEC BIT(12) /* Chip supports PEC */
-#define LM90_HAVE_PARTIAL_PEC BIT(13) /* Partial PEC support (adm1032)*/
+#define LM90_PAUSE_FOR_CONFIG BIT(8) /* Pause conversion for config */
+#define LM90_HAVE_CRIT BIT(9) /* Chip supports CRIT/OVERT register */
+#define LM90_HAVE_CRIT_ALRM_SWP BIT(10) /* critical alarm bits swapped */
+#define LM90_HAVE_PEC BIT(11) /* Chip supports PEC */
+#define LM90_HAVE_PARTIAL_PEC BIT(12) /* Partial PEC support (adm1032)*/
/* LM90 status */
#define LM90_STATUS_LTHRM BIT(0) /* local THERM limit tripped */
@@ -1109,7 +1105,7 @@ static int lm90_temp_from_reg(u32 flags, u16 regval, u8 resolution)
{
int val;
- if (flags & LM90_FLAG_ADT7461_EXT)
+ if (flags & LM90_HAVE_EXTENDED_TEMP)
val = regval - 0x4000;
else if (flags & LM90_HAVE_UNSIGNED_TEMP)
val = regval;
@@ -1136,7 +1132,7 @@ static u16 lm90_temp_to_reg(u32 flags, long val, u8 resolution)
int fraction = resolution > 8 ?
1000 - DIV_ROUND_CLOSEST(1000, BIT(resolution - 8)) : 0;
- if (flags & LM90_FLAG_ADT7461_EXT) {
+ if (flags & LM90_HAVE_EXTENDED_TEMP) {
val = clamp_val(val, -64000, 191000 + fraction);
val += 64000;
} else if (flags & LM90_HAVE_UNSIGNED_TEMP) {
@@ -1766,9 +1762,8 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
if (data->flags & LM90_HAVE_EXTENDED_TEMP) {
if (of_property_read_bool(np, "ti,extended-range-enable"))
config |= 0x04;
-
- if (config & 0x04)
- data->flags |= LM90_FLAG_ADT7461_EXT;
+ if (!(config & 0x04))
+ data->flags &= ~LM90_HAVE_EXTENDED_TEMP;
}
/*