* [lm-sensors] [PATCH] hwmon: (gpio-fan) Prevent overflow problem when writing large limits
@ 2014-08-02 5:36 Axel Lin
2014-08-04 14:28 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2014-08-02 5:36 UTC (permalink / raw)
To: lm-sensors
On platforms with sizeof(int) < sizeof(unsigned long), writing a rpm value
larger than MAXINT will result in unpredictable limit values written to the
chip. Avoid auto-conversion from unsigned long to int to fix the problem.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/hwmon/gpio-fan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index a43e5b0..4efa173 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -173,7 +173,7 @@ static int get_fan_speed_index(struct gpio_fan_data *fan_data)
return -ENODEV;
}
-static int rpm_to_speed_index(struct gpio_fan_data *fan_data, int rpm)
+static int rpm_to_speed_index(struct gpio_fan_data *fan_data, unsigned long rpm)
{
struct gpio_fan_speed *speed = fan_data->speed;
int i;
--
1.9.1
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (gpio-fan) Prevent overflow problem when writing large limits
2014-08-02 5:36 [lm-sensors] [PATCH] hwmon: (gpio-fan) Prevent overflow problem when writing large limits Axel Lin
@ 2014-08-04 14:28 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2014-08-04 14:28 UTC (permalink / raw)
To: lm-sensors
On 08/01/2014 10:36 PM, Axel Lin wrote:
> On platforms with sizeof(int) < sizeof(unsigned long), writing a rpm value
> larger than MAXINT will result in unpredictable limit values written to the
> chip. Avoid auto-conversion from unsigned long to int to fix the problem.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Good catch. Applied.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-04 14:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-02 5:36 [lm-sensors] [PATCH] hwmon: (gpio-fan) Prevent overflow problem when writing large limits Axel Lin
2014-08-04 14:28 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.