Commit 3110df80 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 375d0c0e 7e97bbba
...@@ -53,23 +53,23 @@ static int adm1275_probe(struct i2c_client *client, ...@@ -53,23 +53,23 @@ static int adm1275_probe(struct i2c_client *client,
info->direct[PSC_VOLTAGE_IN] = true; info->direct[PSC_VOLTAGE_IN] = true;
info->direct[PSC_VOLTAGE_OUT] = true; info->direct[PSC_VOLTAGE_OUT] = true;
info->direct[PSC_CURRENT_OUT] = true; info->direct[PSC_CURRENT_OUT] = true;
info->m[PSC_CURRENT_OUT] = 800; info->m[PSC_CURRENT_OUT] = 807;
info->b[PSC_CURRENT_OUT] = 20475; info->b[PSC_CURRENT_OUT] = 20475;
info->R[PSC_CURRENT_OUT] = -1; info->R[PSC_CURRENT_OUT] = -1;
info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT; info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT;
if (config & ADM1275_VRANGE) { if (config & ADM1275_VRANGE) {
info->m[PSC_VOLTAGE_IN] = 19045; info->m[PSC_VOLTAGE_IN] = 19199;
info->b[PSC_VOLTAGE_IN] = 0; info->b[PSC_VOLTAGE_IN] = 0;
info->R[PSC_VOLTAGE_IN] = -2; info->R[PSC_VOLTAGE_IN] = -2;
info->m[PSC_VOLTAGE_OUT] = 19045; info->m[PSC_VOLTAGE_OUT] = 19199;
info->b[PSC_VOLTAGE_OUT] = 0; info->b[PSC_VOLTAGE_OUT] = 0;
info->R[PSC_VOLTAGE_OUT] = -2; info->R[PSC_VOLTAGE_OUT] = -2;
} else { } else {
info->m[PSC_VOLTAGE_IN] = 6666; info->m[PSC_VOLTAGE_IN] = 6720;
info->b[PSC_VOLTAGE_IN] = 0; info->b[PSC_VOLTAGE_IN] = 0;
info->R[PSC_VOLTAGE_IN] = -1; info->R[PSC_VOLTAGE_IN] = -1;
info->m[PSC_VOLTAGE_OUT] = 6666; info->m[PSC_VOLTAGE_OUT] = 6720;
info->b[PSC_VOLTAGE_OUT] = 0; info->b[PSC_VOLTAGE_OUT] = 0;
info->R[PSC_VOLTAGE_OUT] = -1; info->R[PSC_VOLTAGE_OUT] = -1;
} }
......
...@@ -362,7 +362,7 @@ static struct pmbus_data *pmbus_update_device(struct device *dev) ...@@ -362,7 +362,7 @@ static struct pmbus_data *pmbus_update_device(struct device *dev)
* Convert linear sensor values to milli- or micro-units * Convert linear sensor values to milli- or micro-units
* depending on sensor type. * depending on sensor type.
*/ */
static int pmbus_reg2data_linear(struct pmbus_data *data, static long pmbus_reg2data_linear(struct pmbus_data *data,
struct pmbus_sensor *sensor) struct pmbus_sensor *sensor)
{ {
s16 exponent; s16 exponent;
...@@ -397,14 +397,14 @@ static int pmbus_reg2data_linear(struct pmbus_data *data, ...@@ -397,14 +397,14 @@ static int pmbus_reg2data_linear(struct pmbus_data *data,
else else
val >>= -exponent; val >>= -exponent;
return (int)val; return val;
} }
/* /*
* Convert direct sensor values to milli- or micro-units * Convert direct sensor values to milli- or micro-units
* depending on sensor type. * depending on sensor type.
*/ */
static int pmbus_reg2data_direct(struct pmbus_data *data, static long pmbus_reg2data_direct(struct pmbus_data *data,
struct pmbus_sensor *sensor) struct pmbus_sensor *sensor)
{ {
long val = (s16) sensor->data; long val = (s16) sensor->data;
...@@ -440,12 +440,12 @@ static int pmbus_reg2data_direct(struct pmbus_data *data, ...@@ -440,12 +440,12 @@ static int pmbus_reg2data_direct(struct pmbus_data *data,
R++; R++;
} }
return (int)((val - b) / m); return (val - b) / m;
} }
static int pmbus_reg2data(struct pmbus_data *data, struct pmbus_sensor *sensor) static long pmbus_reg2data(struct pmbus_data *data, struct pmbus_sensor *sensor)
{ {
int val; long val;
if (data->info->direct[sensor->class]) if (data->info->direct[sensor->class])
val = pmbus_reg2data_direct(data, sensor); val = pmbus_reg2data_direct(data, sensor);
...@@ -619,7 +619,7 @@ static int pmbus_get_boolean(struct pmbus_data *data, int index, int *val) ...@@ -619,7 +619,7 @@ static int pmbus_get_boolean(struct pmbus_data *data, int index, int *val)
if (!s1 && !s2) if (!s1 && !s2)
*val = !!regval; *val = !!regval;
else { else {
int v1, v2; long v1, v2;
struct pmbus_sensor *sensor1, *sensor2; struct pmbus_sensor *sensor1, *sensor2;
sensor1 = &data->sensors[s1]; sensor1 = &data->sensors[s1];
...@@ -661,7 +661,7 @@ static ssize_t pmbus_show_sensor(struct device *dev, ...@@ -661,7 +661,7 @@ static ssize_t pmbus_show_sensor(struct device *dev,
if (sensor->data < 0) if (sensor->data < 0)
return sensor->data; return sensor->data;
return snprintf(buf, PAGE_SIZE, "%d\n", pmbus_reg2data(data, sensor)); return snprintf(buf, PAGE_SIZE, "%ld\n", pmbus_reg2data(data, sensor));
} }
static ssize_t pmbus_set_sensor(struct device *dev, static ssize_t pmbus_set_sensor(struct device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment