Skip to content

Commit 1523e4d

Browse files
committed
Merge tag 'hwmon-for-v7.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - Fix temperature sensor for PRIME X670E-PRO WIFI - occ: Add missing newline, and fix potential division by zero - pmbus: - Fix device ID comparison and printing in tps53676_identify() - Add missing MODULE_IMPORT_NS("PMBUS") for ltc4286 - Check return value of page-select write in pxe1610 probe - Fix array access with zero-length block tps53679 read * tag 'hwmon-for-v7.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (asus-ec-sensors) Fix T_Sensor for PRIME X670E-PRO WIFI hwmon: (occ) Fix missing newline in occ_show_extended() hwmon: (occ) Fix division by zero in occ_show_power_1() hwmon: (tps53679) Fix device ID comparison and printing in tps53676_identify() hwmon: (ltc4286) Add missing MODULE_IMPORT_NS("PMBUS") hwmon: (pxe1610) Check return value of page-select write in probe hwmon: (tps53679) Fix array access with zero-length block read
2 parents 631919f + cffff6d commit 1523e4d

5 files changed

Lines changed: 25 additions & 17 deletions

File tree

drivers/hwmon/asus-ec-sensors.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ enum ec_sensors {
111111
ec_sensor_temp_mb,
112112
/* "T_Sensor" temperature sensor reading [℃] */
113113
ec_sensor_temp_t_sensor,
114+
/* like ec_sensor_temp_t_sensor, but at an alternate address [℃] */
115+
ec_sensor_temp_t_sensor_alt1,
114116
/* VRM temperature [℃] */
115117
ec_sensor_temp_vrm,
116118
/* VRM east (right) temperature [℃] */
@@ -160,6 +162,7 @@ enum ec_sensors {
160162
#define SENSOR_TEMP_CPU_PACKAGE BIT(ec_sensor_temp_cpu_package)
161163
#define SENSOR_TEMP_MB BIT(ec_sensor_temp_mb)
162164
#define SENSOR_TEMP_T_SENSOR BIT(ec_sensor_temp_t_sensor)
165+
#define SENSOR_TEMP_T_SENSOR_ALT1 BIT(ec_sensor_temp_t_sensor_alt1)
163166
#define SENSOR_TEMP_VRM BIT(ec_sensor_temp_vrm)
164167
#define SENSOR_TEMP_VRME BIT(ec_sensor_temp_vrme)
165168
#define SENSOR_TEMP_VRMW BIT(ec_sensor_temp_vrmw)
@@ -279,6 +282,8 @@ static const struct ec_sensor_info sensors_family_amd_600[] = {
279282
EC_SENSOR("VRM", hwmon_temp, 1, 0x00, 0x33),
280283
[ec_sensor_temp_t_sensor] =
281284
EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x36),
285+
[ec_sensor_temp_t_sensor_alt1] =
286+
EC_SENSOR("T_Sensor", hwmon_temp, 1, 0x00, 0x37),
282287
[ec_sensor_fan_cpu_opt] =
283288
EC_SENSOR("CPU_Opt", hwmon_fan, 2, 0x00, 0xb0),
284289
[ec_sensor_temp_water_in] =
@@ -519,7 +524,7 @@ static const struct ec_board_info board_info_prime_x570_pro = {
519524
static const struct ec_board_info board_info_prime_x670e_pro_wifi = {
520525
.sensors = SENSOR_TEMP_CPU | SENSOR_TEMP_CPU_PACKAGE |
521526
SENSOR_TEMP_MB | SENSOR_TEMP_VRM |
522-
SENSOR_TEMP_T_SENSOR | SENSOR_FAN_CPU_OPT,
527+
SENSOR_TEMP_T_SENSOR_ALT1 | SENSOR_FAN_CPU_OPT,
523528
.mutex_path = ACPI_GLOBAL_LOCK_PSEUDO_PATH,
524529
.family = family_amd_600_series,
525530
};

drivers/hwmon/occ/common.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ static ssize_t occ_show_freq_2(struct device *dev,
420420
return sysfs_emit(buf, "%u\n", val);
421421
}
422422

423+
static u64 occ_get_powr_avg(u64 accum, u32 samples)
424+
{
425+
return (samples == 0) ? 0 :
426+
mul_u64_u32_div(accum, 1000000UL, samples);
427+
}
428+
423429
static ssize_t occ_show_power_1(struct device *dev,
424430
struct device_attribute *attr, char *buf)
425431
{
@@ -441,9 +447,8 @@ static ssize_t occ_show_power_1(struct device *dev,
441447
val = get_unaligned_be16(&power->sensor_id);
442448
break;
443449
case 1:
444-
val = get_unaligned_be32(&power->accumulator) /
445-
get_unaligned_be32(&power->update_tag);
446-
val *= 1000000ULL;
450+
val = occ_get_powr_avg(get_unaligned_be32(&power->accumulator),
451+
get_unaligned_be32(&power->update_tag));
447452
break;
448453
case 2:
449454
val = (u64)get_unaligned_be32(&power->update_tag) *
@@ -459,12 +464,6 @@ static ssize_t occ_show_power_1(struct device *dev,
459464
return sysfs_emit(buf, "%llu\n", val);
460465
}
461466

462-
static u64 occ_get_powr_avg(u64 accum, u32 samples)
463-
{
464-
return (samples == 0) ? 0 :
465-
mul_u64_u32_div(accum, 1000000UL, samples);
466-
}
467-
468467
static ssize_t occ_show_power_2(struct device *dev,
469468
struct device_attribute *attr, char *buf)
470469
{
@@ -725,7 +724,7 @@ static ssize_t occ_show_extended(struct device *dev,
725724
switch (sattr->nr) {
726725
case 0:
727726
if (extn->flags & EXTN_FLAG_SENSOR_ID) {
728-
rc = sysfs_emit(buf, "%u",
727+
rc = sysfs_emit(buf, "%u\n",
729728
get_unaligned_be32(&extn->sensor_id));
730729
} else {
731730
rc = sysfs_emit(buf, "%4phN\n", extn->name);

drivers/hwmon/pmbus/ltc4286.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,4 @@ module_i2c_driver(ltc4286_driver);
173173
MODULE_AUTHOR("Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>");
174174
MODULE_DESCRIPTION("PMBUS driver for LTC4286 and compatibles");
175175
MODULE_LICENSE("GPL");
176+
MODULE_IMPORT_NS("PMBUS");

drivers/hwmon/pmbus/pxe1610.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ static int pxe1610_probe(struct i2c_client *client)
104104
* By default this device doesn't boot to page 0, so set page 0
105105
* to access all pmbus registers.
106106
*/
107-
i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
107+
ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
108+
if (ret < 0)
109+
return dev_err_probe(&client->dev, ret,
110+
"Failed to set page 0\n");
108111

109112
/* Read Manufacturer id */
110113
ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);

drivers/hwmon/pmbus/tps53679.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ static int tps53679_identify_chip(struct i2c_client *client,
103103
}
104104

105105
ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, buf);
106-
if (ret < 0)
107-
return ret;
106+
if (ret <= 0)
107+
return ret < 0 ? ret : -EIO;
108108

109-
/* Adjust length if null terminator if present */
109+
/* Adjust length if null terminator is present */
110110
buf_len = (buf[ret - 1] != '\x00' ? ret : ret - 1);
111111

112112
id_len = strlen(id);
@@ -175,8 +175,8 @@ static int tps53676_identify(struct i2c_client *client,
175175
ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, buf);
176176
if (ret < 0)
177177
return ret;
178-
if (strncmp("TI\x53\x67\x60", buf, 5)) {
179-
dev_err(&client->dev, "Unexpected device ID: %s\n", buf);
178+
if (ret != 6 || memcmp(buf, "TI\x53\x67\x60\x00", 6)) {
179+
dev_err(&client->dev, "Unexpected device ID: %*ph\n", ret, buf);
180180
return -ENODEV;
181181
}
182182

0 commit comments

Comments
 (0)