hwmon: (emc6w201) Fix DIV_ROUND_CLOSEST problem with unsigned divisors
Guenter Roeck
maintainerPATCH v2 1/1 hwmon: (emc6w201) Fix DIV_ROUND_CLOSEST problem with unsigned divisors
Result of DIV_ROUND_CLOSEST is undefined for negative dividends if the divisor variable type is unsigned. Fix by declaring divisor as signed variable.
---
v2: Fix by changing divisor variable type instead of dividend variable type
drivers/hwmon/emc6w201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/emc6w201.c +1 -1
@@ -187,7 +187,7 @@ static struct emc6w201_data *emc6w201_update_device(struct device *dev)* Sysfs callback functions */ -static const u16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 }; +static const s16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 };static ssize_t show_in (struct device *dev,struct device_attribute *devattr,char *buf)
Signature · 7 lines
1.7.9.7 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Jean Delvare
AppliedHi Guenter,
Quoted 15 lines · Guenter Roeck
Result of
DIV_ROUND_CLOSESTis undefined for negative dividends if the divisor variable type is unsigned. Fix by declaring divisor as signed variable.Signed-off-by Guenter Roeck <[email protected]>---
v2: Fix by changing divisor variable type instead of dividend variable typedrivers/hwmon/emc6w201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/emc6w201.c +0
-0
drivers/hwmon/emc6w201.c static struct emc6w201_data *emc6w201_update_device(struct device *dev) · line 193
Quoted 8 lines
drivers/hwmon/emc6w201.c +1
-1@@ -187,7 +187,7 @@ static struct emc6w201_data *emc6w201_update_device(struct device *dev)* Sysfs callback functions */ -static const u16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 }; +static const s16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 };static ssize_t show_in (struct device *dev,struct device_attribute *devattr,char *buf)
Applied, thanks.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 21 lines · Jean Delvare
Hi Guenter,
Quoted 18 lines · Guenter Roeck
Result of
DIV_ROUND_CLOSESTis undefined for negative dividends if the divisor variable type is unsigned. Fix by declaring divisor as signed variable.Signed-off-by Guenter Roeck <[email protected]>---
v2: Fix by changing divisor variable type instead of dividend variable typedrivers/hwmon/emc6w201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/emc6w201.c +0
-0@@ -187,7 +187,7 @@ static struct emc6w201_data *emc6w201_update_device(struct device *dev)* Sysfs callback functions */
Quoted 8 lines
drivers/hwmon/emc6w201.c static struct emc6w201_data *emc6w201_update_device(struct device *dev) · line 193
Quoted 5 lines
drivers/hwmon/emc6w201.c +1
-1-static const u16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 }; +static const s16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 };static ssize_t show_in (struct device *dev,struct device_attribute *devattr,char *buf)Applied, thanks.
Hi Jean,
Can you take the kernel.h patch as well ?
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 25 lines · Guenter Roeck
Quoted 24 lines · Jean Delvare
Hi Guenter,
Quoted 21 lines · Guenter Roeck
Result of
DIV_ROUND_CLOSESTis undefined for negative dividends if the divisor variable type is unsigned. Fix by declaring divisor as signed variable.Signed-off-by Guenter Roeck <[email protected]>---
v2: Fix by changing divisor variable type instead of dividend variable typedrivers/hwmon/emc6w201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/emc6w201.c +1
-1@@ -187,7 +187,7 @@ static struct emc6w201_data *emc6w201_update_device(struct device *dev)* Sysfs callback functions */ -static const u16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 }; +static const s16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 };
Quoted 6 lines
Quoted 4 lines
drivers/hwmon/emc6w201.c static struct emc6w201_data *emc6w201_update_device(struct device *dev) · line 193
Quoted 2 lines
drivers/hwmon/emc6w201.c +0
-0static ssize_t show_in (struct device *dev,struct device_attribute *devattr,char *buf)Applied, thanks.
Can you take the
kernel.hpatch as well ?
Yes I can. I'm sending my hwmon patches to Linus tonight.
For clarity: both patches are needed but they are otherwise independent, right?
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 31 lines · Jean Delvare
Quoted 30 lines · Guenter Roeck
Quoted 28 lines · Jean Delvare
Hi Guenter,
Quoted 15 lines · Guenter Roeck
Result of
DIV_ROUND_CLOSESTis undefined for negative dividends if the divisor variable type is unsigned. Fix by declaring divisor as signed variable.Signed-off-by Guenter Roeck <[email protected]>---
v2: Fix by changing divisor variable type instead of dividend variable typedrivers/hwmon/emc6w201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/emc6w201.c +0
-0drivers/hwmon/emc6w201.c static struct emc6w201_data *emc6w201_update_device(struct device *dev) · line 193
Quoted 8 lines
drivers/hwmon/emc6w201.c +1
-1@@ -187,7 +187,7 @@ static struct emc6w201_data *emc6w201_update_device(struct device *dev)* Sysfs callback functions */ -static const u16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 }; +static const s16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 };static ssize_t show_in (struct device *dev,struct device_attribute *devattr,char *buf)Applied, thanks.
Quoted 6 lines
Quoted 1 line
Can you take the
kernel.hpatch as well ?Yes I can. I'm sending my hwmon patches to Linus tonight.
For clarity: both patches are needed but they are otherwise independent, right?
Note: I finally refrained from including both commits in my pull request, I want to take a closer look first. If nothing else, to decide whether they should go to stable trees or not.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Guenter Roeck
maintainerQuoted 34 lines · Jean Delvare
Quoted 33 lines · Jean Delvare
Quoted 31 lines · Guenter Roeck
Quoted 21 lines · Jean Delvare
Hi Guenter,
Quoted 18 lines · Guenter Roeck
Result of
DIV_ROUND_CLOSESTis undefined for negative dividends if the divisor variable type is unsigned. Fix by declaring divisor as signed variable.Signed-off-by Guenter Roeck <[email protected]>---
v2: Fix by changing divisor variable type instead of dividend variable typedrivers/hwmon/emc6w201.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/emc6w201.c +0
-0@@ -187,7 +187,7 @@ static struct emc6w201_data *emc6w201_update_device(struct device *dev)* Sysfs callback functions */ Quoted 7 lines
drivers/hwmon/emc6w201.c static struct emc6w201_data *emc6w201_update_device(struct device *dev) · line 193
Quoted 5 lines
drivers/hwmon/emc6w201.c +1
-1-static const u16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 }; +static const s16 nominal_mv[6 ] = {2500 ,1500 ,3300 ,5000 ,1500 ,1500 };static ssize_t show_in (struct device *dev,struct device_attribute *devattr,char *buf)Applied, thanks.
Can you take the
kernel.hpatch as well ?
Quoted 9 lines
Quoted 4 lines
Yes I can. I'm sending my hwmon patches to Linus tonight.
For clarity: both patches are needed but they are otherwise independent, right?
Note: I finally refrained from including both commits in my pull request, I want to take a closer look first. If nothing else, to decide whether they should go to stable trees or not.
Yes - 3.6 and later.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors