aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-15 13:21:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-15 13:21:21 -0400
commit3110df800c4de2724624d46e6bed27efc5e9a707 (patch)
tree7285520054f5fb5e154c8f71c9232f8b63cca417
parent375d0c0e70cf788fa74c658e5dd619a7abb7c5f7 (diff)
parent7e97bbba62754ea86e191b99c6978476198ecb99 (diff)
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging
* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/staging: hwmon: (adm1275) Fix coefficients per datasheet revision B hwmon: (pmbus) Use long variables for register to data conversions
-rw-r--r--drivers/hwmon/adm1275.c10
-rw-r--r--drivers/hwmon/pmbus_core.c20
2 files changed, 15 insertions, 15 deletions
diff --git a/drivers/hwmon/adm1275.c b/drivers/hwmon/adm1275.c
index b9b7caf4a1d2..8bc1bd663721 100644
--- a/drivers/hwmon/adm1275.c
+++ b/drivers/hwmon/adm1275.c
@@ -53,23 +53,23 @@ static int adm1275_probe(struct i2c_client *client,
53 info->direct[PSC_VOLTAGE_IN] = true; 53 info->direct[PSC_VOLTAGE_IN] = true;
54 info->direct[PSC_VOLTAGE_OUT] = true; 54 info->direct[PSC_VOLTAGE_OUT] = true;
55 info->direct[PSC_CURRENT_OUT] = true; 55 info->direct[PSC_CURRENT_OUT] = true;
56 info->m[PSC_CURRENT_OUT] = 800; 56 info->m[PSC_CURRENT_OUT] = 807;
57 info->b[PSC_CURRENT_OUT] = 20475; 57 info->b[PSC_CURRENT_OUT] = 20475;
58 info->R[PSC_CURRENT_OUT] = -1; 58 info->R[PSC_CURRENT_OUT] = -1;
59 info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT; 59 info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT;
60 60
61 if (config & ADM1275_VRANGE) { 61 if (config & ADM1275_VRANGE) {
62 info->m[PSC_VOLTAGE_IN] = 19045; 62 info->m[PSC_VOLTAGE_IN] = 19199;
63 info->b[PSC_VOLTAGE_IN] = 0; 63 info->b[PSC_VOLTAGE_IN] = 0;
64 info->R[PSC_VOLTAGE_IN] = -2; 64 info->R[PSC_VOLTAGE_IN] = -2;
65 info->m[PSC_VOLTAGE_OUT] = 19045; 65 info->m[PSC_VOLTAGE_OUT] = 19199;
66 info->b[PSC_VOLTAGE_OUT] = 0; 66 info->b[PSC_VOLTAGE_OUT] = 0;
67 info->R[PSC_VOLTAGE_OUT] = -2; 67 info->R[PSC_VOLTAGE_OUT] = -2;
68 } else { 68 } else {
69 info->m[PSC_VOLTAGE_IN] = 6666; 69 info->m[PSC_VOLTAGE_IN] = 6720;
70 info->b[PSC_VOLTAGE_IN] = 0; 70 info->b[PSC_VOLTAGE_IN] = 0;
71 info->R[PSC_VOLTAGE_IN] = -1; 71 info->R[PSC_VOLTAGE_IN] = -1;
72 info->m[PSC_VOLTAGE_OUT] = 6666; 72 info->m[PSC_VOLTAGE_OUT] = 6720;
73 info->b[PSC_VOLTAGE_OUT] = 0; 73 info->b[PSC_VOLTAGE_OUT] = 0;
74 info->R[PSC_VOLTAGE_OUT] = -1; 74 info->R[PSC_VOLTAGE_OUT] = -1;
75 } 75 }
diff --git a/drivers/hwmon/pmbus_core.c b/drivers/hwmon/pmbus_core.c
index 744672c1f26d..8e31a8e2c746 100644
--- a/drivers/hwmon/pmbus_core.c
+++ b/drivers/hwmon/pmbus_core.c
@@ -362,8 +362,8 @@ static struct pmbus_data *pmbus_update_device(struct device *dev)
362 * Convert linear sensor values to milli- or micro-units 362 * Convert linear sensor values to milli- or micro-units
363 * depending on sensor type. 363 * depending on sensor type.
364 */ 364 */
365static int pmbus_reg2data_linear(struct pmbus_data *data, 365static long pmbus_reg2data_linear(struct pmbus_data *data,
366 struct pmbus_sensor *sensor) 366 struct pmbus_sensor *sensor)
367{ 367{
368 s16 exponent; 368 s16 exponent;
369 s32 mantissa; 369 s32 mantissa;
@@ -397,15 +397,15 @@ static int pmbus_reg2data_linear(struct pmbus_data *data,
397 else 397 else
398 val >>= -exponent; 398 val >>= -exponent;
399 399
400 return (int)val; 400 return val;
401} 401}
402 402
403/* 403/*
404 * Convert direct sensor values to milli- or micro-units 404 * Convert direct sensor values to milli- or micro-units
405 * depending on sensor type. 405 * depending on sensor type.
406 */ 406 */
407static int pmbus_reg2data_direct(struct pmbus_data *data, 407static long pmbus_reg2data_direct(struct pmbus_data *data,
408 struct pmbus_sensor *sensor) 408 struct pmbus_sensor *sensor)
409{ 409{
410 long val = (s16) sensor->data; 410 long val = (s16) sensor->data;
411 long m, b, R; 411 long m, b, R;
@@ -440,12 +440,12 @@ static int pmbus_reg2data_direct(struct pmbus_data *data,
440 R++; 440 R++;
441 } 441 }
442 442
443 return (int)((val - b) / m); 443 return (val - b) / m;
444} 444}
445 445
446static int pmbus_reg2data(struct pmbus_data *data, struct pmbus_sensor *sensor) 446static long pmbus_reg2data(struct pmbus_data *data, struct pmbus_sensor *sensor)
447{ 447{
448 int val; 448 long val;
449 449
450 if (data->info->direct[sensor->class]) 450 if (data->info->direct[sensor->class])
451 val = pmbus_reg2data_direct(data, sensor); 451 val = pmbus_reg2data_direct(data, sensor);
@@ -619,7 +619,7 @@ static int pmbus_get_boolean(struct pmbus_data *data, int index, int *val)
619 if (!s1 && !s2) 619 if (!s1 && !s2)
620 *val = !!regval; 620 *val = !!regval;
621 else { 621 else {
622 int v1, v2; 622 long v1, v2;
623 struct pmbus_sensor *sensor1, *sensor2; 623 struct pmbus_sensor *sensor1, *sensor2;
624 624
625 sensor1 = &data->sensors[s1]; 625 sensor1 = &data->sensors[s1];
@@ -661,7 +661,7 @@ static ssize_t pmbus_show_sensor(struct device *dev,
661 if (sensor->data < 0) 661 if (sensor->data < 0)
662 return sensor->data; 662 return sensor->data;
663 663
664 return snprintf(buf, PAGE_SIZE, "%d\n", pmbus_reg2data(data, sensor)); 664 return snprintf(buf, PAGE_SIZE, "%ld\n", pmbus_reg2data(data, sensor));
665} 665}
666 666
667static ssize_t pmbus_set_sensor(struct device *dev, 667static ssize_t pmbus_set_sensor(struct device *dev,