Skip to content

Commit 7b6e48d

Browse files
committed
Merge tag 'hwmon-for-v7.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - Fix initialization commands for AHT20 - Correct a malformed email address (emc1403) - Check the it87_lock() return value - Fix inverted polarity (max6639) - Fix overflows, underflows, sign extension, and other problems in macsmc - Fix stack overflow in debugfs read (pmbus/q54sj108a2) - Drop support for SMARC-sAM67 (discontinued and never released to market) * tag 'hwmon-for-v7.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (pmbus/q54sj108a2) fix stack overflow in debugfs read hwmon: (max6639) fix inverted polarity dt-bindings: hwmon: sl28cpld: Drop sa67mcu compatible hwmon: (it87) Check the it87_lock() return value Revert "hwmon: add SMARC-sAM67 support" hwmon: (aht10) Fix initialization commands for AHT20 hwmon: (emc1403) correct a malformed email address hwmon: (macsmc) Fix overflows, underflows, and sign extension hwmon: (macsmc) Fix regressions in Apple Silicon SMC hwmon driver
2 parents e33aafa + 25dd70a commit 7b6e48d

13 files changed

Lines changed: 47 additions & 256 deletions

File tree

Documentation/devicetree/bindings/hwmon/kontron,sl28cpld-hwmon.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ description: |
1616
properties:
1717
compatible:
1818
enum:
19-
- kontron,sa67mcu-hwmon
2019
- kontron,sl28cpld-fan
2120

2221
reg:

Documentation/hwmon/emc1403.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Supported chips:
5757
- https://ww1.microchip.com/downloads/en/DeviceDoc/EMC1438%20DS%20Rev.%201.0%20(04-29-10).pdf
5858

5959
Author:
60-
Kalhan Trisal <kalhan.trisal@intel.com
60+
Kalhan Trisal <kalhan.trisal@intel.com>
6161

6262

6363
Description

Documentation/hwmon/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ Hardware Monitoring Kernel Drivers
220220
q54sj108a2
221221
qnap-mcu-hwmon
222222
raspberrypi-hwmon
223-
sa67
224223
sbrmi
225224
sbtsi_temp
226225
sch5627

Documentation/hwmon/sa67.rst

Lines changed: 0 additions & 41 deletions
This file was deleted.

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24320,7 +24320,6 @@ F: Documentation/devicetree/bindings/interrupt-controller/kontron,sl28cpld-intc.
2432024320
F: Documentation/devicetree/bindings/pwm/kontron,sl28cpld-pwm.yaml
2432124321
F: Documentation/devicetree/bindings/watchdog/kontron,sl28cpld-wdt.yaml
2432224322
F: drivers/gpio/gpio-sl28cpld.c
24323-
F: drivers/hwmon/sa67mcu-hwmon.c
2432424323
F: drivers/hwmon/sl28cpld-hwmon.c
2432524324
F: drivers/irqchip/irq-sl28cpld.c
2432624325
F: drivers/pwm/pwm-sl28cpld.c

drivers/hwmon/Kconfig

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,16 +1927,6 @@ config SENSORS_RASPBERRYPI_HWMON
19271927
This driver can also be built as a module. If so, the module
19281928
will be called raspberrypi-hwmon.
19291929

1930-
config SENSORS_SA67MCU
1931-
tristate "Kontron sa67mcu hardware monitoring driver"
1932-
depends on MFD_SL28CPLD || COMPILE_TEST
1933-
help
1934-
If you say yes here you get support for the voltage and temperature
1935-
monitor of the sa67 board management controller.
1936-
1937-
This driver can also be built as a module. If so, the module
1938-
will be called sa67mcu-hwmon.
1939-
19401930
config SENSORS_SL28CPLD
19411931
tristate "Kontron sl28cpld hardware monitoring driver"
19421932
depends on MFD_SL28CPLD || COMPILE_TEST

drivers/hwmon/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ obj-$(CONFIG_SENSORS_PT5161L) += pt5161l.o
199199
obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o
200200
obj-$(CONFIG_SENSORS_QNAP_MCU_HWMON) += qnap-mcu-hwmon.o
201201
obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o
202-
obj-$(CONFIG_SENSORS_SA67MCU) += sa67mcu-hwmon.o
203202
obj-$(CONFIG_SENSORS_SBTSI) += sbtsi_temp.o
204203
obj-$(CONFIG_SENSORS_SBRMI) += sbrmi.o
205204
obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o

drivers/hwmon/aht10.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
#define AHT10_CMD_MEAS 0b10101100
3838
#define AHT10_CMD_RST 0b10111010
3939

40-
#define DHT20_CMD_INIT 0x71
40+
#define AHT20_CMD_INIT 0b10111110
41+
42+
#define DHT20_CMD_INIT 0b01110001
4143

4244
/*
4345
* Flags in the answer byte/command
@@ -341,7 +343,7 @@ static int aht10_probe(struct i2c_client *client)
341343
data->meas_size = AHT20_MEAS_SIZE;
342344
data->crc8 = true;
343345
crc8_populate_msb(crc8_table, AHT20_CRC8_POLY);
344-
data->init_cmd = AHT10_CMD_INIT;
346+
data->init_cmd = AHT20_CMD_INIT;
345347
break;
346348
case dht20:
347349
data->meas_size = AHT20_MEAS_SIZE;

drivers/hwmon/it87.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3590,10 +3590,13 @@ static int it87_resume(struct device *dev)
35903590
{
35913591
struct platform_device *pdev = to_platform_device(dev);
35923592
struct it87_data *data = dev_get_drvdata(dev);
3593+
int err;
35933594

35943595
it87_resume_sio(pdev);
35953596

3596-
it87_lock(data);
3597+
err = it87_lock(data);
3598+
if (err)
3599+
return err;
35973600

35983601
it87_check_pwm(dev);
35993602
it87_check_limit_regs(data);

drivers/hwmon/macsmc-hwmon.c

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <linux/bitfield.h>
2424
#include <linux/hwmon.h>
25+
#include <linux/math64.h>
2526
#include <linux/mfd/macsmc.h>
2627
#include <linux/module.h>
2728
#include <linux/of.h>
@@ -130,7 +131,7 @@ static int macsmc_hwmon_read_ioft_scaled(struct apple_smc *smc, smc_key key,
130131
if (ret < 0)
131132
return ret;
132133

133-
*p = mult_frac(val, scale, 65536);
134+
*p = mul_u64_u32_div(val, scale, 65536);
134135

135136
return 0;
136137
}
@@ -140,7 +141,7 @@ static int macsmc_hwmon_read_ioft_scaled(struct apple_smc *smc, smc_key key,
140141
* them.
141142
*/
142143
static int macsmc_hwmon_read_f32_scaled(struct apple_smc *smc, smc_key key,
143-
int *p, int scale)
144+
long *p, int scale)
144145
{
145146
u32 fval;
146147
u64 val;
@@ -162,21 +163,21 @@ static int macsmc_hwmon_read_f32_scaled(struct apple_smc *smc, smc_key key,
162163
val = 0;
163164
else if (exp < 0)
164165
val >>= -exp;
165-
else if (exp != 0 && (val & ~((1UL << (64 - exp)) - 1))) /* overflow */
166+
else if (exp != 0 && (val & ~((1ULL << (64 - exp)) - 1))) /* overflow */
166167
val = U64_MAX;
167168
else
168169
val <<= exp;
169170

170171
if (fval & FLT_SIGN_MASK) {
171-
if (val > (-(s64)INT_MIN))
172-
*p = INT_MIN;
172+
if (val > (u64)LONG_MAX + 1)
173+
*p = LONG_MIN;
173174
else
174-
*p = -val;
175+
*p = -(long)val;
175176
} else {
176-
if (val > INT_MAX)
177-
*p = INT_MAX;
177+
if (val > (u64)LONG_MAX)
178+
*p = LONG_MAX;
178179
else
179-
*p = val;
180+
*p = (long)val;
180181
}
181182

182183
return 0;
@@ -195,7 +196,7 @@ static int macsmc_hwmon_read_key(struct apple_smc *smc,
195196
switch (sensor->info.type_code) {
196197
/* 32-bit IEEE 754 float */
197198
case __SMC_KEY('f', 'l', 't', ' '): {
198-
u32 flt_ = 0;
199+
long flt_ = 0;
199200

200201
ret = macsmc_hwmon_read_f32_scaled(smc, sensor->macsmc_key,
201202
&flt_, scale);
@@ -214,7 +215,10 @@ static int macsmc_hwmon_read_key(struct apple_smc *smc,
214215
if (ret)
215216
return ret;
216217

217-
*val = (long)ioft;
218+
if (ioft > LONG_MAX)
219+
*val = LONG_MAX;
220+
else
221+
*val = (long)ioft;
218222
break;
219223
}
220224
default:
@@ -224,29 +228,26 @@ static int macsmc_hwmon_read_key(struct apple_smc *smc,
224228
return 0;
225229
}
226230

227-
static int macsmc_hwmon_write_f32(struct apple_smc *smc, smc_key key, int value)
231+
static int macsmc_hwmon_write_f32(struct apple_smc *smc, smc_key key, long value)
228232
{
229233
u64 val;
230234
u32 fval = 0;
231-
int exp = 0, neg;
235+
int exp, neg;
232236

237+
neg = value < 0;
233238
val = abs(value);
234-
neg = val != value;
235239

236240
if (val) {
237-
int msb = __fls(val) - exp;
238-
239-
if (msb > 23) {
240-
val >>= msb - FLT_MANT_BIAS;
241-
exp -= msb - FLT_MANT_BIAS;
242-
} else if (msb < 23) {
243-
val <<= FLT_MANT_BIAS - msb;
244-
exp += msb;
245-
}
241+
exp = __fls(val);
242+
243+
if (exp > 23)
244+
val >>= exp - 23;
245+
else
246+
val <<= 23 - exp;
246247

247248
fval = FIELD_PREP(FLT_SIGN_MASK, neg) |
248249
FIELD_PREP(FLT_EXP_MASK, exp + FLT_EXP_BIAS) |
249-
FIELD_PREP(FLT_MANT_MASK, val);
250+
FIELD_PREP(FLT_MANT_MASK, val & FLT_MANT_MASK);
250251
}
251252

252253
return apple_smc_write_u32(smc, key, fval);
@@ -663,8 +664,8 @@ static int macsmc_hwmon_populate_sensors(struct macsmc_hwmon *hwmon,
663664
if (!hwmon->volt.sensors)
664665
return -ENOMEM;
665666

666-
for_each_child_of_node_with_prefix(hwmon_node, key_node, "volt-") {
667-
sensor = &hwmon->temp.sensors[hwmon->temp.count];
667+
for_each_child_of_node_with_prefix(hwmon_node, key_node, "voltage-") {
668+
sensor = &hwmon->volt.sensors[hwmon->volt.count];
668669
if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) {
669670
sensor->attrs = HWMON_I_INPUT;
670671

0 commit comments

Comments
 (0)