aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwmon
AgeCommit message (Collapse)AuthorFilesLines
2024-10-14[PATCH} hwmon: (jc42) Properly detect TSE2004-compliant devices againJean Delvare1-1/+1
Commit b3e992f69c23 ("hwmon: (jc42) Strengthen detect function") attempted to make the detect function more robust for TSE2004-compliant devices by checking capability bits which, according to the JEDEC 21-C specification, should always be set. Unfortunately, not all real-world implementations fully adhere to this specification, so this change caused a regression. Stop testing bit 7 (EVSD) of the Capabilities register, as it was found to be 0 on one real-world device. Also stop testing bits 0 (EVENT) and 2 (RANGE) as vendor datasheets (Renesas TSE2004GB2B0, ST STTS2004) suggest that they may not always be set either. Signed-off-by: Jean Delvare <[email protected]> Message-ID: <[email protected]> Fixes: b3e992f69c23 ("hwmon: (jc42) Strengthen detect function") Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-10-07hwmon: (max1668) Add missing dependency on REGMAP_I2CJavier Carrasco1-0/+1
This driver requires REGMAP_I2C to be selected in order to get access to regmap_config, regmap_bus, and devm_regmap_init_i2c. Add the missing dependency. Fixes: 021730acbca6 ("hwmon: (max1668) Convert to use regmap") Signed-off-by: Javier Carrasco <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-10-07hwmon: (ltc2991) Add missing dependency on REGMAP_I2CJavier Carrasco1-0/+1
This driver requires REGMAP_I2C to be selected in order to get access to regmap_config and devm_regmap_init_i2c. Add the missing dependency. Fixes: 2b9ea4262ae9 ("hwmon: Add driver for ltc2991") Signed-off-by: Javier Carrasco <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-10-07hwmon: (adt7470) Add missing dependency on REGMAP_I2CJavier Carrasco1-0/+1
This driver requires REGMAP_I2C to be selected in order to get access to regmap_config and devm_regmap_init_i2c. Add the missing dependency. Fixes: ef67959c4253 ("hwmon: (adt7470) Convert to use regmap") Signed-off-by: Javier Carrasco <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-10-07hwmon: (adm9240) Add missing dependency on REGMAP_I2CJavier Carrasco1-0/+1
This driver requires REGMAP_I2C to be selected in order to get access to regmap_config and devm_regmap_init_i2c. Add the missing dependency. Fixes: df885d912f67 ("hwmon: (adm9240) Convert to regmap") Signed-off-by: Javier Carrasco <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-10-07hwmon: (mc34vr500) Add missing dependency on REGMAP_I2CJavier Carrasco1-0/+1
This driver requires REGMAP_I2C to be selected in order to get access to regmap_config and devm_regmap_init_i2c. Add the missing dependency. Fixes: 07830d9ab34c ("hwmon: add initial NXP MC34VR500 PMIC monitoring support") Signed-off-by: Javier Carrasco <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-10-07hwmon: (tmp513) Add missing dependency on REGMAP_I2CGuenter Roeck1-0/+1
0-day reports: drivers/hwmon/tmp513.c:162:21: error: variable 'tmp51x_regmap_config' has initializer but incomplete type 162 | static const struct regmap_config tmp51x_regmap_config = { | ^ struct regmap_config is only available if REGMAP is enabled. Add the missing Kconfig dependency to fix the problem. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Fixes: 59dfa75e5d82 ("hwmon: Add driver for Texas Instruments TMP512/513 sensor chips.") Cc: Eric Tremblay <[email protected]> Reviewed-by: Javier Carrasco <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-10-07hwmon: (adt7475) Fix memory leak in adt7475_fan_pwm_config()Javier Carrasco1-2/+1
The device_for_each_child_node() loop requires calls to fwnode_handle_put() upon early returns to decrement the refcount of the child node and avoid leaking memory. There are multiple early returns within that loop in adt7475_fan_pwm_config(), but fwnode_handle_put() is never called. Instead of adding the missing calls, the scoped version of the loop can be used to simplify the code and avoid mistakes in the future if new early returns are added. This issue was recently introduced and it does not affect old kernels that do not support the scoped variant. Fixes: 777c97ff08d0 ("hwmon: (adt7475) Add support for configuring initial PWM state") Signed-off-by: Javier Carrasco <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-10-07hwmon: intel-m10-bmc-hwmon: relabel Columbiaville to CVL Die TemperaturePeter Colberg1-1/+1
Consistently use CVL instead of Columbiaville, since CVL is already being used in all other sensor labels for the Intel N6000 card. Fixes: e1983220ae14 ("hwmon: intel-m10-bmc-hwmon: Add N6000 sensors") Signed-off-by: Peter Colberg <[email protected]> Reviewed-by: Michael Adler <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-10-02move asm/unaligned.h to linux/unaligned.hAl Viro11-11/+11
asm/unaligned.h is always an include of asm-generic/unaligned.h; might as well move that thing to linux/unaligned.h and include that - there's nothing arch-specific in that header. auto-generated by the following: for i in `git grep -l -w asm/unaligned.h`; do sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i done for i in `git grep -l -w asm-generic/unaligned.h`; do sed -i -e "s/asm-generic\/unaligned.h/linux\/unaligned.h/" $i done git mv include/asm-generic/unaligned.h include/linux/unaligned.h git mv tools/include/asm-generic/unaligned.h tools/include/linux/unaligned.h sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild sed -i -e "s/__ASM_GENERIC/__LINUX/" include/linux/unaligned.h tools/include/linux/unaligned.h
2024-09-27[tree-wide] finally take no_llseek outAl Viro3-3/+0
no_llseek had been defined to NULL two years ago, in commit 868941b14441 ("fs: remove no_llseek") To quote that commit, At -rc1 we'll need do a mechanical removal of no_llseek - git grep -l -w no_llseek | grep -v porting.rst | while read i; do sed -i '/\<no_llseek\>/d' $i done would do it. Unfortunately, that hadn't been done. Linus, could you do that now, so that we could finally put that thing to rest? All instances are of the form .llseek = no_llseek, so it's obviously safe. Signed-off-by: Al Viro <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2024-09-19Merge tag 'platform-drivers-x86-v6.12-1' of ↵Linus Torvalds1-16/+6
git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86 Pull x86 platform drivers updates from Hans de Goede: - asus-wmi: Add support for vivobook fan profiles - dell-laptop: Add knobs to change battery charge settings - lg-laptop: Add operation region support - intel-uncore-freq: Add support for efficiency latency control - intel/ifs: Add SBAF test support - intel/pmc: Ignore all LTRs during suspend - platform/surface: Support for arm64 based Surface devices - wmi: Pass event data directly to legacy notify handlers - x86/platform/geode: switch GPIO buttons and LEDs to software properties - bunch of small cleanups, fixes, hw-id additions, etc. * tag 'platform-drivers-x86-v6.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (65 commits) MAINTAINERS: adjust file entry in INTEL MID PLATFORM platform/x86: x86-android-tablets: Adjust Xiaomi Pad 2 bottom bezel touch buttons LED platform/mellanox: mlxbf-pmc: fix lockdep warning platform/x86/amd: pmf: Add quirk for TUF Gaming A14 platform/x86: touchscreen_dmi: add nanote-next quirk platform/x86: asus-wmi: don't fail if platform_profile already registered platform/x86: asus-wmi: add debug print in more key places platform/x86: intel_scu_wdt: Move intel_scu_wdt.h to x86 subfolder platform/x86: intel_scu_ipc: Move intel_scu_ipc.h out of arch/x86/include/asm MAINTAINERS: Add Intel MID section platform/x86: panasonic-laptop: Add support for programmable buttons platform/olpc: Remove redundant null pointer checks in olpc_ec_setup_debugfs() platform/x86: intel/pmc: Ignore all LTRs during suspend platform/x86: wmi: Call both legacy and WMI driver notify handlers platform/x86: wmi: Merge get_event_data() with wmi_get_notify_data() platform/x86: wmi: Remove wmi_get_event_data() platform/x86: wmi: Pass event data directly to legacy notify handlers platform/x86: thinkpad_acpi: Fix uninitialized symbol 's' warning platform/x86: x86-android-tablets: Fix spelling in the comments platform/x86: ideapad-laptop: Make the scope_guard() clear of its scope ...
2024-09-18Merge tag 'hwmon-for-v6.12' of ↵Linus Torvalds50-2669/+3289
git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon updates from Guenter Roeck: "New drivers: - driver for Sophgo SG2042 external hardware monitor - thermal sensor driver for Surface Aggregator Module Added support to existing drivers: - oxp-sensors: Support for multiple new devices. - nct6775: Added G15CF to ASUS WMI monitoring list Modernizations: - driver cleanup and update to use with_info API: ina2xx, lm92, lm95234, max1619, max1668, and max6697. API updates: - removed unused devm_hwmon_device_unregister() API function Other notable changes - implement and use generic bus access delay for pmbus drivers - use with scoped for each OF child loop in several drivers - module unloading fixes for gsc-hwmon and ntc_thermistor drivers - converted various drivers to use multi-byte regmap operations - adt7475: Improved devicetree based configuration - ltc2947: Move to firmware agnostic API - ltc2978: Converted devicetree description to yaml - max16065: Addressed overflows when writing limit attributes Various other minor cleanups, fixes and improvements" * tag 'hwmon-for-v6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (96 commits) hwmon: Remove devm_hwmon_device_unregister() API function hwmon: (sch5636) Print unknown ID in error string via %*pE hwmon: (sht21) Use %*ph to print small buffer hwmon: (pmbus/mpq7932) Constify struct regulator_desc hwmon: pmbus: pli12096bc: Add write delay hwmon: pmbus: zl6100: Use generic code hwmon: pmbus: ucd9000: Use generic code hwmon: pmbus: max15301: Use generic code hwmon: pmbus: Implement generic bus access delay hwmon: (ina2xx) Use shunt voltage to calculate current hwmon: (ina2xx) Add support for current limits hwmon: (ina2xx) Pass register to alert limit write functions hwmon: (ina2xx) Convert to use with_info hwmon API hwmon: (ina2xx) Move ina2xx_get_value() hwmon: (ina2xx) Set alert latch hwmon: (ina2xx) Consolidate chip initialization code hwmon: (ina2xx) Fix various overflow issues hwmon: (ina2xx) Re-initialize chip using regmap functions hwmon: (ina2xx) Use local regmap pointer if used more than once hwmon: (ina2xx) Mark regmap_config as const ...
2024-09-17Merge tag 'x86-misc-2024-09-17' of ↵Linus Torvalds1-0/+1
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull misc x86 updates from Thomas Gleixner: - Rework kcpuid to handle the the autogenerated CSV file correctly and update the CSV file to cover the whole zoo of CPUID. - Avoid memcpy() for ia32 syscall_get_arguments() and use direct assignments as fortified memcpy() is unhappy about writing/reading beyond the end of the addresses destination/source struct member - A few new PCI IDs for AMD - Update MAINTAINERS to cover x86 specific selftests * tag 'x86-misc-2024-09-17' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: MAINTAINERS: Add selftests/x86 entry x86/amd_nb: Add new PCI IDs for AMD family 1Ah model 60h-70h x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments() MAINTAINERS: Add x86 cpuid database entry tools/x86/kcpuid: Introduce a complete cpuid bitfields CSV file tools/x86/kcpuid: Parse subleaf ranges if provided tools/x86/kcpuid: Recognize all leaves with subleaves tools/x86/kcpuid: Strip bitfield names leading/trailing whitespace tools/x86/kcpuid: Protect against faulty "max subleaf" values tools/x86/kcpuid: Set max possible subleaves count to 64 tools/x86/kcpuid: Properly align long-description columns tools/x86/kcpuid: Remove unused variable x86/amd_nb: Add new PCI IDs for AMD family 1Ah model 60h
2024-09-13hwmon: Remove devm_hwmon_device_unregister() API functionGuenter Roeck1-18/+0
devm_hwmon_device_unregister() has no in-tree user, and its implementation is wrong since it does not pass the to-be-removed hardware monitoring device as parameter. I do not envision a valid use for it; drivers needing it should not have called devm_hwmon_device_register_with_info() in the first place. Remove it. Reported-by: Matthew Sanders <[email protected]> Closes: https://lore.kernel.org/linux-hwmon/[email protected]/ Signed-off-by: Guenter Roeck <[email protected]>
2024-09-12hwmon: (sch5636) Print unknown ID in error string via %*pEAndy Shevchenko1-2/+1
Instead of custom approach this allows to print escaped strings via %*pE extension. With this the unknown ID will be printed as a string. Nonetheless, leave hex values to be printed as well. Signed-off-by: Andy Shevchenko <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-09-12hwmon: (sht21) Use %*ph to print small bufferAndy Shevchenko1-4/+1
Use %*ph format to print small buffer as hex string. Signed-off-by: Andy Shevchenko <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-09-09hwmon: (pmbus) Conditionally clear individual status bits for pmbus rev >= 1.2Patryk Biel2-3/+20
The current implementation of pmbus_show_boolean assumes that all devices support write-back operation of status register to clear pending warnings or faults. Since clearing individual bits in the status registers was only introduced in PMBus specification 1.2, this operation may not be supported by some older devices. This can result in an error while reading boolean attributes such as temp1_max_alarm. Fetch PMBus revision supported by the device and modify pmbus_show_boolean so that it only tries to clear individual status bits if the device is compliant with PMBus specs >= 1.2. Otherwise clear all fault indicators on the current page after a fault status was reported. Fixes: 35f165f08950a ("hwmon: (pmbus) Clear pmbus fault/warning bits after read") Signed-off-by: Patryk Biel <[email protected]> Message-ID: <[email protected]> [groeck: Rewrote description Moved revision detection code ahead of clear faults command Assigned revision if return value from PMBUS_REVISION command is 0 Improved return value check from calling _pmbus_write_byte_data()] Signed-off-by: Guenter Roeck <[email protected]>
2024-09-08hwmon: (pmbus/mpq7932) Constify struct regulator_descChristophe JAILLET1-1/+1
'struct regulator_desc' is not modified in this driver. Constifying this structure moves some data to a read-only section, so increase overall security, especially when the structure holds some function pointers. This also makes mpq7932_regulators_desc consistent with mpq7932_regulators_desc_one which is already a "static const struct regulator_desc". On a x86_64, with allmodconfig: Before: ====== text data bss dec hex filename 3516 2264 0 5780 1694 drivers/hwmon/pmbus/mpq7932.o After: ===== text data bss dec hex filename 5396 384 0 5780 1694 drivers/hwmon/pmbus/mpq7932.o Signed-off-by: Christophe JAILLET <[email protected]> Message-ID: <c0585a07547ec58d99a5bff5e02b398114bbe312.1725784343.git.christophe.jaillet@wanadoo.fr> Signed-off-by: Guenter Roeck <[email protected]>
2024-09-05platform/x86: wmi: Pass event data directly to legacy notify handlersArmin Wolf1-16/+6
The current legacy WMI handlers are susceptible to picking up wrong WMI event data on systems where different WMI devices share some notification IDs. Prevent this by letting the WMI driver core taking care of retrieving the event data. This also simplifies the legacy WMI handlers and their implementation inside the WMI driver core. Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Armin Wolf <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hans de Goede <[email protected]>
2024-09-02hwmon: pmbus: pli12096bc: Add write delayPatrick Rudolph1-25/+1
Tests on PLI12096bc showed that sometimes a small delay is necessary after a write operation before a new operation can be processed. If not respected the device will probably NACK the data phase of the SMBus transaction. Tests showed that the probability to observe transaction errors can be raised by either reading sensor data or toggling the regulator enable. Further tests showed that 250 microseconds, as used previously for the CLEAR_FAULTS workaround, is sufficient. Signed-off-by: Patrick Rudolph <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-09-02hwmon: pmbus: zl6100: Use generic codePatrick Rudolph1-58/+8
Use generic pmbus bus access delay. Signed-off-by: Patrick Rudolph <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-09-02hwmon: pmbus: ucd9000: Use generic codePatrick Rudolph1-62/+2
Use generic pmbus bus write access delay. Signed-off-by: Patrick Rudolph <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-09-02hwmon: pmbus: max15301: Use generic codePatrick Rudolph1-91/+1
Use the generic pmbus bus access delay. Signed-off-by: Patrick Rudolph <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-09-02hwmon: pmbus: Implement generic bus access delayPatrick Rudolph2-6/+96
Some drivers, like the max15301 or zl6100, are intentionally delaying SMBus communications, to prevent transmission errors. As this is necessary on additional PMBus compatible devices, implement a generic delay mechanism in the pmbus core. Introduces two delay settings in the pmbus_driver_info struct, one applies to every SMBus transaction and the other is for write transaction only. Once set by the driver the SMBus traffic, using the generic pmbus access helpers, is automatically delayed when necessary. The two settings are: access_delay: - Unit in microseconds - Stores the accessed timestamp after every SMBus access - Delays when necessary before the next SMBus access write_delay: - Unit in microseconds - Stores the written timestamp after a write SMBus access - Delays when necessary before the next SMBus access This allows to drop the custom delay code from the drivers and easily introduce this feature in additional pmbus drivers. Signed-off-by: Patrick Rudolph <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-09-02hwmon: (hp-wmi-sensors) Check if WMI event data existsArmin Wolf1-0/+2
The BIOS can choose to return no event data in response to a WMI event, so the ACPI object passed to the WMI notify handler can be NULL. Check for such a situation and ignore the event in such a case. Fixes: 23902f98f8d4 ("hwmon: add HP WMI Sensors driver") Signed-off-by: Armin Wolf <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-09-01hwmon: ltc2991: fix register bits definesPawel Dembicki1-3/+3
In the LTC2991, V5 and V6 channels use the low nibble of the "V5, V6, V7, and V8 Control Register" for configuration, but currently, the high nibble is defined. This patch changes the defines to use the low nibble. Fixes: 2b9ea4262ae9 ("hwmon: Add driver for ltc2991") Signed-off-by: Pawel Dembicki <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Use shunt voltage to calculate currentGuenter Roeck1-1/+13
Since the shunt voltage and the current register report the same values when the chip is calibrated, we can calculate the current directly from the shunt voltage without relying on chip calibration. With this change, the current register is no longer accessed. Its register address is only used to indicate if reading or writing current or shunt voltage is desired when accessing registers. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Add support for current limitsGuenter Roeck1-2/+59
While the chips supported by this driver do not directly support current limits, they do support setting shunt voltage limits. The shunt voltage divided by the shunt resistor value is the current. On top of that, calibration values are set such that in the shunt voltage register and the current register report the same values. That means we can report and configure current limits based on shunt voltage limits, and we can do so with much better accuracy than by setting shunt voltage limits. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Pass register to alert limit write functionsGuenter Roeck1-10/+11
Pass the to-be-limited register to alert functions and use it to determine conversion from limit to register value. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Convert to use with_info hwmon APIGuenter Roeck1-202/+293
Convert driver to use the with_info hardware monitoring API to reduce its dependency on sysfs attribute functions. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Move ina2xx_get_value()Guenter Roeck1-36/+36
ina2xx_get_value() will be needed earlier in the next patch, so move it. No functional change. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Set alert latchGuenter Roeck1-2/+5
Alerts should only be cleared after reported, not immediately after the alert condition has been cleared. Set the latch enable bit to keep alerts latched until the alert register has been read from the chip. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Consolidate chip initialization codeGuenter Roeck1-68/+43
Move all chip initialization code into a single function. No functional change. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Fix various overflow issuesGuenter Roeck1-12/+20
Module tests show various overflow problems when writing limits and other attributes. in0_crit: Suspected overflow: [max=82, read 0, written 2147483648] in0_lcrit: Suspected overflow: [max=82, read 0, written 2147483648] in1_crit: Suspected overflow: [max=40959, read 0, written 2147483647] in1_lcrit: Suspected overflow: [max=40959, read 0, written 2147483647] power1_crit: Suspected overflow: [max=134218750, read 0, written 2147483648] update_interval: Suspected overflow: [max=2253, read 2, written 2147483647] Implement missing clamping on attribute write operations to avoid those problems. While at it, check in the probe function if the shunt resistor value passed from devicetree is valid, and bail out if it isn't. Also limit mutex use to the code calling ina2xx_set_shunt() since it isn't needed when called from the probe function. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Re-initialize chip using regmap functionsGuenter Roeck1-9/+41
If it is necessary to re-initialize the chip, for example because it has been power cycled, use regmap functions to update register contents. This ensures that all registers, including the configuration register and alert registers, are updated to previously configured values without having to locally cache everything. For this to work, volatile registers have to be marked as volatile. Also, the cache needs to be bypassed when reading the calibration and mask_enable registers. While the calibration register is not volatile, it will be reset to 0 if the chip has been power cycled. Most of the bits in the mask_enable register are configuration bits, except for bit 4 which reports if an alert has been observed. Both registers need to be marked as non-volatile to be updated after a power cycle, but it is necessary to bypass the cache when reading them to detect if the chip has been power cycled and to read the alert status. The chip does not support register auto-increments. It is therefore necessary to configure regmap to use single register read/write operations. Otherwise regmap tries to write all registers in a single operation when synchronizing register contents with the hardware, and the synchronization fails. Another necessary change is to declare ina226_alert_to_reg() as u16. So far it returned an s16 which is sign extended to a large negative value which is then sent to regmap as unsigned int, causing an -EINVAL error return. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Use local regmap pointer if used more than onceGuenter Roeck1-13/+10
If regmap is accessed more than once in a function, declare and used local regmap variable. While at it, drop low value debug messages. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Mark regmap_config as constGuenter Roeck1-10/+2
Recent versions of checkpatch complain that struct regmap_config should be declared as const. WARNING: struct regmap_config should normally be const Doing so reveals a potential problem in the driver: If both supported chips are present in a single system, the maximum number of registers may race when devices are instantiated since max_registers is updated in the probe function. Solve the problem by setting .max_registers to the maximum register address of all supported chips. This does not make a practical difference while fixing the potential race condition and reducing code complexity. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Use bit operationsGuenter Roeck1-42/+42
Use bit operations where possible to make the code more generic and to align it with other drivers. Also use compile time conversion from bit to mask to reduce runtime overhead. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Replace platform data with device propertiesGuenter Roeck1-12/+4
There are no in-tree users of ina2xx platform data. Drop it and support device properties instead as alternative if it should ever be needed. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-30hwmon: (ina2xx) Reorder include files to alphabetic orderGuenter Roeck1-8/+7
Simplify driver maintenance by reordering include files to alphabetic order. Whule at it, drop unnecessary / unused jiffies.h. No functional change. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-28hwmon: (oxp-sensors) Add missing breaks to fix -Wimplicit-fallthrough with clangNathan Chancellor1-0/+4
clang warns (or errors due to CONFIG_WERROR): drivers/hwmon/oxp-sensors.c:481:3: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] drivers/hwmon/oxp-sensors.c:553:3: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] drivers/hwmon/oxp-sensors.c:556:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] drivers/hwmon/oxp-sensors.c:607:3: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return. Add the missing breaks to silence the warnings. Fixes: b82b38a49926 ("hwmon: (oxp-sensors) Add support for multiple new devices.") Signed-off-by: Nathan Chancellor <[email protected]> Message-ID: <20240828-hwmon-oxp-sensors-fix-clang-implicit-fallthrough-v1-1-dc48496ac67a@kernel.org> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-27hwmon: (pwmfan) Do not force disable pwm controllerJohannes Kirchmair1-5/+6
The pwm1_enable attribute of the pwmfan driver influences the mode of operation, especially in case of a requested pwm1 duty cycle of zero. Especially setting pwm1_enable to two, should keep the pwm controller enabled even if the duty cycle is set to zero [1]. This is not the case at the moment, as the pwm controller is disabled always if pwm1 is set to zero. This commit tries to fix this behavior. [1] https://docs.kernel.org/hwmon/pwm-fan.html Signed-off-by: Johannes Kirchmair <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-27hwmon: (pc87360) Use min() macroShen Lichuan1-1/+1
Use the min() macro to simplify the pc87360_init_device() function and improve its readability. Signed-off-by: Shen Lichuan <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-27hwmon: Add sophgo SG2042 external hardware monitor supportInochi Amaoto3-0/+400
SG2042 use an external MCU to provide basic hardware information and thermal sensors. Add driver support for the onboard MCU of SG2042. Signed-off-by: Inochi Amaoto <[email protected]> Message-ID: <IA1PR20MB49536C786048D1E676BB9C20BB822@IA1PR20MB4953.namprd20.prod.outlook.com> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-27hwmon: (tmp464): Simplify with scoped for each OF child loopJinjie Ruan1-5/+2
Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-27hwmon: (tmp421): Simplify with scoped for each OF child loopJinjie Ruan1-5/+2
Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-27hwmon: (npcm750-pwm-fan): Simplify with scoped for each OF child loopJinjie Ruan1-3/+2
Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-27hwmon: (nct7802): Simplify with scoped for each OF child loopJinjie Ruan1-5/+2
Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
2024-08-27hwmon: (lm90): Simplify with scoped for each OF child loopJinjie Ruan1-5/+2
Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Jinjie Ruan <[email protected]> Message-ID: <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>