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

Merge tag 'hwmon-for-v5.9-rc3' of...

Merge tag 'hwmon-for-v5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:

 - Fix tempeerature scale in gsc-hwmon driver

 - Fix divide by 0 error in nct7904 driver

 - Drop non-existing attribute from pmbus/isl68137 driver

 - Fix status check in applesmc driver

* tag 'hwmon-for-v5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (gsc-hwmon) Scale temperature to millidegrees
  hwmon: (applesmc) check status earlier.
  hwmon: (nct7904) Correct divide by 0
  hwmon: (pmbus/isl68137) remove READ_TEMPERATURE_1 telemetry for RAA228228
parents 4d41ead6 c1ae18d3
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -753,15 +753,18 @@ static ssize_t applesmc_light_show(struct device *dev,
	}

	ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length);
	if (ret)
		goto out;
	/* newer macbooks report a single 10-bit bigendian value */
	if (data_length == 10) {
		left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2;
		goto out;
	}
	left = buffer[2];

	ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, data_length);
	if (ret)
		goto out;
	ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, data_length);
	right = buffer[2];

out:
@@ -810,11 +813,10 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
		  to_index(attr));

	ret = applesmc_read_key(newkey, buffer, 2);
	speed = ((buffer[0] << 8 | buffer[1]) >> 2);

	if (ret)
		return ret;
	else

	speed = ((buffer[0] << 8 | buffer[1]) >> 2);
	return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", speed);
}

@@ -851,11 +853,10 @@ static ssize_t applesmc_show_fan_manual(struct device *dev,
	u8 buffer[2];

	ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
	manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01;

	if (ret)
		return ret;
	else

	manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01;
	return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", manual);
}

@@ -872,10 +873,11 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
		return -EINVAL;

	ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
	val = (buffer[0] << 8 | buffer[1]);
	if (ret)
		goto out;

	val = (buffer[0] << 8 | buffer[1]);

	if (input)
		val = val | (0x01 << to_index(attr));
	else
@@ -951,12 +953,11 @@ static ssize_t applesmc_key_count_show(struct device *dev,
	u32 count;

	ret = applesmc_read_key(KEY_COUNT_KEY, buffer, 4);
	count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) +
						((u32)buffer[2]<<8) + buffer[3];

	if (ret)
		return ret;
	else

	count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) +
						((u32)buffer[2]<<8) + buffer[3];
	return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", count);
}

+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@ gsc_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
	case mode_temperature:
		if (tmp > 0x8000)
			tmp -= 0xffff;
		tmp *= 100; /* convert to millidegrees celsius */
		break;
	case mode_voltage_raw:
		tmp = clamp_val(tmp, 0, BIT(GSC_HWMON_RESOLUTION));
+2 −2
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
		if (ret < 0)
			return ret;
		cnt = ((ret & 0xff00) >> 3) | (ret & 0x1f);
		if (cnt == 0x1fff)
		if (cnt == 0 || cnt == 0x1fff)
			rpm = 0;
		else
			rpm = 1350000 / cnt;
@@ -243,7 +243,7 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
		if (ret < 0)
			return ret;
		cnt = ((ret & 0xff00) >> 3) | (ret & 0x1f);
		if (cnt == 0x1fff)
		if (cnt == 0 || cnt == 0x1fff)
			rpm = 0;
		else
			rpm = 1350000 / cnt;
+6 −1
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ enum variants {
	raa_dmpvr1_2rail,
	raa_dmpvr2_1rail,
	raa_dmpvr2_2rail,
	raa_dmpvr2_2rail_nontc,
	raa_dmpvr2_3rail,
	raa_dmpvr2_hv,
};
@@ -241,6 +242,10 @@ static int isl68137_probe(struct i2c_client *client,
		info->pages = 1;
		info->read_word_data = raa_dmpvr2_read_word_data;
		break;
	case raa_dmpvr2_2rail_nontc:
		info->func[0] &= ~PMBUS_HAVE_TEMP;
		info->func[1] &= ~PMBUS_HAVE_TEMP;
		fallthrough;
	case raa_dmpvr2_2rail:
		info->pages = 2;
		info->read_word_data = raa_dmpvr2_read_word_data;
@@ -304,7 +309,7 @@ static const struct i2c_device_id raa_dmpvr_id[] = {
	{"raa228000", raa_dmpvr2_hv},
	{"raa228004", raa_dmpvr2_hv},
	{"raa228006", raa_dmpvr2_hv},
	{"raa228228", raa_dmpvr2_2rail},
	{"raa228228", raa_dmpvr2_2rail_nontc},
	{"raa229001", raa_dmpvr2_2rail},
	{"raa229004", raa_dmpvr2_2rail},
	{}