summaryrefslogtreecommitdiff
path: root/drivers/hwmon
AgeCommit message (Collapse)Author
2026-06-09hwmon: (ina2xx) Use scoped_guard() to acquire the subsystem lockGuenter Roeck
Use scoped_guard() instead of hwmon_lock() / hwmon_unlock() to acquire and release the hardware monitoring subsystem lock. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (lm90) Use guard() and scoped_guard() to acquire subsystem lockGuenter Roeck
Use guard() and scoped_guard() instead of hwmon_lock() / hwmon_unlock() to acquire and release the hardware monitoring subsystem lock. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (pmbus/d1u74t) Add Murata D1U74T PSU driverAbdurrahman Hussain
Add PMBUS driver for Murata D1U74T power supplies. Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260514-d1u74t-v4-2-1f1ee7b002ec@nexthop.ai [groeck: Dropped inappropriate tags; added missing include files] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (coretemp) fix coding style issuesRoman Bakshansky
Address several coding style warnings reported by checkpatch.pl: - Replace <asm/processor.h> with <linux/processor.h> - Add missing blank lines after declarations - Combine split quoted strings - Reorder __initconst placement No functional change. Signed-off-by: Roman Bakshansky <bakshansky.lists@gmail.com> Link: https://lore.kernel.org/r/20260516114253.5466-3-bakshansky.lists@gmail.com [groeck: Dropped false positive change. Fixed various CHECK reports.] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (coretemp) replace hardcoded core count with dynamic valueRoman Bakshansky
The hardcoded maximum of 512 cores per package was first defined by commit 34cf8c657cf0 ("hwmon: (coretemp) Enlarge per package core count limit") and later kept as a fallback with a TODO in commit 1a793caf6f69 ("hwmon: (coretemp) Use dynamic allocated memory for core temp_data") because the actual per-package core count was not reliably available at the time. Now that topology_num_cores_per_package() is stable and suitable for use, it's time to complete the TODO and allocate only the needed amount of memory for core_data. Signed-off-by: Roman Bakshansky <bakshansky.lists@gmail.com> Link: https://lore.kernel.org/r/20260516114253.5466-2-bakshansky.lists@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (pmbus/adm1266) add firmware_revision debugfs entryAbdurrahman Hussain
The ADM1266 reports its firmware revision via the IC_DEVICE_REV manufacturer-specific block-read command (0xAE, datasheet Rev. D Table 80). The first three returned bytes are the firmware major.minor.patch fields. This is useful when correlating field behaviour against ADI release notes; expose it through debugfs alongside the existing sequencer_state entry. The standard PMBus MFR_REVISION (0x9B) register is already exposed by pmbus_core's debugfs auto-create path and reports the manufacturer revision, which is a separate thing from the firmware running on the device. Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260512-adm1266-v3-1-a81a479b0bb0@nexthop.ai [groeck: Squashed patch adding serialization with pmbus_lock] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (nct7802) Add time step attributes for tweaking responsivenessRonan Dalton
The nct7802 chip exposes two registers that allow setting the time interval between successive duty increases or decreases in Smart Fan mode. The units are intervals of 0.1 second. The default value at power on is 10, so 1 second. Add sysfs attributes for step_up_time and step_down_time to allow controlling the responsiveness of the fan speed. Values are represented as milliseconds to the user. When set, the value is clamped to the valid range of 100 to 25500 (0.1 to 25.5 seconds), and rounded to the nearest multiple of 100. Signed-off-by: Ronan Dalton <ronan.dalton@alliedtelesis.co.nz> Cc: linux-kernel@vger.kernel.org Cc: linux-hwmon@vger.kernel.org Cc: Guenter Roeck <linux@roeck-us.net> Cc: Chris Packham <chris.packham@alliedtelesis.co.nz> Link: https://lore.kernel.org/r/20260514003404.1548747-2-ronan.dalton@alliedtelesis.co.nz Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: Use named initializers for arrays of i2c_device_dataUwe Kleine-König (The Capable Hub)
While being less compact, using named initializers allows to more easily see which members of the structs are assigned which value without having to lookup the declaration of the struct. And it's also more robust against changes to the struct definition. The mentioned robustness is relevant for a planned change to struct i2c_device_id that replaces .driver_data by an anonymous union. While touching all these arrays, unify indention and usage of commas. This patch doesn't modify the compiled arrays, only their representation in source form benefits. The former was confirmed with x86 and arm64 builds. Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/65b77bcd452752c36d866069cc5790b26d2bf8dc.1778688803.git.u.kleine-koenig@baylibre.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: Drop unused i2c driver_dataUwe Kleine-König (The Capable Hub)
The four drivers all don't make use of the value that was explicitly assigned to the .driver_data member. Drop the assignment. While touching these lines also make the assignments use named initializers and drop a comma after the end-of-list marker. Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # For Link: https://lore.kernel.org/r/e8ceb3931975813545a8b478cc1a71b4ede9a6c0.1778688803.git.u.kleine-koenig@baylibre.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (pmbus/mp2869) Drop unjustified __maybe_unusedUwe Kleine-König (The Capable Hub)
mp2869_of_match is used unconditionally in mp2869_driver, so there is no need for the __maybe_unused marker. Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/3ec2ee181d4f5bfc48c3745f9ce4fdbd1e8fb01e.1778603083.git.ukleinek@kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (pmbus/mp2869) Remove unused driver dataUwe Kleine-König (The Capable Hub)
The driver doesn't make use of the i2c .driver_data and the of .data. So drop the useless and irritating assignments. While touching all these lines, use named initializers for the i2c device ids and convert to the most common usage of spacing in such arrays. Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/dcfcc82a93da77b55503998c5c7acf2a80c4a615.1778603083.git.ukleinek@kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (tmp102) Use device_property_read_string APIFlaviu Nistor
Replace of_property_read_string() with the preferded device_property_read_string() in the probe function to read the device label property, improving the driver compatibility since this method is not limited to Device Tree only. Also drop the now unnecessary __maybe_unused from tmp102_of_match. Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com> Link: https://lore.kernel.org/r/20260510092543.12352-1-flaviu.nistor@gmail.com Link: https://lore.kernel.org/r/20260518122210.10288-1-flaviu.nistor@gmail.com [groeck: Combined API change with __maybe_unused patch] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: add driver for ARCTIC Fan ControllerAureo Serrano de Souza
Add hwmon driver for the ARCTIC Fan Controller, a USB HID device (VID 0x3904, PID 0xF001) with 10 fan channels. Exposes fan speed in RPM (read-only) and PWM duty cycle (0-255, read/write) via sysfs. The device pushes IN reports at ~1 Hz containing RPM readings. PWM is set via OUT reports; the device applies the new duty cycle and sends back a 2-byte ACK (Report ID 0x02). The driver waits up to 1 s for the ACK using a completion. Measured device latency: max ~563 ms over 500 iterations. PWM control is manual-only: the device never changes duty cycle autonomously. raw_event() may run in hardirq context, so fan_rpm[] is protected by a spinlock with irq-save. pwm_duty[] is also protected by this spinlock because reset_resume() clears it outside the hwmon core lock. The OUT report buffer is built and write_pending is armed under the same lock so that no reset_resume() can race with the pwm_duty[] snapshot. priv->buf is exclusively accessed by write(), which the hwmon core serializes. Signed-off-by: Aureo Serrano de Souza <aureo.serrano@arctic.de> Link: https://lore.kernel.org/r/20260508064405.38676-1-aureo.serrano@arctic.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (pmbus) add support for Delta E50SN12051Colin Huang
Add the pmbus driver for Delta E50SN12051 600W Non-isolated 1/8th Brick DCDC Power Modules. Signed-off-by: Colin Huang <u8813345@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20260508-add-e50sn12051-v5-3-abebdcc29665@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (pmbus/max20830) add driver for max20830Alexis Czezar Torreno
Add support for MAX20830 step-down DC-DC switching regulator with PMBus interface. It allows monitoring of input/output voltage, output current and temperature through the PMBus serial interface. Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com> Link: https://lore.kernel.org/r/20260505-dev_max20830-v4-2-4343dcbfd7d7@analog.com [groeck: checkpatch cleanup (space before and after '-')] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (lm75) Support active-high alert polarityMarkus Stockhausen
LM75 devices supported by this driver support configurable active-high alert polarity. This is already documented in the devicetree description. Add support for it to the driver. Follow documentation and defensively enforce active-low if property is not set. This avoids possible inconsistencies for future devices with wrong parametrization. No API breakage as all current devices have their parameters set to active-low. Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: https://lore.kernel.org/r/20260504151020.462342-3-markus.stockhausen@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: Move MODULE_DEVICE_TABLE next to the table itselfKrzysztof Kozlowski
By convention MODULE_DEVICE_TABLE() immediately follows the ID table it exports, because this is easier to read and verify. It also makes more sense since #ifdef for ACPI or OF could hide both of them. Most of the privers already have this correctly placed, so adjust the missing ones. No functional impact. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Acked-by: Thomas Weißschuh <linux@weissschuh.net> # cros_ec_hwmon.c Link: https://lore.kernel.org/r/20260505102923.189289-2-krzysztof.kozlowski@oss.qualcomm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (ads7871) Use DMA-safe buffer for SPI writesTabrez Ahmed
The driver currently passes a stack-allocated buffer to spi_write(), which is incompatible with DMA on systems with CONFIG_VMAP_STACK enabled. Move the transfer buffer into the driver's private data structure to ensure it is DMA-safe. Since this shared buffer now requires serialization, this change depends on the previous commit which migrated the driver to the hwmon 'with_info' API. While moving the logic, also: - Corrected the sign extension for 14-bit data by casting to s16. - Scaled the output to millivolts (2500mV full scale ) to comply with the hwmon ABI. Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com> Link: https://lore.kernel.org/r/20260502020844.110038-4-tabreztalks@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (ads7871) Convert to hwmon_device_register_with_infoTabrez Ahmed
Convert the ads7871 driver from the legacy hwmon_device_register() to the modern hwmon_device_register_with_info() API. This migration simplifies the driver by using the structured hwmon_channel_info approach and prepares the codebase for the transition to a shared DMA-safe buffer. While at it, fix checkpatch violations. Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com> Link: https://lore.kernel.org/r/20260502020844.110038-3-tabreztalks@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: emc2305: Support configurable fan PWM at shutdownFlorin Leotescu
Some systems require fans to enter in a defined safe state during system shutdown or reboot handoff. Add support for the optional Device Tree property "fan-shutdown-percent" to configure the shutdown PWM duty cycle per fan output. If the property is present for a fan channel, the driver converts the configured percentage value to the corresponding PWM duty cycle and applies it during driver shutdown. If the property is not present, the fan state remains unchanged. Signed-off-by: Florin Leotescu <florin.leotescu@nxp.com> Link: https://lore.kernel.org/r/20260429065955.2113012-4-florin.leotescu@oss.nxp.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (emc2305) Fix fan channel index handlingFlorin Leotescu
The fan channel index is used to access per-channel data structures. Validate the index against the number of available channels before use to prevent out-of-bounds access if an invalid value is provided. The thermal registration path currently uses a sequential child index, which may not match the validated channel from DT. Use the DT "reg" property when registering cooling devices to ensure consistent channel handling Signed-off-by: Florin Leotescu <florin.leotescu@nxp.com> Link: https://lore.kernel.org/r/20260429065955.2113012-2-florin.leotescu@oss.nxp.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (pmbus/lx1308) Add support for LX1308Brian Chiang
Add support for the Luxshare LX1308, a high-efficiency 12V 860W DC/DC power module. The module operates from 40-60V input voltage. Signed-off-by: Brian Chiang <chiang.brian@inventec.com> Link: https://lore.kernel.org/r/20260428-add-support-lx1308-v2-2-90f115954143@inventec.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-09hwmon: (mcp9982) Add external diode fault readVictor Duicu
Add external diode fault read capability to the MCP998X/33 and MCP998XD/33D driver. Signed-off-by: Victor Duicu <victor.duicu@microchip.com> Link: https://lore.kernel.org/r/20260423-add-external-diode-fault-read-v2-1-4004bb5f7d55@microchip.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-06-08x86/msr: Switch rdmsr_safe_on_cpu() users to rdmsrq_safe_on_cpu()Juergen Gross
In order to prepare retiring rdmsr_safe_on_cpu() switch rdmsr_safe_on_cpu() users to rdmsrq_safe_on_cpu(). Tested-by: K Prateek Nayak <kprateek.nayak@amd.com> Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Rafael J. Wysocki <rafael@kernel.org> Cc: Daniel Lezcano <daniel.lezcano@kernel.org> Link: https://patch.msgid.link/20260608051741.3207435-9-jgross@suse.com
2026-06-08x86/msr: Switch rdmsr_on_cpu() users to rdmsrq_on_cpu()Juergen Gross
In order to prepare retiring rdmsr_on_cpu() switch rdmsr_on_cpu() users to rdmsrq_on_cpu(). Tested-by: K Prateek Nayak <kprateek.nayak@amd.com> Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Cc: Rafael J. Wysocki <rafael@kernel.org> Cc: Viresh Kumar <viresh.kumar@linaro.org> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Daniel Lezcano <daniel.lezcano@kernel.org> Link: https://patch.msgid.link/20260608051741.3207435-4-jgross@suse.com
2026-06-03thermal/of: Rename the devm_thermal_of_cooling_device_register() functionDaniel Lezcano
To clarify that the function operates on child nodes, rename: devm_thermal_of_cooling_device_register() | v devm_thermal_of_child_cooling_device_register() Used the command: find . -type f -name '*.[ch]' -exec \ sed -i 's/devm_thermal_of_cooling_device_register/\ devm_thermal_of_child_cooling_device_register/g' {} \; Did not used clang-format-diff because it does not indent correctly and checkpatch complained. Manually reindented to make checkpatch happy This prepares for upcoming support of cooling devices identified by an ID rather than device tree child nodes. No functional change. Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Link: https://patch.msgid.link/20260526140802.1059293-18-daniel.lezcano@oss.qualcomm.com
2026-06-03hwmon: Use non-OF thermal cooling device registration APIDaniel Lezcano
Some HWMON drivers register cooling devices using the OF helper devm_thermal_of_cooling_device_register() with a NULL device node. With the introduction of a dedicated non-OF registration API, switch these users to devm_thermal_cooling_device_register() to make the intent explicit and avoid relying on OF-specific helpers. This is a pure refactoring with no functional change. Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Acked-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Link: https://patch.msgid.link/20260526140802.1059293-15-daniel.lezcano@oss.qualcomm.com
2026-06-01Merge tag 'v7.1-rc6' into usb-nextGreg Kroah-Hartman
We need the USB and Thunderbolt fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-05-24hwmon: (lm75) Add explicit default cases in lm75_is_visible()Flaviu Nistor
Add explicit default labels to switch statements in lm75_is_visible(). This makes the control flow explicit and improves readability, but also keeps consistency to other usage of the switch statement in the driver. Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com> Link: https://lore.kernel.org/r/20260417055700.5739-1-flaviu.nistor@gmail.com [groeck: Reformatted description for line length] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-24hwmon: add MP2985 driverWensheng Wang
Add support for MPS mp2985 controller. This driver exposes telemetry and limit value readings and writtings. Signed-off-by: Wensheng Wang <wenswang@yeah.net> Link: https://lore.kernel.org/r/20260414092921.1067735-2-wenswang@yeah.net Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-22scsi: core: Convert INQUIRY informationBart Van Assche
Currently the vendor, model, and revision members of struct scsi_device are pointers to fixed-length strings that are not NUL-terminated. Fixed-precision format specifiers (e.g., "%.8s") are required whenever they are printed and strncmp() must be used to compare these fields. This is error-prone. Convert these fields to fixed-size character arrays within struct scsi_device. Remove an !sdev->model check because sdev->model is now guaranteed not to be NULL. This patch fixes a bug in the qla2xxx driver. It makes the following code safe: if (state_flags & BIT_4) scmd_printk(KERN_WARNING, cp, "Unsupported device '%s' found.\n", cp->device->vendor); Signed-off-by: Bart Van Assche <bvanassche@acm.org> Tested-by: Brian Bunker <brian@purestorage.com> Link: https://patch.msgid.link/20260515205222.1754621-4-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2026-05-21hwmon: add AMD Promontory 21 xHCI temperature sensor supportJihong Min
Add an auxiliary-bus hwmon driver for the temperature sensor exposed by AMD Promontory 21 (PROM21) xHCI PCI functions. The driver binds to the "hwmon" auxiliary device published by the PROM21 xHCI PCI glue and exposes the sensor as temp1_input under the prom21_xhci hwmon device. The sensor is accessed through a PROM21 vendor index/data register pair in the xHCI PCI MMIO BAR. The driver consumes parent-provided MMIO data from the PROM21 PCI glue instead of inspecting the parent PCI driver's drvdata. The read path restores the previous vendor index value after sampling and does not runtime-resume the parent PCI device; reads from a suspended parent return -ENODATA. Document the supported device, register access, runtime PM behavior, and sysfs lookup method. The documentation also records the observation method used to identify the register pair and derive the conversion formula. Assisted-by: Codex:gpt-5.5 Signed-off-by: Jihong Min <hurryman2212@gmail.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Tested-by: Yaroslav Isakov <yaroslav.isakov@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://patch.msgid.link/20260519000732.2334711-3-hurryman2212@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-05-21hwmon: (pmbus/adm1266) serialize sequencer_state debugfs read with pmbus_lockAbdurrahman Hussain
adm1266_state_read() backs the sequencer_state debugfs entry and issues an i2c_smbus_read_word_data(client, ADM1266_READ_STATE) against the device without taking pmbus_lock. pmbus_core holds pmbus_lock around its own multi-transaction sequences (notably the "set PAGE, then read paged register" pattern used by hwmon attributes), so an unlocked debugfs reader can land between a PAGE write and the subsequent paged read in another thread. READ_STATE itself is not paged, so it cannot corrupt PAGE in flight, but the same defensive serialisation that applies to the GPIO accessors applies here: any direct device access from outside pmbus_core should be ordered with respect to pmbus_core's own. Take pmbus_lock at the top of adm1266_state_read() via the scope-based guard(). Fixes: ed1ff457e187 ("hwmon: (pmbus/adm1266) add debugfs for states") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260518-adm1266-gpio-fixes-v3-8-e425e4f88139@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) serialize NVMEM blackbox read with pmbus_lockAbdurrahman Hussain
adm1266_nvmem_read() is the reg_read callback the NVMEM core invokes when userspace reads /sys/bus/nvmem/devices/.../nvmem on this chip. On the first byte of every read it does a memset of data->dev_mem, walks the device blackbox through adm1266_nvmem_read_blackbox() (which issues a chain of PMBus block transactions), and then memcpys the refreshed buffer out to userspace. None of that runs under pmbus_lock today. Two consequences: - The PMBus traffic the refresh issues is not serialised against pmbus_core's own multi-step PAGE+register sequences. A paged hwmon attribute read from another thread can land between a PAGE write and the paged read in either direction and corrupt one side's view of the device state machine. - The NVMEM core does not serialise concurrent reg_read calls, so two userspace readers racing at offset 0 can interleave the memset of data->dev_mem with another reader's adm1266_nvmem_read_blackbox() refill or memcpy out, returning torn data to userspace. Take pmbus_lock at the top of adm1266_nvmem_read() via the scope-based guard(). Patch 5 of this series moves adm1266_config_nvmem() past pmbus_do_probe() so the lock is guaranteed to be live before the callback is reachable from userspace. Fixes: 15609d189302 ("hwmon: (pmbus/adm1266) read blackbox") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260518-adm1266-gpio-fixes-v3-7-e425e4f88139@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) serialize GPIO PMBus accesses with pmbus_lockAbdurrahman Hussain
adm1266_gpio_get(), adm1266_gpio_get_multiple(), and adm1266_gpio_dbg_show() all issue PMBus reads against the device but none of them take pmbus_lock. The pmbus_core framework holds pmbus_lock around its own multi-transaction sequences (notably the "set PAGE, then read paged register" pattern used by hwmon attributes), so an unlocked GPIO accessor can land between a PAGE write and the subsequent paged read in another thread and corrupt either side's view of the device state machine. Take pmbus_lock at the top of each of the three accessors via the scope-based guard(). The lock is uncontended in the common case and adds only a single mutex round-trip per call. Fixes: d98dfad35c38 ("hwmon: (pmbus/adm1266) Add support for GPIOs") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260518-adm1266-gpio-fixes-v3-6-e425e4f88139@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) register the nvmem device after pmbus_do_probe()Abdurrahman Hussain
adm1266_probe() calls adm1266_config_nvmem() -- which goes on to devm_nvmem_register() and exposes adm1266_nvmem_read() to userspace -- before pmbus_do_probe() has initialised the per-client PMBus state. Same latent hazard as the gpio_chip one fixed in the previous patch: once the nvmem device is registered, gpiolib's nvmem char-dev / sysfs interface is reachable, and any concurrent read triggers adm1266_nvmem_read() -> adm1266_nvmem_read_blackbox(), which issues PMBus traffic that races pmbus_do_probe()'s own device accesses with no serialisation. Move adm1266_config_nvmem() down past pmbus_do_probe() so the nvmem device isn't reachable from userspace until the PMBus state the nvmem accessors depend on is fully initialised. Fixes: 15609d189302 ("hwmon: (pmbus/adm1266) read blackbox") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260518-adm1266-gpio-fixes-v3-5-e425e4f88139@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) register the gpio_chip after pmbus_do_probe()Abdurrahman Hussain
adm1266_probe() calls adm1266_config_gpio() -- which goes on to devm_gpiochip_add_data() and exposes the gpio_chip callbacks to gpiolib -- before pmbus_do_probe() has initialised the per-client PMBus state (notably the pmbus_lock mutex the core hands out via pmbus_get_data()). That ordering is already a latent hazard: any GPIO access that lands between adm1266_config_gpio() and the end of pmbus_do_probe() (for example a sysfs read from a user space agent that opens the gpiochip the instant gpiolib advertises it) races pmbus_do_probe()'s own device accesses with no serialisation. Move adm1266_config_gpio() down past pmbus_do_probe() so the chip isn't reachable from userspace until the PMBus state it depends on is fully initialised. Fixes: d98dfad35c38 ("hwmon: (pmbus/adm1266) Add support for GPIOs") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260518-adm1266-gpio-fixes-v3-4-e425e4f88139@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) reject short block-read responses in the GPIO accessorsAbdurrahman Hussain
adm1266_gpio_get() and adm1266_gpio_get_multiple() both compose the pin-status word as pins_status = read_buf[0] + (read_buf[1] << 8); right after i2c_smbus_read_block_data(), guarding only against an error return. A well-behaved device returns 2 bytes for GPIO_STATUS/PDIO_STATUS, but the helper happily reports a 0- or 1-byte response too. If the device returns 0 bytes, both read_buf slots are uninitialized stack memory; if it returns 1 byte, read_buf[1] is. The composed value then flows through set_bit() into the caller's *bits in adm1266_gpio_get_multiple(), or into the return value of adm1266_gpio_get(), and ends up in userspace via gpiolib (sysfs and the char-dev ioctls). That leaks a few bits of kernel stack per request on any device whose firmware glitch, bus error, or hostile slave produces a short block-read response. Add the missing length check to both call sites and surface a short response as -EIO. Fixes: d98dfad35c38 ("hwmon: (pmbus/adm1266) Add support for GPIOs") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260518-adm1266-gpio-fixes-v3-3-e425e4f88139@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) don't clobber GPIO bits before PDIO read in get_multipleAbdurrahman Hussain
adm1266_gpio_get_multiple() zeroes *bits before the GPIO_STATUS loop and then a second time before the PDIO_STATUS loop: *bits = 0; for_each_set_bit(gpio_nr, mask, ADM1266_GPIO_NR) { ... set_bit(gpio_nr, bits); } ret = i2c_smbus_read_block_data(data->client, ADM1266_PDIO_STATUS, ...); ... *bits = 0; for_each_set_bit_from(gpio_nr, mask, ADM1266_GPIO_NR + ADM1266_PDIO_NR) { ... set_bit(gpio_nr, bits); } The second *bits = 0 throws away every GPIO bit the first loop just populated, so callers asking for any combination of GPIO and PDIO pins always see the GPIO portion of the returned bits as zero. Drop the redundant second assignment so both halves of the result survive. Fixes: d98dfad35c38 ("hwmon: (pmbus/adm1266) Add support for GPIOs") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://lore.kernel.org/r/20260518-adm1266-gpio-fixes-v3-2-e425e4f88139@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) cap PDIO scan in get_multiple at ADM1266_PDIO_NRAbdurrahman Hussain
adm1266_gpio_get_multiple() iterates the PDIO portion of the caller-supplied mask using for_each_set_bit_from(gpio_nr, mask, ADM1266_GPIO_NR + ADM1266_PDIO_STATUS) { ... } where ADM1266_PDIO_STATUS is the PMBus command code (0xE9, i.e. 233), not the number of PDIO pins. The intended upper bound is ADM1266_GPIO_NR + ADM1266_PDIO_NR = 25. gpiolib hands in a mask sized for gc.ngpio (= 25 bits on this chip), so the iteration walks find_next_bit() up to 242, reading up to 217 extra bits (a handful of unsigned-long words: four on 64-bit, seven on 32-bit) of whatever lives past the end of the mask in the caller's stack. Any incidental set bit in that range then drives a set_bit(gpio_nr, bits) call that writes past the end of the caller-supplied bits array too -- both out-of-bounds. Substitute ADM1266_PDIO_NR for the constant so the scan stops at the last real PDIO bit. Fixes: d98dfad35c38 ("hwmon: (pmbus/adm1266) Add support for GPIOs") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://lore.kernel.org/r/20260518-adm1266-gpio-fixes-v3-1-e425e4f88139@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) bounce blackbox records through a protocol-sized bufferAbdurrahman Hussain
adm1266_pmbus_block_xfer() copies the device-supplied block payload into the caller-provided buffer using the device-supplied length: memcpy(data_r, &msgs[1].buf[1], msgs[1].buf[0]); The helper does not know how large data_r is and trusts the device to return at most one record's worth of bytes. adm1266_nvmem_read_blackbox() violates that contract: it advances read_buff inside data->dev_mem in ADM1266_BLACKBOX_SIZE (64-byte) strides while the helper is willing to write up to ADM1266_PMBUS_BLOCK_MAX (255) bytes. A device that returns more than 64 bytes on the trailing record (read_buff offset 1984 in the 2048-byte dev_mem allocation) overflows dev_mem by up to 191 bytes before the post-call if (ret != ADM1266_BLACKBOX_SIZE) return -EIO; can reject the response. Contain the fix in the caller without changing the helper signature: read each record into a 255-byte local bounce buffer that matches the helper's maximum output, validate the returned length, and only then copy exactly ADM1266_BLACKBOX_SIZE bytes into the dev_mem slot. Fixes: 407dc802a9c0 ("hwmon: (pmbus/adm1266) Add Block process call") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260515-adm1266-fixes-v1-5-1c1ea1349cfe@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) include adapter number in GPIO line labelAbdurrahman Hussain
Platforms that fit more than one ADM1266 on different I2C buses at the same 7-bit slave address (a common shelf-management pattern, e.g. one device per power domain) end up with duplicate GPIO line labels because the existing format only includes the slave address. Including the adapter number disambiguates them. The adapter number is formatted as decimal to match the i2c-N convention used elsewhere in Linux (sysfs paths, dev nodes); the slave address keeps its conventional hexadecimal form. The label is purely informational (visible via gpioinfo and the gpiochip /sys/class/gpio name); no DT or ABI consumer parses it. Fixes: d98dfad35c38c ("hwmon: (pmbus/adm1266) Add support for GPIOs") Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260512-adm1266-v3-5-a81a479b0bb0@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) include PEC byte in pmbus_block_xfer read bufferAbdurrahman Hussain
adm1266_pmbus_block_xfer() sets up the read transaction with .buf = data->read_buf, .len = ADM1266_PMBUS_BLOCK_MAX + 2, but read_buf in struct adm1266_data is declared as u8 read_buf[ADM1266_PMBUS_BLOCK_MAX + 1]; For a max-length block response (length byte = 255 + up to 1 PEC byte), the i2c controller is told to write 257 bytes into a 256-byte buffer, putting one byte past the end of read_buf. The same response also makes the subsequent PEC compare if (crc != msgs[1].buf[msgs[1].buf[0] + 1]) read a byte beyond the array. Bump the read_buf declaration to ADM1266_PMBUS_BLOCK_MAX + 2 so the buffer can hold the length byte, up to 255 payload bytes, and the PEC byte the i2c_msg length already accounts for. Fixes: 407dc802a9c0 ("hwmon: (pmbus/adm1266) Add Block process call") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260515-adm1266-fixes-v1-4-1c1ea1349cfe@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) reject implausible blackbox record_countAbdurrahman Hussain
adm1266_nvmem_read_blackbox() loops over a record_count that comes straight from byte 3 of the BLACKBOX_INFO response. The destination buffer is data->dev_mem, sized for the nvmem cell's declared 2048 bytes (ADM1266_BLACKBOX_MAX_RECORDS * ADM1266_BLACKBOX_SIZE = 32 * 64). A device that reports a record_count greater than 32 -- whether due to firmware bugs, bus corruption, or a non-responsive slave returning 0xff -- would walk read_buff past the end of the dev_mem allocation on the trailing iterations. Cap record_count at ADM1266_BLACKBOX_MAX_RECORDS (introduced here) before entering the loop and return -EIO on any larger value, so a malformed BLACKBOX_INFO response cannot drive the loop out of bounds. Fixes: 15609d189302 ("hwmon: (pmbus/adm1266) read blackbox") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260515-adm1266-fixes-v1-3-1c1ea1349cfe@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) widen blackbox-info buffer to I2C_SMBUS_BLOCK_MAXAbdurrahman Hussain
adm1266_nvmem_read_blackbox() declares a 5-byte stack buffer and passes it to i2c_smbus_read_block_data() to retrieve the 4-byte BLACKBOX_INFO response. i2c_smbus_read_block_data() does not honour caller buffer sizes -- it memcpy()s data.block[0] bytes from the SMBus transaction (where data.block[0] is the length byte returned by the slave device, up to I2C_SMBUS_BLOCK_MAX = 32): memcpy(values, &data.block[1], data.block[0]); If the device returns any block length above 5, the call overflows the caller's 5-byte stack buffer before the post-call if (ret != 4) return -EIO; check has a chance to reject the response. Widen the local buffer to I2C_SMBUS_BLOCK_MAX so the helper has room for any well-formed SMBus block response, matching the convention used by the other i2c_smbus_read_block_data() callers in this driver. Fixes: 15609d189302 ("hwmon: (pmbus/adm1266) read blackbox") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260515-adm1266-fixes-v1-2-1c1ea1349cfe@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (pmbus/adm1266) seed timestamp from the real-time clockAbdurrahman Hussain
adm1266_set_rtc() seeds the chip's SET_RTC register from ktime_get_seconds(), which returns CLOCK_MONOTONIC -- i.e. seconds since the host last booted, not seconds since the Unix epoch. The chip stamps that value into every blackbox record it captures. Userspace reading those timestamps back expects wall-clock seconds: that's what the SET_RTC frame layout documents (datasheet Rev. D, Table 84) and what every other consumer of "seconds since epoch" assumes. Seeding from CLOCK_MONOTONIC gives blackbox records a timestamp that is only meaningful within a single boot of the host and silently resets to small values on every reboot. Switch to ktime_get_real_seconds() so the seed matches what the register is documented to hold. Fixes: 15609d189302 ("hwmon: (pmbus/adm1266) read blackbox") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Link: https://lore.kernel.org/r/20260515-adm1266-fixes-v1-1-1c1ea1349cfe@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (lenovo-ec-sensors): Fix EC "MCHP" signature validation logicKean Ren
The EC signature check uses && instead of || between the four byte comparisons. With &&, the condition is true only when ALL four bytes fail to match simultaneously, meaning the driver accepts a device as a valid Microchip EC if ANY single byte of the 4-byte "MCHP" signature happens to match. Due to short-circuit evaluation, if the first byte reads back as 'M' (0x4D, a very common register value), the remaining three comparisons are skipped entirely and the device is accepted. Change && to || so the check rejects devices that do not fully match the expected EC signature, as originally intended. Fixes: 70118f85e6538 ("hwmon: Add EC Chip driver for Lenovo ThinkStation motherboards") Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Signed-off-by: Kean Ren <rh_king@163.com> Link: https://lore.kernel.org/r/20260521035228.533317-3-rh_king@163.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-21hwmon: (lenovo-ec-sensors): Convert to devm_request_region()Kean Ren
Replace manual request_region()/release_region() with devm_request_region(). This lets the device-managed framework handle I/O region lifetime automatically and fixes: - A double release_region() when probe fails after acquiring the I/O region: the probe error path releases it, and then lenovo_ec_init() releases it again on the same error path. - A release-after-use window in lenovo_ec_exit() where release_region() was called before platform_device_unregister(), leaving the hwmon device active with a released I/O region. - Missing release_region() in lenovo_ec_probe() if devm_hwmon_device_register_with_info() fails. Remove all four manual release_region() calls that are now handled automatically and replace request_region with devm_request_region, use dev_err replace pr_err. Also remove the now-unnecessary braces around the single-statement if body. Fixes: 70118f85e6538 ("hwmon: Add EC Chip driver for Lenovo ThinkStation motherboards") Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Signed-off-by: Kean Ren <rh_king@163.com> Link: https://lore.kernel.org/r/20260521035228.533317-2-rh_king@163.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-16hwmon: (lm90) Add lock protection to lm90_alertGuenter Roeck
Sashiko reports: lm90_alert() executes in the smbus alert context and calls lm90_update_confreg() to disable the hardware alert line, without acquiring hwmon_lock. Concurrently, sysfs write operations (such as lm90_write_convrate) hold the hwmon_lock, temporarily modify data->config, and then restore it. If an alert interrupt occurs concurrently with a sysfs write, the sysfs path will overwrite the alert handler's modifications to data->config and the hardware register. This unintentionally re-enables the hardware alert line while the alarm is still active, causing an interrupt storm. Add the missing lock to lm90_alert() to solve the problem. Fixes: 7a1d220ccb0cc ("hwmon: (lm90) Introduce function to update configuration register") Reported-by: Sashiko <sashiko-bot@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2026-05-16hwmon: (lm90) Stop work before releasing hwmon deviceGuenter Roeck
Sashiko reports: In lm90_probe(), the devm action to cancel the alert_work and report_work (lm90_restore_conf) is registered in lm90_init_client() before devm_hwmon_device_register_with_info() is called. Because devm executes cleanup actions in reverse order during module unbind or probe failure, the hwmon device is unregistered and freed first. If lm90_alert_work() or lm90_report_alarms() runs in the window between the hwmon device being freed and the delayed works being cancelled, lm90_update_alarms() will dereference the freed data->hwmon_dev here. Fix the problem by canceling the workers separately after registering the hwmon device and before registering the interrupt handler. This ensures that the workers are canceled after interrupts are disabled and before the hwmon device is released. Add "shutdown" flag to indicate that device shutdown is in progress to prevent workers from being re-armed. Fixes: f6d0775119fb9 ("hwmon: (lm90) Rework alarm/status handling") Reported-by: Sashiko <sashiko-bot@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>