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

Merge tag 'hwmon-for-v6.16-rc7' of...

Merge tag 'hwmon-for-v6.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:

 - corsair-cpro: Validate the size of the received input buffer

 - ina238: Report energy in microjoules as expected by the ABI

 - pmbus/ucd9000: Fixed GPIO functionality

* tag 'hwmon-for-v6.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (pmbus/ucd9000) Fix error in ucd9000_gpio_set
  hwmon: (ina238) Report energy in microjoules
  hwmon: (corsair-cpro) Validate the size of the received input buffer
parents acc0bac1 ce3cf7c8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ Additional sysfs entries for sq52206
------------------------------------

======================= =======================================================
energy1_input		Energy measurement (mJ)
energy1_input		Energy measurement (uJ)

power1_input_highest	Peak Power (uW)
======================= =======================================================
+5 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ struct ccp_device {
	struct mutex mutex; /* whenever buffer is used, lock before send_usb_cmd */
	u8 *cmd_buffer;
	u8 *buffer;
	int buffer_recv_size; /* number of received bytes in buffer */
	int target[6];
	DECLARE_BITMAP(temp_cnct, NUM_TEMP_SENSORS);
	DECLARE_BITMAP(fan_cnct, NUM_FANS);
@@ -146,6 +147,9 @@ static int send_usb_cmd(struct ccp_device *ccp, u8 command, u8 byte1, u8 byte2,
	if (!t)
		return -ETIMEDOUT;

	if (ccp->buffer_recv_size != IN_BUFFER_SIZE)
		return -EPROTO;

	return ccp_get_errno(ccp);
}

@@ -157,6 +161,7 @@ static int ccp_raw_event(struct hid_device *hdev, struct hid_report *report, u8
	spin_lock(&ccp->wait_input_report_lock);
	if (!completion_done(&ccp->wait_input_report)) {
		memcpy(ccp->buffer, data, min(IN_BUFFER_SIZE, size));
		ccp->buffer_recv_size = size;
		complete_all(&ccp->wait_input_report);
	}
	spin_unlock(&ccp->wait_input_report_lock);
+4 −4
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@
 *  Power (mW) = 0.2 * register value * 20000 / rshunt / 4 * gain
 *  (Specific for SQ52206)
 *  Power (mW) = 0.24 * register value * 20000 / rshunt / 4 * gain
 *  Energy (mJ) = 16 * 0.24 * register value * 20000 / rshunt / 4 * gain
 *  Energy (uJ) = 16 * 0.24 * register value * 20000 / rshunt / 4 * gain * 1000
 */
#define INA238_CALIBRATION_VALUE	16384
#define INA238_FIXED_SHUNT		20000
@@ -500,9 +500,9 @@ static ssize_t energy1_input_show(struct device *dev,
	if (ret)
		return ret;

	/* result in mJ */
	energy = div_u64(regval * INA238_FIXED_SHUNT *	data->gain * 16 *
				data->config->power_calculate_factor, 4 * 100 * data->rshunt);
	/* result in uJ */
	energy = div_u64(regval * INA238_FIXED_SHUNT *	data->gain * 16 * 10 *
				data->config->power_calculate_factor, 4 * data->rshunt);

	return sysfs_emit(buf, "%llu\n", energy);
}
+4 −4
Original line number Diff line number Diff line
@@ -226,15 +226,15 @@ static int ucd9000_gpio_set(struct gpio_chip *gc, unsigned int offset,
	}

	if (value) {
		if (ret & UCD9000_GPIO_CONFIG_STATUS)
		if (ret & UCD9000_GPIO_CONFIG_OUT_VALUE)
			return 0;

		ret |= UCD9000_GPIO_CONFIG_STATUS;
		ret |= UCD9000_GPIO_CONFIG_OUT_VALUE;
	} else {
		if (!(ret & UCD9000_GPIO_CONFIG_STATUS))
		if (!(ret & UCD9000_GPIO_CONFIG_OUT_VALUE))
			return 0;

		ret &= ~UCD9000_GPIO_CONFIG_STATUS;
		ret &= ~UCD9000_GPIO_CONFIG_OUT_VALUE;
	}

	ret |= UCD9000_GPIO_CONFIG_ENABLE;