Commit eb02755a authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare

hwmon: (w83795) More style cleanups

Cleanups suggested by Guenter Roeck, falling into 4 categories:
* Swapping test orders, because if (var == CONSTANT) is much easier to
  read than if (CONSTANT == var).
* Simplifying comparisons with 0.
* Dropping unneeded masks.
* Dropping unneeded parentheses and curly braces.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Acked-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
parent 5d2cd958
...@@ -491,7 +491,7 @@ static void w83795_update_limits(struct i2c_client *client) ...@@ -491,7 +491,7 @@ static void w83795_update_limits(struct i2c_client *client)
} }
/* Read the DTS limits */ /* Read the DTS limits */
if (data->enable_dts != 0) { if (data->enable_dts) {
for (limit = DTS_CRIT; limit <= DTS_WARN_HYST; limit++) for (limit = DTS_CRIT; limit <= DTS_WARN_HYST; limit++)
data->dts_ext[limit] = data->dts_ext[limit] =
w83795_read(client, W83795_REG_DTS_EXT(limit)); w83795_read(client, W83795_REG_DTS_EXT(limit));
...@@ -544,7 +544,7 @@ static struct w83795_data *w83795_update_pwm_config(struct device *dev) ...@@ -544,7 +544,7 @@ static struct w83795_data *w83795_update_pwm_config(struct device *dev)
data->pwm_temp[i][TEMP_PWM_CTFS] = data->pwm_temp[i][TEMP_PWM_CTFS] =
w83795_read(client, W83795_REG_CTFS(i)); w83795_read(client, W83795_REG_CTFS(i));
tmp = w83795_read(client, W83795_REG_HT(i)); tmp = w83795_read(client, W83795_REG_HT(i));
data->pwm_temp[i][TEMP_PWM_HCT] = (tmp >> 4) & 0x0f; data->pwm_temp[i][TEMP_PWM_HCT] = tmp >> 4;
data->pwm_temp[i][TEMP_PWM_HOT] = tmp & 0x0f; data->pwm_temp[i][TEMP_PWM_HOT] = tmp & 0x0f;
} }
...@@ -618,8 +618,7 @@ static struct w83795_data *w83795_update_device(struct device *dev) ...@@ -618,8 +618,7 @@ static struct w83795_data *w83795_update_device(struct device *dev)
if (!(data->has_fan & (1 << i))) if (!(data->has_fan & (1 << i)))
continue; continue;
data->fan[i] = w83795_read(client, W83795_REG_FAN(i)) << 4; data->fan[i] = w83795_read(client, W83795_REG_FAN(i)) << 4;
data->fan[i] |= data->fan[i] |= w83795_read(client, W83795_REG_VRLSB) >> 4;
(w83795_read(client, W83795_REG_VRLSB) >> 4) & 0x0F;
} }
/* Update temperature */ /* Update temperature */
...@@ -631,7 +630,7 @@ static struct w83795_data *w83795_update_device(struct device *dev) ...@@ -631,7 +630,7 @@ static struct w83795_data *w83795_update_device(struct device *dev)
} }
/* Update dts temperature */ /* Update dts temperature */
if (data->enable_dts != 0) { if (data->enable_dts) {
for (i = 0; i < ARRAY_SIZE(data->dts); i++) { for (i = 0; i < ARRAY_SIZE(data->dts); i++) {
if (!(data->has_dts & (1 << i))) if (!(data->has_dts & (1 << i)))
continue; continue;
...@@ -677,11 +676,10 @@ show_alarm_beep(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -677,11 +676,10 @@ show_alarm_beep(struct device *dev, struct device_attribute *attr, char *buf)
int bit = sensor_attr->index & 0x07; int bit = sensor_attr->index & 0x07;
u8 val; u8 val;
if (ALARM_STATUS == nr) { if (nr == ALARM_STATUS)
val = (data->alarms[index] >> (bit)) & 1; val = (data->alarms[index] >> bit) & 1;
} else { /* BEEP_ENABLE */ else /* BEEP_ENABLE */
val = (data->beeps[index] >> (bit)) & 1; val = (data->beeps[index] >> bit) & 1;
}
return sprintf(buf, "%u\n", val); return sprintf(buf, "%u\n", val);
} }
...@@ -744,7 +742,7 @@ show_fan(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -744,7 +742,7 @@ show_fan(struct device *dev, struct device_attribute *attr, char *buf)
struct w83795_data *data = w83795_update_device(dev); struct w83795_data *data = w83795_update_device(dev);
u16 val; u16 val;
if (FAN_INPUT == nr) if (nr == FAN_INPUT)
val = data->fan[index] & 0x0fff; val = data->fan[index] & 0x0fff;
else else
val = data->fan_min[index] & 0x0fff; val = data->fan_min[index] & 0x0fff;
...@@ -1011,7 +1009,7 @@ store_temp_pwm_enable(struct device *dev, struct device_attribute *attr, ...@@ -1011,7 +1009,7 @@ store_temp_pwm_enable(struct device *dev, struct device_attribute *attr,
switch (nr) { switch (nr) {
case TEMP_PWM_ENABLE: case TEMP_PWM_ENABLE:
if ((tmp != 3) && (tmp != 4)) if (tmp != 3 && tmp != 4)
return -EINVAL; return -EINVAL;
tmp -= 3; tmp -= 3;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
...@@ -1074,7 +1072,7 @@ store_fanin(struct device *dev, struct device_attribute *attr, ...@@ -1074,7 +1072,7 @@ store_fanin(struct device *dev, struct device_attribute *attr,
switch (nr) { switch (nr) {
case FANIN_TARGET: case FANIN_TARGET:
val = fan_to_reg(SENSORS_LIMIT(val, 0, 0xfff)); val = fan_to_reg(SENSORS_LIMIT(val, 0, 0xfff));
w83795_write(client, W83795_REG_FTSH(index), (val >> 4) & 0xff); w83795_write(client, W83795_REG_FTSH(index), val >> 4);
w83795_write(client, W83795_REG_FTSL(index), (val << 4) & 0xf0); w83795_write(client, W83795_REG_FTSL(index), (val << 4) & 0xf0);
data->target_speed[index] = val; data->target_speed[index] = val;
break; break;
...@@ -1234,7 +1232,7 @@ show_temp(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1234,7 +1232,7 @@ show_temp(struct device *dev, struct device_attribute *attr, char *buf)
struct w83795_data *data = w83795_update_device(dev); struct w83795_data *data = w83795_update_device(dev);
long temp = temp_from_reg(data->temp[index][nr]); long temp = temp_from_reg(data->temp[index][nr]);
if (TEMP_READ == nr) if (nr == TEMP_READ)
temp += (data->temp_read_vrlsb[index] >> 6) * 250; temp += (data->temp_read_vrlsb[index] >> 6) * 250;
return sprintf(buf, "%ld\n", temp); return sprintf(buf, "%ld\n", temp);
} }
...@@ -1891,7 +1889,7 @@ static int w83795_handle_files(struct device *dev, int (*fn)(struct device *, ...@@ -1891,7 +1889,7 @@ static int w83795_handle_files(struct device *dev, int (*fn)(struct device *,
} }
} }
if (data->enable_dts != 0) { if (data->enable_dts) {
for (i = 0; i < ARRAY_SIZE(w83795_dts); i++) { for (i = 0; i < ARRAY_SIZE(w83795_dts); i++) {
if (!(data->has_dts & (1 << i))) if (!(data->has_dts & (1 << i)))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment