diff options
author | Jean Delvare <khali@linux-fr.org> | 2012-07-26 16:13:47 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-27 16:59:22 -0400 |
commit | 2ccc8731e5054058d5fb990744b4f72a79018d34 (patch) | |
tree | 10f493b1ba750d43f61657232cc217721a94fb79 /drivers/hwmon/jc42.c | |
parent | 9baeb8fdd7e1e78973ad19a6d7e2bcf7dfeb2498 (diff) |
hwmon: (jc42) Simplify hysteresis mask
Define JC42_CFG_HYST_MASK as the mask _before_ shifting instead of
after shifting. This simplifies the current code slightly, and will
simplify the code to come even more.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/jc42.c')
-rw-r--r-- | drivers/hwmon/jc42.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c index e72ba5d2a824..44f189ed414a 100644 --- a/drivers/hwmon/jc42.c +++ b/drivers/hwmon/jc42.c | |||
@@ -57,7 +57,7 @@ static const unsigned short normal_i2c[] = { | |||
57 | #define JC42_CFG_EVENT_LOCK (1 << 7) | 57 | #define JC42_CFG_EVENT_LOCK (1 << 7) |
58 | #define JC42_CFG_SHUTDOWN (1 << 8) | 58 | #define JC42_CFG_SHUTDOWN (1 << 8) |
59 | #define JC42_CFG_HYST_SHIFT 9 | 59 | #define JC42_CFG_HYST_SHIFT 9 |
60 | #define JC42_CFG_HYST_MASK 0x03 | 60 | #define JC42_CFG_HYST_MASK (0x03 << 9) |
61 | 61 | ||
62 | /* Capabilities */ | 62 | /* Capabilities */ |
63 | #define JC42_CAP_RANGE (1 << 2) | 63 | #define JC42_CAP_RANGE (1 << 2) |
@@ -287,8 +287,8 @@ static ssize_t show_temp_crit_hyst(struct device *dev, | |||
287 | return PTR_ERR(data); | 287 | return PTR_ERR(data); |
288 | 288 | ||
289 | temp = jc42_temp_from_reg(data->temp_crit); | 289 | temp = jc42_temp_from_reg(data->temp_crit); |
290 | hyst = jc42_hysteresis[(data->config >> JC42_CFG_HYST_SHIFT) | 290 | hyst = jc42_hysteresis[(data->config & JC42_CFG_HYST_MASK) |
291 | & JC42_CFG_HYST_MASK]; | 291 | >> JC42_CFG_HYST_SHIFT]; |
292 | return sprintf(buf, "%d\n", temp - hyst); | 292 | return sprintf(buf, "%d\n", temp - hyst); |
293 | } | 293 | } |
294 | 294 | ||
@@ -302,8 +302,8 @@ static ssize_t show_temp_max_hyst(struct device *dev, | |||
302 | return PTR_ERR(data); | 302 | return PTR_ERR(data); |
303 | 303 | ||
304 | temp = jc42_temp_from_reg(data->temp_max); | 304 | temp = jc42_temp_from_reg(data->temp_max); |
305 | hyst = jc42_hysteresis[(data->config >> JC42_CFG_HYST_SHIFT) | 305 | hyst = jc42_hysteresis[(data->config & JC42_CFG_HYST_MASK) |
306 | & JC42_CFG_HYST_MASK]; | 306 | >> JC42_CFG_HYST_SHIFT]; |
307 | return sprintf(buf, "%d\n", temp - hyst); | 307 | return sprintf(buf, "%d\n", temp - hyst); |
308 | } | 308 | } |
309 | 309 | ||
@@ -362,8 +362,7 @@ static ssize_t set_temp_crit_hyst(struct device *dev, | |||
362 | } | 362 | } |
363 | 363 | ||
364 | mutex_lock(&data->update_lock); | 364 | mutex_lock(&data->update_lock); |
365 | data->config = (data->config | 365 | data->config = (data->config & ~JC42_CFG_HYST_MASK) |
366 | & ~(JC42_CFG_HYST_MASK << JC42_CFG_HYST_SHIFT)) | ||
367 | | (hyst << JC42_CFG_HYST_SHIFT); | 366 | | (hyst << JC42_CFG_HYST_SHIFT); |
368 | err = i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, | 367 | err = i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, |
369 | data->config); | 368 | data->config); |