[PATCH 2.6] Fix conversion from milli volts in store_in_reg() forw83781d.c

From: Martin Schlemmer
Date: Wed Sep 03 2003 - 15:56:04 EST


Hi

I am not sure if it was a later patch from me that fixed in_* to display
milli volts in sysfs, or if it was a patch from Jan Dittmer, but the
conversion in the store_in_*() functions is wrong, and cause something
like:

----------------------------
nosferatu patch # cat /sys/bus/i2c/devices/1-0290/in_max2
3632
nosferatu patch # echo '3700' > /sys/bus/i2c/devices/1-0290/in_max2
nosferatu patch # cat /sys/bus/i2c/devices/1-0290/in_max2
400
nosferatu patch # echo '3640' > /sys/bus/i2c/devices/1-0290/in_max2
nosferatu patch # cat /sys/bus/i2c/devices/1-0290/in_max2
400
nosferatu patch # echo '3632' > /sys/bus/i2c/devices/1-0290/in_max2
nosferatu patch # cat /sys/bus/i2c/devices/1-0290/in_max2
400
nosferatu patch #
-----------------------------

I think Andrey also noticed this (if I did not smoke too much Weedbix
this morning ;) - if so, please verify that this fixes it ... it does
here at least.

Anyhow, patch is attached and should apply to 2.6.0-test4-bk5.


Regards,

--

Martin Schlemmer



--- 1/drivers/i2c/chips/w83781d.c 2003-09-03 22:42:02.199165296 +0200
+++ 2/drivers/i2c/chips/w83781d.c 2003-09-03 22:35:02.378987664 +0200
@@ -378,8 +378,8 @@ static ssize_t store_in_##reg (struct de
struct w83781d_data *data = i2c_get_clientdata(client); \
u32 val; \
\
- val = simple_strtoul(buf, NULL, 10); \
- data->in_##reg[nr] = (IN_TO_REG(val) / 10); \
+ val = simple_strtoul(buf, NULL, 10) / 10; \
+ data->in_##reg[nr] = IN_TO_REG(val); \
w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \
\
return count; \

Attachment: signature.asc
Description: This is a digitally signed message part