Skip to content

Commit bd4a156

Browse files
committed
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
2 parents acc0bac + ce3cf7c commit bd4a156

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

Documentation/hwmon/ina238.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Additional sysfs entries for sq52206
6565
------------------------------------
6666

6767
======================= =======================================================
68-
energy1_input Energy measurement (mJ)
68+
energy1_input Energy measurement (uJ)
6969

7070
power1_input_highest Peak Power (uW)
7171
======================= =======================================================

drivers/hwmon/corsair-cpro.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct ccp_device {
8989
struct mutex mutex; /* whenever buffer is used, lock before send_usb_cmd */
9090
u8 *cmd_buffer;
9191
u8 *buffer;
92+
int buffer_recv_size; /* number of received bytes in buffer */
9293
int target[6];
9394
DECLARE_BITMAP(temp_cnct, NUM_TEMP_SENSORS);
9495
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,
146147
if (!t)
147148
return -ETIMEDOUT;
148149

150+
if (ccp->buffer_recv_size != IN_BUFFER_SIZE)
151+
return -EPROTO;
152+
149153
return ccp_get_errno(ccp);
150154
}
151155

@@ -157,6 +161,7 @@ static int ccp_raw_event(struct hid_device *hdev, struct hid_report *report, u8
157161
spin_lock(&ccp->wait_input_report_lock);
158162
if (!completion_done(&ccp->wait_input_report)) {
159163
memcpy(ccp->buffer, data, min(IN_BUFFER_SIZE, size));
164+
ccp->buffer_recv_size = size;
160165
complete_all(&ccp->wait_input_report);
161166
}
162167
spin_unlock(&ccp->wait_input_report_lock);

drivers/hwmon/ina238.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
* Power (mW) = 0.2 * register value * 20000 / rshunt / 4 * gain
9898
* (Specific for SQ52206)
9999
* Power (mW) = 0.24 * register value * 20000 / rshunt / 4 * gain
100-
* Energy (mJ) = 16 * 0.24 * register value * 20000 / rshunt / 4 * gain
100+
* Energy (uJ) = 16 * 0.24 * register value * 20000 / rshunt / 4 * gain * 1000
101101
*/
102102
#define INA238_CALIBRATION_VALUE 16384
103103
#define INA238_FIXED_SHUNT 20000
@@ -500,9 +500,9 @@ static ssize_t energy1_input_show(struct device *dev,
500500
if (ret)
501501
return ret;
502502

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

507507
return sysfs_emit(buf, "%llu\n", energy);
508508
}

drivers/hwmon/pmbus/ucd9000.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,15 @@ static int ucd9000_gpio_set(struct gpio_chip *gc, unsigned int offset,
226226
}
227227

228228
if (value) {
229-
if (ret & UCD9000_GPIO_CONFIG_STATUS)
229+
if (ret & UCD9000_GPIO_CONFIG_OUT_VALUE)
230230
return 0;
231231

232-
ret |= UCD9000_GPIO_CONFIG_STATUS;
232+
ret |= UCD9000_GPIO_CONFIG_OUT_VALUE;
233233
} else {
234-
if (!(ret & UCD9000_GPIO_CONFIG_STATUS))
234+
if (!(ret & UCD9000_GPIO_CONFIG_OUT_VALUE))
235235
return 0;
236236

237-
ret &= ~UCD9000_GPIO_CONFIG_STATUS;
237+
ret &= ~UCD9000_GPIO_CONFIG_OUT_VALUE;
238238
}
239239

240240
ret |= UCD9000_GPIO_CONFIG_ENABLE;

0 commit comments

Comments
 (0)