hwmon: (w83791d) Drop unnecessary compare statements
Subsystems (2)
Guenter Roeck
maintainerPATCH v2 1/1 hwmon: (w83791d) Drop unnecessary compare statements
The following build warnings are seen with -Wextra.
w83791d.c: In function store_temp_target:
w83791d.c:858:2: warning: comparison of unsigned expression < 0 is always false w83791d.c: In function store_temp_tolerance:
w83791d.c:920:2: warning: comparison of unsigned expression < 0 is always false
For store_temp_target, accept negative numbers and clamp to >= 0. For store_temp_tolerance, drop the unnecessary comparison.
---
v2: Accept negative values in store_temp_target and clamp to >= 0.
drivers/hwmon/w83791d.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/hwmon/w83791d.c +3 -4
@@ -259,8 +259,7 @@ static u8 fan_to_reg(long rpm, int div) ((val) + 500) / 1000)/* for thermal cruise temp tolerance, 4-bits, LSB = 1 degree Celsius */ -#define TOL_TEMP_TO_REG (val) ((val) < 0 ? 0 : \ - (val) >= 15000 ? 15 : \ +#define TOL_TEMP_TO_REG (val) ((val) >= 15000 ? 15 : \ ((val) + 500) / 1000)#define BEEP_MASK_TO_REG (val) ((val) & 0xffffff)
@@ -848,10 +847,10 @@ static ssize_t store_temp_target(struct device *dev,struct i2c_client *client =to_i2c_client (dev);struct w83791d_data *data =i2c_get_clientdata (client);int nr = sensor_attr->index; -unsigned long val; +long val;u8 target_mask; -if (kstrtoul (buf,10 , &val)) +if (kstrtol (buf,10 , &val))return -EINVAL ;mutex_lock (&data->update_lock);
Signature · 7 lines
1.7.9.7 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 34 lines · Guenter Roeck
The following build warnings are seen with -Wextra.
w83791d.c: In functionstore_temp_target:
w83791d.c:858:2: warning: comparison of unsigned expression < 0 is always falsew83791d.c: In functionstore_temp_tolerance:
w83791d.c:920:2: warning: comparison of unsigned expression < 0 is always falseFor
store_temp_target, accept negative numbers and clamp to >= 0. Forstore_temp_tolerance, drop the unnecessary comparison.Signed-off-by Guenter Roeck <[email protected]>---
v2: Accept negative values instore_temp_targetand clamp to >= 0.drivers/hwmon/w83791d.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/hwmon/w83791d.c +1
-2@@ -259,8 +259,7 @@ static u8 fan_to_reg(long rpm, int div) ((val) + 500) / 1000)/* for thermal cruise temp tolerance, 4-bits, LSB = 1 degree Celsius */ -#define TOL_TEMP_TO_REG (val) ((val) < 0 ? 0 : \ - (val) >= 15000 ? 15 : \ +#define TOL_TEMP_TO_REG (val) ((val) >= 15000 ? 15 : \ ((val) + 500) / 1000)#define BEEP_MASK_TO_REG (val) ((val) & 0xffffff)@@ -848,10 +847,10 @@ static ssize_t store_temp_target(struct device *dev,struct i2c_client *client =to_i2c_client (dev);struct w83791d_data *data =i2c_get_clientdata (client);
drivers/hwmon/w83791d.c static ssize_t store_temp_target(struct device *dev, · line 856
Quoted 10 lines
drivers/hwmon/w83791d.c +2
-2int nr = sensor_attr->index; -unsigned long val; +long val;u8 target_mask; -if (kstrtoul (buf,10 , &val)) +if (kstrtol (buf,10 , &val))return -EINVAL ;mutex_lock (&data->update_lock);
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors