Skip to content

Commit e6995f2

Browse files
committed
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
2 parents 5766e9d + 94cdc56 commit e6995f2

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/hwmon/adm9240.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
194194
* 0.5'C per two measurement cycles thus ignore possible
195195
* but unlikely aliasing error on lsb reading. --Grant
196196
*/
197-
data->temp = ((i2c_smbus_read_byte_data(client,
197+
data->temp = (i2c_smbus_read_byte_data(client,
198198
ADM9240_REG_TEMP) << 8) |
199199
i2c_smbus_read_byte_data(client,
200-
ADM9240_REG_TEMP_CONF)) / 128;
200+
ADM9240_REG_TEMP_CONF);
201201

202202
for (i = 0; i < 2; i++) { /* read fans */
203203
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,
263263
char *buf)
264264
{
265265
struct adm9240_data *data = adm9240_update_device(dev);
266-
return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */
266+
return sprintf(buf, "%d\n", data->temp / 128 * 500); /* 9-bit value */
267267
}
268268

269269
static ssize_t show_max(struct device *dev, struct device_attribute *devattr,

drivers/hwmon/max31790.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,13 @@ static int max31790_read_pwm(struct device *dev, u32 attr, int channel,
268268
long *val)
269269
{
270270
struct max31790_data *data = max31790_update_device(dev);
271-
u8 fan_config = data->fan_config[channel];
271+
u8 fan_config;
272272

273273
if (IS_ERR(data))
274274
return PTR_ERR(data);
275275

276+
fan_config = data->fan_config[channel];
277+
276278
switch (attr) {
277279
case hwmon_pwm_input:
278280
*val = data->pwm[channel] >> 8;

0 commit comments

Comments
 (0)