Skip to content

Commit 07757ee

Browse files
committed
Merge tag 'hwmon-for-v6.13-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - ltc2991, tmp513: Fix problems seen when dividing negative numbers - drivetemp: Handle large timeouts observed on some drives - acpi_power_meter: Fix loading the driver on platforms without _PMD method * tag 'hwmon-for-v6.13-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (ltc2991) Fix mixed signed/unsigned in DIV_ROUND_CLOSEST hwmon: (drivetemp) Set scsi command timeout to 10s hwmon: (acpi_power_meter) Fix a check for the return value of read_domain_devices(). hwmon: (tmp513) Fix division of negative numbers
2 parents 7fed891 + e9b24de commit 07757ee

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

drivers/hwmon/acpi_power_meter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ static int setup_attrs(struct acpi_power_meter_resource *resource)
682682

683683
/* _PMD method is optional. */
684684
res = read_domain_devices(resource);
685-
if (res != -ENODEV)
685+
if (res && res != -ENODEV)
686686
return res;
687687

688688
if (resource->caps.flags & POWER_METER_CAN_MEASURE) {

drivers/hwmon/drivetemp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static int drivetemp_scsi_command(struct drivetemp_data *st,
194194
scsi_cmd[14] = ata_command;
195195

196196
err = scsi_execute_cmd(st->sdev, scsi_cmd, op, st->smartdata,
197-
ATA_SECT_SIZE, HZ, 5, NULL);
197+
ATA_SECT_SIZE, 10 * HZ, 5, NULL);
198198
if (err > 0)
199199
err = -EIO;
200200
return err;

drivers/hwmon/ltc2991.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int ltc2991_get_curr(struct ltc2991_state *st, u32 reg, int channel,
125125

126126
/* Vx-Vy, 19.075uV/LSB */
127127
*val = DIV_ROUND_CLOSEST(sign_extend32(reg_val, 14) * 19075,
128-
st->r_sense_uohm[channel]);
128+
(s32)st->r_sense_uohm[channel]);
129129

130130
return 0;
131131
}

drivers/hwmon/tmp513.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ static int tmp51x_get_value(struct tmp51x_data *data, u8 reg, u8 pos,
207207
*val = sign_extend32(regval,
208208
reg == TMP51X_SHUNT_CURRENT_RESULT ?
209209
16 - tmp51x_get_pga_shift(data) : 15);
210-
*val = DIV_ROUND_CLOSEST(*val * 10 * MILLI, data->shunt_uohms);
210+
*val = DIV_ROUND_CLOSEST(*val * 10 * (long)MILLI, (long)data->shunt_uohms);
211+
211212
break;
212213
case TMP51X_BUS_VOLTAGE_RESULT:
213214
case TMP51X_BUS_VOLTAGE_H_LIMIT:
@@ -223,7 +224,7 @@ static int tmp51x_get_value(struct tmp51x_data *data, u8 reg, u8 pos,
223224
case TMP51X_BUS_CURRENT_RESULT:
224225
// Current = (ShuntVoltage * CalibrationRegister) / 4096
225226
*val = sign_extend32(regval, 15) * (long)data->curr_lsb_ua;
226-
*val = DIV_ROUND_CLOSEST(*val, MILLI);
227+
*val = DIV_ROUND_CLOSEST(*val, (long)MILLI);
227228
break;
228229
case TMP51X_LOCAL_TEMP_RESULT:
229230
case TMP51X_REMOTE_TEMP_RESULT_1:
@@ -263,7 +264,7 @@ static int tmp51x_set_value(struct tmp51x_data *data, u8 reg, long val)
263264
* The user enter current value and we convert it to
264265
* voltage. 1lsb = 10uV
265266
*/
266-
val = DIV_ROUND_CLOSEST(val * data->shunt_uohms, 10 * MILLI);
267+
val = DIV_ROUND_CLOSEST(val * (long)data->shunt_uohms, 10 * (long)MILLI);
267268
max_val = U16_MAX >> tmp51x_get_pga_shift(data);
268269
regval = clamp_val(val, -max_val, max_val);
269270
break;

0 commit comments

Comments
 (0)