Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+46 -255
-1
Documentation/devicetree/bindings/hwmon/kontron,sl28cpld-hwmon.yaml
··· 16 16 properties: 17 17 compatible: 18 18 enum: 19 - - kontron,sa67mcu-hwmon 20 19 - kontron,sl28cpld-fan 21 20 22 21 reg:
+1 -1
Documentation/hwmon/emc1403.rst
··· 57 57 - https://ww1.microchip.com/downloads/en/DeviceDoc/EMC1438%20DS%20Rev.%201.0%20(04-29-10).pdf 58 58 59 59 Author: 60 - Kalhan Trisal <kalhan.trisal@intel.com 60 + Kalhan Trisal <kalhan.trisal@intel.com> 61 61 62 62 63 63 Description
-1
Documentation/hwmon/index.rst
··· 220 220 q54sj108a2 221 221 qnap-mcu-hwmon 222 222 raspberrypi-hwmon 223 - sa67 224 223 sbrmi 225 224 sbtsi_temp 226 225 sch5627
-41
Documentation/hwmon/sa67.rst
··· 1 - .. SPDX-License-Identifier: GPL-2.0-only 2 - 3 - Kernel driver sa67mcu 4 - ===================== 5 - 6 - Supported chips: 7 - 8 - * Kontron sa67mcu 9 - 10 - Prefix: 'sa67mcu' 11 - 12 - Datasheet: not available 13 - 14 - Authors: Michael Walle <mwalle@kernel.org> 15 - 16 - Description 17 - ----------- 18 - 19 - The sa67mcu is a board management controller which also exposes a hardware 20 - monitoring controller. 21 - 22 - The controller has two voltage and one temperature sensor. The values are 23 - hold in two 8 bit registers to form one 16 bit value. Reading the lower byte 24 - will also capture the high byte to make the access atomic. The unit of the 25 - volatge sensors are 1mV and the unit of the temperature sensor is 0.1degC. 26 - 27 - Sysfs entries 28 - ------------- 29 - 30 - The following attributes are supported. 31 - 32 - ======================= ======================================================== 33 - in0_label "VDDIN" 34 - in0_input Measured VDDIN voltage. 35 - 36 - in1_label "VDD_RTC" 37 - in1_input Measured VDD_RTC voltage. 38 - 39 - temp1_input MCU temperature. Roughly the board temperature. 40 - ======================= ======================================================== 41 -
-1
MAINTAINERS
··· 24320 24320 F: Documentation/devicetree/bindings/pwm/kontron,sl28cpld-pwm.yaml 24321 24321 F: Documentation/devicetree/bindings/watchdog/kontron,sl28cpld-wdt.yaml 24322 24322 F: drivers/gpio/gpio-sl28cpld.c 24323 - F: drivers/hwmon/sa67mcu-hwmon.c 24324 24323 F: drivers/hwmon/sl28cpld-hwmon.c 24325 24324 F: drivers/irqchip/irq-sl28cpld.c 24326 24325 F: drivers/pwm/pwm-sl28cpld.c
-10
drivers/hwmon/Kconfig
··· 1927 1927 This driver can also be built as a module. If so, the module 1928 1928 will be called raspberrypi-hwmon. 1929 1929 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 - 1940 1930 config SENSORS_SL28CPLD 1941 1931 tristate "Kontron sl28cpld hardware monitoring driver" 1942 1932 depends on MFD_SL28CPLD || COMPILE_TEST
-1
drivers/hwmon/Makefile
··· 199 199 obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o 200 200 obj-$(CONFIG_SENSORS_QNAP_MCU_HWMON) += qnap-mcu-hwmon.o 201 201 obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o 202 - obj-$(CONFIG_SENSORS_SA67MCU) += sa67mcu-hwmon.o 203 202 obj-$(CONFIG_SENSORS_SBTSI) += sbtsi_temp.o 204 203 obj-$(CONFIG_SENSORS_SBRMI) += sbrmi.o 205 204 obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o
+4 -2
drivers/hwmon/aht10.c
··· 37 37 #define AHT10_CMD_MEAS 0b10101100 38 38 #define AHT10_CMD_RST 0b10111010 39 39 40 - #define DHT20_CMD_INIT 0x71 40 + #define AHT20_CMD_INIT 0b10111110 41 + 42 + #define DHT20_CMD_INIT 0b01110001 41 43 42 44 /* 43 45 * Flags in the answer byte/command ··· 343 341 data->meas_size = AHT20_MEAS_SIZE; 344 342 data->crc8 = true; 345 343 crc8_populate_msb(crc8_table, AHT20_CRC8_POLY); 346 - data->init_cmd = AHT10_CMD_INIT; 344 + data->init_cmd = AHT20_CMD_INIT; 347 345 break; 348 346 case dht20: 349 347 data->meas_size = AHT20_MEAS_SIZE;
+4 -1
drivers/hwmon/it87.c
··· 3590 3590 { 3591 3591 struct platform_device *pdev = to_platform_device(dev); 3592 3592 struct it87_data *data = dev_get_drvdata(dev); 3593 + int err; 3593 3594 3594 3595 it87_resume_sio(pdev); 3595 3596 3596 - it87_lock(data); 3597 + err = it87_lock(data); 3598 + if (err) 3599 + return err; 3597 3600 3598 3601 it87_check_pwm(dev); 3599 3602 it87_check_limit_regs(data);
+26 -25
drivers/hwmon/macsmc-hwmon.c
··· 22 22 23 23 #include <linux/bitfield.h> 24 24 #include <linux/hwmon.h> 25 + #include <linux/math64.h> 25 26 #include <linux/mfd/macsmc.h> 26 27 #include <linux/module.h> 27 28 #include <linux/of.h> ··· 131 130 if (ret < 0) 132 131 return ret; 133 132 134 - *p = mult_frac(val, scale, 65536); 133 + *p = mul_u64_u32_div(val, scale, 65536); 135 134 136 135 return 0; 137 136 } ··· 141 140 * them. 142 141 */ 143 142 static int macsmc_hwmon_read_f32_scaled(struct apple_smc *smc, smc_key key, 144 - int *p, int scale) 143 + long *p, int scale) 145 144 { 146 145 u32 fval; 147 146 u64 val; ··· 163 162 val = 0; 164 163 else if (exp < 0) 165 164 val >>= -exp; 166 - else if (exp != 0 && (val & ~((1UL << (64 - exp)) - 1))) /* overflow */ 165 + else if (exp != 0 && (val & ~((1ULL << (64 - exp)) - 1))) /* overflow */ 167 166 val = U64_MAX; 168 167 else 169 168 val <<= exp; 170 169 171 170 if (fval & FLT_SIGN_MASK) { 172 - if (val > (-(s64)INT_MIN)) 173 - *p = INT_MIN; 171 + if (val > (u64)LONG_MAX + 1) 172 + *p = LONG_MIN; 174 173 else 175 - *p = -val; 174 + *p = -(long)val; 176 175 } else { 177 - if (val > INT_MAX) 178 - *p = INT_MAX; 176 + if (val > (u64)LONG_MAX) 177 + *p = LONG_MAX; 179 178 else 180 - *p = val; 179 + *p = (long)val; 181 180 } 182 181 183 182 return 0; ··· 196 195 switch (sensor->info.type_code) { 197 196 /* 32-bit IEEE 754 float */ 198 197 case __SMC_KEY('f', 'l', 't', ' '): { 199 - u32 flt_ = 0; 198 + long flt_ = 0; 200 199 201 200 ret = macsmc_hwmon_read_f32_scaled(smc, sensor->macsmc_key, 202 201 &flt_, scale); ··· 215 214 if (ret) 216 215 return ret; 217 216 218 - *val = (long)ioft; 217 + if (ioft > LONG_MAX) 218 + *val = LONG_MAX; 219 + else 220 + *val = (long)ioft; 219 221 break; 220 222 } 221 223 default: ··· 228 224 return 0; 229 225 } 230 226 231 - static int macsmc_hwmon_write_f32(struct apple_smc *smc, smc_key key, int value) 227 + static int macsmc_hwmon_write_f32(struct apple_smc *smc, smc_key key, long value) 232 228 { 233 229 u64 val; 234 230 u32 fval = 0; 235 - int exp = 0, neg; 231 + int exp, neg; 236 232 233 + neg = value < 0; 237 234 val = abs(value); 238 - neg = val != value; 239 235 240 236 if (val) { 241 - int msb = __fls(val) - exp; 237 + exp = __fls(val); 242 238 243 - if (msb > 23) { 244 - val >>= msb - FLT_MANT_BIAS; 245 - exp -= msb - FLT_MANT_BIAS; 246 - } else if (msb < 23) { 247 - val <<= FLT_MANT_BIAS - msb; 248 - exp += msb; 249 - } 239 + if (exp > 23) 240 + val >>= exp - 23; 241 + else 242 + val <<= 23 - exp; 250 243 251 244 fval = FIELD_PREP(FLT_SIGN_MASK, neg) | 252 245 FIELD_PREP(FLT_EXP_MASK, exp + FLT_EXP_BIAS) | 253 - FIELD_PREP(FLT_MANT_MASK, val); 246 + FIELD_PREP(FLT_MANT_MASK, val & FLT_MANT_MASK); 254 247 } 255 248 256 249 return apple_smc_write_u32(smc, key, fval); ··· 664 663 if (!hwmon->volt.sensors) 665 664 return -ENOMEM; 666 665 667 - for_each_child_of_node_with_prefix(hwmon_node, key_node, "volt-") { 668 - sensor = &hwmon->temp.sensors[hwmon->temp.count]; 666 + for_each_child_of_node_with_prefix(hwmon_node, key_node, "voltage-") { 667 + sensor = &hwmon->volt.sensors[hwmon->volt.count]; 669 668 if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) { 670 669 sensor->attrs = HWMON_I_INPUT; 671 670
+1 -1
drivers/hwmon/max6639.c
··· 607 607 return err; 608 608 609 609 /* Fans PWM polarity high by default */ 610 - err = regmap_write(data->regmap, MAX6639_REG_FAN_CONFIG2a(i), 0x00); 610 + err = regmap_write(data->regmap, MAX6639_REG_FAN_CONFIG2a(i), 0x02); 611 611 if (err) 612 612 return err; 613 613
+10 -9
drivers/hwmon/pmbus/q54sj108a2.c
··· 79 79 int idx = *idxp; 80 80 struct q54sj108a2_data *psu = to_psu(idxp, idx); 81 81 char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; 82 - char data_char[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; 82 + char data_char[I2C_SMBUS_BLOCK_MAX * 2 + 2] = { 0 }; 83 + char *out = data; 83 84 char *res; 84 85 85 86 switch (idx) { ··· 151 150 if (rc < 0) 152 151 return rc; 153 152 154 - res = bin2hex(data, data_char, 32); 155 - rc = res - data; 156 - 153 + res = bin2hex(data_char, data, rc); 154 + rc = res - data_char; 155 + out = data_char; 157 156 break; 158 157 case Q54SJ108A2_DEBUGFS_FLASH_KEY: 159 158 rc = i2c_smbus_read_block_data(psu->client, PMBUS_FLASH_KEY_WRITE, data); 160 159 if (rc < 0) 161 160 return rc; 162 161 163 - res = bin2hex(data, data_char, 4); 164 - rc = res - data; 165 - 162 + res = bin2hex(data_char, data, rc); 163 + rc = res - data_char; 164 + out = data_char; 166 165 break; 167 166 default: 168 167 return -EINVAL; 169 168 } 170 169 171 - data[rc] = '\n'; 170 + out[rc] = '\n'; 172 171 rc += 2; 173 172 174 - return simple_read_from_buffer(buf, count, ppos, data, rc); 173 + return simple_read_from_buffer(buf, count, ppos, out, rc); 175 174 } 176 175 177 176 static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *buf,
-161
drivers/hwmon/sa67mcu-hwmon.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * sl67mcu hardware monitoring driver 4 - * 5 - * Copyright 2025 Kontron Europe GmbH 6 - */ 7 - 8 - #include <linux/bitfield.h> 9 - #include <linux/hwmon.h> 10 - #include <linux/kernel.h> 11 - #include <linux/mod_devicetable.h> 12 - #include <linux/module.h> 13 - #include <linux/platform_device.h> 14 - #include <linux/property.h> 15 - #include <linux/regmap.h> 16 - 17 - #define SA67MCU_VOLTAGE(n) (0x00 + ((n) * 2)) 18 - #define SA67MCU_TEMP(n) (0x04 + ((n) * 2)) 19 - 20 - struct sa67mcu_hwmon { 21 - struct regmap *regmap; 22 - u32 offset; 23 - }; 24 - 25 - static int sa67mcu_hwmon_read(struct device *dev, 26 - enum hwmon_sensor_types type, u32 attr, 27 - int channel, long *input) 28 - { 29 - struct sa67mcu_hwmon *hwmon = dev_get_drvdata(dev); 30 - unsigned int offset; 31 - u8 reg[2]; 32 - int ret; 33 - 34 - switch (type) { 35 - case hwmon_in: 36 - switch (attr) { 37 - case hwmon_in_input: 38 - offset = hwmon->offset + SA67MCU_VOLTAGE(channel); 39 - break; 40 - default: 41 - return -EOPNOTSUPP; 42 - } 43 - break; 44 - case hwmon_temp: 45 - switch (attr) { 46 - case hwmon_temp_input: 47 - offset = hwmon->offset + SA67MCU_TEMP(channel); 48 - break; 49 - default: 50 - return -EOPNOTSUPP; 51 - } 52 - break; 53 - default: 54 - return -EOPNOTSUPP; 55 - } 56 - 57 - /* Reading the low byte will capture the value */ 58 - ret = regmap_bulk_read(hwmon->regmap, offset, reg, ARRAY_SIZE(reg)); 59 - if (ret) 60 - return ret; 61 - 62 - *input = reg[1] << 8 | reg[0]; 63 - 64 - /* Temperatures are s16 and in 0.1degC steps. */ 65 - if (type == hwmon_temp) 66 - *input = sign_extend32(*input, 15) * 100; 67 - 68 - return 0; 69 - } 70 - 71 - static const struct hwmon_channel_info * const sa67mcu_hwmon_info[] = { 72 - HWMON_CHANNEL_INFO(in, 73 - HWMON_I_INPUT | HWMON_I_LABEL, 74 - HWMON_I_INPUT | HWMON_I_LABEL), 75 - HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), 76 - NULL 77 - }; 78 - 79 - static const char *const sa67mcu_hwmon_in_labels[] = { 80 - "VDDIN", 81 - "VDD_RTC", 82 - }; 83 - 84 - static int sa67mcu_hwmon_read_string(struct device *dev, 85 - enum hwmon_sensor_types type, u32 attr, 86 - int channel, const char **str) 87 - { 88 - switch (type) { 89 - case hwmon_in: 90 - switch (attr) { 91 - case hwmon_in_label: 92 - *str = sa67mcu_hwmon_in_labels[channel]; 93 - return 0; 94 - default: 95 - return -EOPNOTSUPP; 96 - } 97 - default: 98 - return -EOPNOTSUPP; 99 - } 100 - } 101 - 102 - static const struct hwmon_ops sa67mcu_hwmon_ops = { 103 - .visible = 0444, 104 - .read = sa67mcu_hwmon_read, 105 - .read_string = sa67mcu_hwmon_read_string, 106 - }; 107 - 108 - static const struct hwmon_chip_info sa67mcu_hwmon_chip_info = { 109 - .ops = &sa67mcu_hwmon_ops, 110 - .info = sa67mcu_hwmon_info, 111 - }; 112 - 113 - static int sa67mcu_hwmon_probe(struct platform_device *pdev) 114 - { 115 - struct sa67mcu_hwmon *hwmon; 116 - struct device *hwmon_dev; 117 - int ret; 118 - 119 - if (!pdev->dev.parent) 120 - return -ENODEV; 121 - 122 - hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL); 123 - if (!hwmon) 124 - return -ENOMEM; 125 - 126 - hwmon->regmap = dev_get_regmap(pdev->dev.parent, NULL); 127 - if (!hwmon->regmap) 128 - return -ENODEV; 129 - 130 - ret = device_property_read_u32(&pdev->dev, "reg", &hwmon->offset); 131 - if (ret) 132 - return -EINVAL; 133 - 134 - hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, 135 - "sa67mcu_hwmon", hwmon, 136 - &sa67mcu_hwmon_chip_info, 137 - NULL); 138 - if (IS_ERR(hwmon_dev)) 139 - dev_err(&pdev->dev, "failed to register as hwmon device"); 140 - 141 - return PTR_ERR_OR_ZERO(hwmon_dev); 142 - } 143 - 144 - static const struct of_device_id sa67mcu_hwmon_of_match[] = { 145 - { .compatible = "kontron,sa67mcu-hwmon", }, 146 - {} 147 - }; 148 - MODULE_DEVICE_TABLE(of, sa67mcu_hwmon_of_match); 149 - 150 - static struct platform_driver sa67mcu_hwmon_driver = { 151 - .probe = sa67mcu_hwmon_probe, 152 - .driver = { 153 - .name = "sa67mcu-hwmon", 154 - .of_match_table = sa67mcu_hwmon_of_match, 155 - }, 156 - }; 157 - module_platform_driver(sa67mcu_hwmon_driver); 158 - 159 - MODULE_DESCRIPTION("sa67mcu Hardware Monitoring Driver"); 160 - MODULE_AUTHOR("Michael Walle <mwalle@kernel.org>"); 161 - MODULE_LICENSE("GPL");