diff options
author | Jean Delvare <khali@linux-fr.org> | 2005-12-18 10:34:28 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-06 01:16:25 -0500 |
commit | 99d855602c1d7968ca6b6cc99b773b0b47909690 (patch) | |
tree | 3e79339c40f1819f90911c6d96b72cb73781dbdd /drivers | |
parent | c9152deaa635cab09cb43c17cf80130b9e6ee29d (diff) |
[PATCH] hwmon: w83792d simplify in low bits handling
Simplify the way the w83792d driver handles the extra resolution
bits of voltage input channels.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Yuan Mu <Ymu@winbond.com.tw>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/w83792d.c | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 0ad1ae569531..b176bf0c4c7b 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -281,7 +281,7 @@ struct w83792d_data { | |||
281 | u8 in[9]; /* Register value */ | 281 | u8 in[9]; /* Register value */ |
282 | u8 in_max[9]; /* Register value */ | 282 | u8 in_max[9]; /* Register value */ |
283 | u8 in_min[9]; /* Register value */ | 283 | u8 in_min[9]; /* Register value */ |
284 | u8 low_bits[2]; /* Additional resolution to voltage in0-6 */ | 284 | u16 low_bits; /* Additional resolution to voltage in6-0 */ |
285 | u8 fan[7]; /* Register value */ | 285 | u8 fan[7]; /* Register value */ |
286 | u8 fan_min[7]; /* Register value */ | 286 | u8 fan_min[7]; /* Register value */ |
287 | u8 temp1[3]; /* current, over, thyst */ | 287 | u8 temp1[3]; /* current, over, thyst */ |
@@ -323,38 +323,10 @@ static struct i2c_driver w83792d_driver = { | |||
323 | .detach_client = w83792d_detach_client, | 323 | .detach_client = w83792d_detach_client, |
324 | }; | 324 | }; |
325 | 325 | ||
326 | static long in_count_from_reg(int nr, struct w83792d_data *data) | 326 | static inline long in_count_from_reg(int nr, struct w83792d_data *data) |
327 | { | 327 | { |
328 | u16 vol_count = data->in[nr]; | 328 | /* in7 and in8 do not have low bits, but the formula still works */ |
329 | u16 low_bits = 0; | 329 | return ((data->in[nr] << 2) | ((data->low_bits >> (2 * nr)) & 0x03)); |
330 | vol_count = (vol_count << 2); | ||
331 | switch (nr) | ||
332 | { | ||
333 | case 0: /* vin0 */ | ||
334 | low_bits = (data->low_bits[0]) & 0x03; | ||
335 | break; | ||
336 | case 1: /* vin1 */ | ||
337 | low_bits = ((data->low_bits[0]) & 0x0c) >> 2; | ||
338 | break; | ||
339 | case 2: /* vin2 */ | ||
340 | low_bits = ((data->low_bits[0]) & 0x30) >> 4; | ||
341 | break; | ||
342 | case 3: /* vin3 */ | ||
343 | low_bits = ((data->low_bits[0]) & 0xc0) >> 6; | ||
344 | break; | ||
345 | case 4: /* vin4 */ | ||
346 | low_bits = (data->low_bits[1]) & 0x03; | ||
347 | break; | ||
348 | case 5: /* vin5 */ | ||
349 | low_bits = ((data->low_bits[1]) & 0x0c) >> 2; | ||
350 | break; | ||
351 | case 6: /* vin6 */ | ||
352 | low_bits = ((data->low_bits[1]) & 0x30) >> 4; | ||
353 | default: | ||
354 | break; | ||
355 | } | ||
356 | vol_count = vol_count | low_bits; | ||
357 | return vol_count; | ||
358 | } | 330 | } |
359 | 331 | ||
360 | /* following are the sysfs callback functions */ | 332 | /* following are the sysfs callback functions */ |
@@ -1481,10 +1453,10 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1481 | data->in_min[i] = w83792d_read_value(client, | 1453 | data->in_min[i] = w83792d_read_value(client, |
1482 | W83792D_REG_IN_MIN[i]); | 1454 | W83792D_REG_IN_MIN[i]); |
1483 | } | 1455 | } |
1484 | data->low_bits[0] = w83792d_read_value(client, | 1456 | data->low_bits = w83792d_read_value(client, |
1485 | W83792D_REG_LOW_BITS1); | 1457 | W83792D_REG_LOW_BITS1) + |
1486 | data->low_bits[1] = w83792d_read_value(client, | 1458 | (w83792d_read_value(client, |
1487 | W83792D_REG_LOW_BITS2); | 1459 | W83792D_REG_LOW_BITS2) << 8); |
1488 | for (i = 0; i < 7; i++) { | 1460 | for (i = 0; i < 7; i++) { |
1489 | /* Update the Fan measured value and limits */ | 1461 | /* Update the Fan measured value and limits */ |
1490 | data->fan[i] = w83792d_read_value(client, | 1462 | data->fan[i] = w83792d_read_value(client, |
@@ -1596,8 +1568,8 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev) | |||
1596 | dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]); | 1568 | dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]); |
1597 | dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]); | 1569 | dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]); |
1598 | } | 1570 | } |
1599 | dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits[0]); | 1571 | dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits & 0xff); |
1600 | dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits[1]); | 1572 | dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits >> 8); |
1601 | dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n"); | 1573 | dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n"); |
1602 | for (i=0; i<7; i++) { | 1574 | for (i=0; i<7; i++) { |
1603 | dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); | 1575 | dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); |