Couple of hwmon fixes
Fix a potential ERR_PTR dereference in max31790 driver, and handle handle temperature readings below 0 in adm9240 driver. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJYC3RdAAoJEMsfJm/On5mB5OEQAIySEJO6fTb9pVfNTpez413F he5aPNIywDojpMx2ksFyrN2GMMbLFPq1ajLPYA6sf9yPmSLhkUiQpCy9nwtLW5Dd eNR7tvE1amqNJ+m8EITzl+P4p2+BqWJ0KlNc/SfrdEQTmnjR2lPd75pcR0IpMF12 yM59BrwtPGsHr3/lJbSYH1Uh+9tUyyfx0GfXmIMjk7xbC4bDFVgAnF2vnVRhLWcN WlRBUWye80vHz8uJAlCHMnrDrgUfPIZwVFblYoMu2ED8tt7+jgcQK91h7OBXj6VE T7YsMz1OCeGL42CYvgNsvCYVgeajssbdZX0za5+uQRNJA+ElTt7HtyEp6PL4wjOr 5MD444KgF6OBV7l6f18bOm+Q8OaS22RddrpaRIfO2VkvjXkffSIpkKUMawYaIP2S cPGbO0q/V3Gw0qw2CD4FtkNs9f0RsEl4a8uiif8ndRhSK6aQs2EC/ul2Z9wVfXx1 EYTHmtdl9Mrs4X9roP6YZKUBaUseQnPCv/Lkyd6vZs2fByiOH7DqIw5ciAP551oU AYvFsab6oK3FZfX4qlESiCkZlAN/sr3Xqu6Ytk2rkFitjeYvRzJecpdU7hqliXZX Rviiy7d/1d/GpC7mPxDiccrfebyYqtObOrYMBW0XY2kbWsc0ek37n4zxX1afsU5Y 2AnjoZHpuitI55FeuGgG =N52z -----END PGP SIGNATURE----- Merge tag 'hwmon-for-linus-v4.9-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon fixes from Guenter Roeck: "Couple of hwmon fixes: Fix a potential ERR_PTR dereference in max31790 driver, and handle temperature readings below 0 in adm9240 driver" * tag 'hwmon-for-linus-v4.9-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (max31790) potential ERR_PTR dereference hwmon: (adm9240) handle temperature readings below 0
This commit is contained in:
commit
e6995f22d3
|
@ -194,10 +194,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
|
|||
* 0.5'C per two measurement cycles thus ignore possible
|
||||
* but unlikely aliasing error on lsb reading. --Grant
|
||||
*/
|
||||
data->temp = ((i2c_smbus_read_byte_data(client,
|
||||
data->temp = (i2c_smbus_read_byte_data(client,
|
||||
ADM9240_REG_TEMP) << 8) |
|
||||
i2c_smbus_read_byte_data(client,
|
||||
ADM9240_REG_TEMP_CONF)) / 128;
|
||||
ADM9240_REG_TEMP_CONF);
|
||||
|
||||
for (i = 0; i < 2; i++) { /* read fans */
|
||||
data->fan[i] = i2c_smbus_read_byte_data(client,
|
||||
|
@ -263,7 +263,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *dummy,
|
|||
char *buf)
|
||||
{
|
||||
struct adm9240_data *data = adm9240_update_device(dev);
|
||||
return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */
|
||||
return sprintf(buf, "%d\n", data->temp / 128 * 500); /* 9-bit value */
|
||||
}
|
||||
|
||||
static ssize_t show_max(struct device *dev, struct device_attribute *devattr,
|
||||
|
|
|
@ -268,11 +268,13 @@ static int max31790_read_pwm(struct device *dev, u32 attr, int channel,
|
|||
long *val)
|
||||
{
|
||||
struct max31790_data *data = max31790_update_device(dev);
|
||||
u8 fan_config = data->fan_config[channel];
|
||||
u8 fan_config;
|
||||
|
||||
if (IS_ERR(data))
|
||||
return PTR_ERR(data);
|
||||
|
||||
fan_config = data->fan_config[channel];
|
||||
|
||||
switch (attr) {
|
||||
case hwmon_pwm_input:
|
||||
*val = data->pwm[channel] >> 8;
|
||||
|
|
Loading…
Reference in New Issue