Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6995f22 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'hwmon-for-linus-v4.9-rc2' of...

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
parents 5766e9d2 94cdc560
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -194,10 +194,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
		 * 0.5'C per two measurement cycles thus ignore possible
		 * 0.5'C per two measurement cycles thus ignore possible
		 * but unlikely aliasing error on lsb reading. --Grant
		 * 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) |
					ADM9240_REG_TEMP) << 8) |
					i2c_smbus_read_byte_data(client,
					i2c_smbus_read_byte_data(client,
					ADM9240_REG_TEMP_CONF)) / 128;
					ADM9240_REG_TEMP_CONF);


		for (i = 0; i < 2; i++) { /* read fans */
		for (i = 0; i < 2; i++) { /* read fans */
			data->fan[i] = i2c_smbus_read_byte_data(client,
			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)
		char *buf)
{
{
	struct adm9240_data *data = adm9240_update_device(dev);
	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,
static ssize_t show_max(struct device *dev, struct device_attribute *devattr,
+3 −1
Original line number Original line Diff line number Diff line
@@ -268,11 +268,13 @@ static int max31790_read_pwm(struct device *dev, u32 attr, int channel,
			     long *val)
			     long *val)
{
{
	struct max31790_data *data = max31790_update_device(dev);
	struct max31790_data *data = max31790_update_device(dev);
	u8 fan_config = data->fan_config[channel];
	u8 fan_config;


	if (IS_ERR(data))
	if (IS_ERR(data))
		return PTR_ERR(data);
		return PTR_ERR(data);


	fan_config = data->fan_config[channel];

	switch (attr) {
	switch (attr) {
	case hwmon_pwm_input:
	case hwmon_pwm_input:
		*val = data->pwm[channel] >> 8;
		*val = data->pwm[channel] >> 8;