summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
Commit message (Collapse)AuthorAgeFilesLines
* hwmon: (gigabyte_waterforce) Mark status report as received under a spinlockAleksa Savic2024-01-081-0/+2
| | | | | | | | | | | | | | | | Through hidraw, userspace can cause a status report to be sent from the device. The parsing in waterforce_raw_event() may happen in parallel to a waterforce_get_status() call (which resets the completion for tracking the report) if it's running on a different CPU where bottom half interrupts are not disabled. Add a spinlock around the complete_all() call in waterforce_raw_event() to prevent race issues. Fixes: d5939a793693 ("hwmon: Add driver for Gigabyte AORUS Waterforce AIO coolers") Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com> Link: https://lore.kernel.org/r/20231219143620.22179-1-savicaleksa83@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (lm75) Fix tmp112 default configAbdel Alkuor2024-01-081-2/+3
| | | | | | | | | Set tmp112 conversion rate to 8 HZ and 12-bit mode. Fixes: 35cd18048542 ("hwmon: (lm75) Aproximate sample times to data-sheet values") Signed-off-by: Abdel Alkuor <alkuor@gmail.com> Link: https://lore.kernel.org/r/20240106030254.384963-1-alkuor@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (lm75) Add AMS AS6200 temperature sensorAbdel Alkuor2024-01-021-14/+94
| | | | | | | | | | | | | | | | | | as6200 is a temperature sensor with 0.0625°C resolution and a range between -40°C to 125°C. By default, the driver configures as6200 as following: - Converstion rate: 8 Hz - Conversion mode: continuous - Consecutive fault counts: 4 samples - Alert state: high polarity - Alert mode: comparator mode Interrupt is supported for the alert pin. Signed-off-by: Abdel Alkuor <alkuor@gmail.com> Link: https://lore.kernel.org/r/d1686678991bf8ee0d00cb08ca046798f37ca4b3.1703127334.git.alkuor@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (lm75) remove now-unused includeLuca Ceresoli2024-01-021-1/+0
| | | | | | | | | | Including hwmon-sysfs.h is not needed since sysfs code got removed from this file in commit 08b024338166 ("hwmon: (lm75) Convert to use new hwmon registration API"). Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Link: https://lore.kernel.org/r/20231228-hwmon-cleanup-include-v1-1-e36f65aee1f0@bootlin.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus) Add support for MPS Multi-phase mp2856/mp2857 controllerPeter Yin2024-01-023-0/+476
| | | | | | | | | | | | Add support for mp2856/mp2857 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a dual-loop, digital, multi-phase, modulation controller. Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com> Signed-off-by: Potin Lai <potin.lai.pt@gmail.com> Link: https://lore.kernel.org/r/20231211160519.21254-3-potin.lai.pt@gmail.com [groeck: Fix checkpatch issues, use i2c_get_match_data()] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (aquacomputer_d5next) Remove unneeded CONFIG_DEBUG_FS #ifdefAleksa Savic2024-01-021-10/+0
| | | | | | | | | | Remove the #ifdef check for CONFIG_DEBUG_FS and the empty variant of aqc_debugfs_init(), because the debugfs functions already do nothing if debugfs isn't enabled. Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com> Link: https://lore.kernel.org/r/20231216140754.336775-1-savicaleksa83@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (k10temp) Add support for AMD Family 19h Model 8hJami Kurki2024-01-021-0/+1
| | | | | | | | | | | | | | | Add support for AMD Family 19h Model 8h CPUs, which appear to be the Zen 3 based AMD Threadripper 5000WX series (Chagall). The patch was tested with an AMD Threadripper 5955WX. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218244 Tested-by: Jami Kurki <bindkeys@gmail.com> Signed-off-by: Jami Kurki <bindkeys@gmail.com> Co-developed-by: Armin Wolf <W_Armin@gmx.de> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231211210206.11060-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: Add driver for Gigabyte AORUS Waterforce AIO coolersAleksa Savic2024-01-023-0/+439
| | | | | | | | | | | | | | | | | | | | | | | | This driver exposes hardware sensors of the Gigabyte AORUS Waterforce all-in-one CPU liquid coolers, which communicate through a proprietary USB HID protocol. Report offsets were initially discovered in [1] and confirmed by me on a Waterforce X240 by observing the sent reports from the official software. Available sensors are pump and fan speed in RPM, as well as coolant temperature. Also available through debugfs is the firmware version. Attaching a fan is optional and allows it to be controlled from the device. If it's not connected, the fan-related sensors will report zeroes. The addressable RGB LEDs and LCD screen are not supported in this driver and should be controlled through userspace tools. [1]: https://github.com/liquidctl/liquidctl/issues/167 Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com> Link: https://lore.kernel.org/r/20231207122402.107032-1-savicaleksa83@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (smsc47m1) Rename global platform device variableUwe Kleine-König2024-01-021-8/+8
| | | | | | | | | pdev is a bad name for a global variable. Still more as the driver has functions where pdev is a local variable. Rename it to smsc47m1_pdev. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/68a959b56da7f9452557d08c72249182364b0dd0.1701957841.git.u.kleine-koenig@pengutronix.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (smsc47m1) Simplify device registrationUwe Kleine-König2024-01-021-30/+13
| | | | | | | | | | Use platform_device_register_full() instead of open coding this function. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/ab326fb9b1ad2191583b4cb3a8bd624dfedb908e.1701957841.git.u.kleine-koenig@pengutronix.de [groeck: Removed double empty line] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (smsc47m1) Convert to platform remove callback returning voidUwe Kleine-König2024-01-021-4/+2
| | | | | | | | | | | | | | | | | | | The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/a732270539ef63094a32d0ff582f78e640caf3e4.1701957841.git.u.kleine-koenig@pengutronix.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (smsc47m1) Mark driver struct with __refdata to prevent section mismatchUwe Kleine-König2024-01-021-1/+7
| | | | | | | | | | | | | | As described in the added code comment, a reference to .exit.text is ok for drivers registered via module_platform_driver_probe(). Make this explicit to prevent the following section mismatch warning WARNING: modpost: drivers/hwmon/smsc47m1: section mismatch in reference: smsc47m1_driver+0x8 (section: .data) -> smsc47m1_remove (section: .exit.text) that triggers on an allmodconfig W=1 build. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/57977a88a9b99b6555b227aa4994ac3df10c6490.1701957840.git.u.kleine-koenig@pengutronix.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus) Add ltc4286 driverDelphine CC Chiu2024-01-023-0/+186
| | | | | | | | | Add a driver to support ltc4286 chip Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@Wiwynn.com> Link: https://lore.kernel.org/r/20231123015440.199822-3-Delphine_CC_Chiu@Wiwynn.com [groeck: Fixed formatting] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (max31827) Add custom attribute for resolutionDaniel Matyas2023-12-111-11/+111
| | | | | | | | | | | | | | | | | | | Added custom channel-specific (temp1) attribute for resolution. The wait time for a conversion in one-shot mode (enable = 0) depends on the resolution. When resolution is 12-bit, the conversion time is 140ms, but the minimum update_interval is 125ms. Handled this problem by waiting an additional 15ms (125ms + 15ms = 140ms). Added 'mask' parameter to the shutdown_write() function. Now it can either write or update bits, depending on the value of mask. This is needed, because for alarms a write is necessary, but for resolution only the resolution bits should be updated. Signed-off-by: Daniel Matyas <daniel.matyas@analog.com> Link: https://lore.kernel.org/r/20231031182158.124608-5-daniel.matyas@analog.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (max31827) Return closest value in update_intervalDaniel Matyas2023-12-111-3/+2
| | | | | | | | | | When user writes a value to update_interval which does not match the possible values, instead of returning invalid error, return the closest value. Signed-off-by: Daniel Matyas <daniel.matyas@analog.com> Link: https://lore.kernel.org/r/20231031182158.124608-4-daniel.matyas@analog.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (max31827) Update bits with shutdown_write()Daniel Matyas2023-12-111-4/+11
| | | | | | | | | | | Added 'mask' parameter to the shutdown_write() function. Now it can either write or update bits, depending on the value of mask. This is needed, because for alarms a write is necessary, but for resolution only the resolution bits should be updated. Signed-off-by: Daniel Matyas <daniel.matyas@analog.com> Link: https://lore.kernel.org/r/20231031182158.124608-3-daniel.matyas@analog.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (max31827) Add support for max31828 and max31829Daniel Matyas2023-12-111-11/+53
| | | | | | | | | | | Created of_match_table and id_table entries for max31828 and max31829. When adi,flt-q and/or adi,alrm-pol are not mentioned, the default configuration is loaded based on the type of the chip. Signed-off-by: Daniel Matyas <daniel.matyas@analog.com> Link: https://lore.kernel.org/r/20231031182158.124608-2-daniel.matyas@analog.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (max31827) Handle new properties from the devicetreeDaniel Matyas2023-12-111-6/+69
| | | | | | | | | | | | Used fwnode to retrieve data from the devicetree in the init_client function. If the uint32 properties are not present, the default values are used for max31827 chip. Signed-off-by: Daniel Matyas <daniel.matyas@analog.com> Link: https://lore.kernel.org/r/20231031182158.124608-1-daniel.matyas@analog.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (corsair-cpro) use NULL instead of 0Marius Zachmann2023-12-111-1/+1
| | | | | | | | | | Replaces the integer 0 with NULL. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202312100455.k6m2eO4N-lkp@intel.com/ Signed-off-by: Marius Zachmann <mail@mariuszachmann.de> Link: https://lore.kernel.org/r/20231210220357.77036-1-mail@mariuszachmann.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (dell-smm) Add Optiplex 7000 to fan control whitelistArmin Wolf2023-12-111-0/+8
| | | | | | | | | | | | A user reported that on this machine, disabling BIOS fan control is necessary in order to change the fan speed. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-10-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (dell-smm) Add support for WMI SMM interfaceArmin Wolf2023-12-112-19/+181
| | | | | | | | | | | | | | | Some Dell machines like the Dell Optiplex 7000 do not support the legacy SMM interface, but instead expect all SMM calls to be issued over a special WMI interface. Add support for this interface so users can control the fans on those machines. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-8-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (dell-smm) Introduce helper function for data initArmin Wolf2023-12-111-18/+28
| | | | | | | | | | | | | | | In the future, multiple SMM calling backends will exist, with each backend being required to initialize its data. Introduce a helper function for this so the code necessary to initialize dell_smm_data is not duplicated between different backends. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-7-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (dell-smm) Move config entries out of i8k_dmi_tableArmin Wolf2023-12-111-56/+73
| | | | | | | | | | | | | | | | | | | | Currently, i8k_dmi_table contains both entries used for DMI matching and entries used to override config options. This does not allow for differentiating between "its safe to issue raw SMM calls on this machine" and "its not safe to issue raw SMM calls on this machine, but here are some config values". Since future SMM backends will need to differentiate between those two cases, move those config entries into a separate table. i8k_dmi_table now serves as a general "its safe to issue raw SMM calls" table. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-6-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (dell-smm) Move DMI config handling to module initArmin Wolf2023-12-111-16/+15
| | | | | | | | | | | | | | Future SMM calling backends will not be able to probe during module init, meaning the DMI tables holding config data would have to drop their __initconst attribute. Prevent this by moving the config handling to module init. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-5-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (dell-smm) Move whitelist handling to module initArmin Wolf2023-12-111-14/+17
| | | | | | | | | | | | | | Future SMM calling backends will not be able to probe during module init, meaning the DMI tables used for whitelisting features would have to drop their __initconst attribute. Prevent this by moving the whitelist handling to module init. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-4-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (dell-smm) Move blacklist handling to module initArmin Wolf2023-12-111-29/+34
| | | | | | | | | | | | | | Future SMM calling backends will not be able to probe during module init, meaning the DMI tables used for backlisting broken features would have to drop their __initconst attribute. Prevent this by moving the blacklist handling to module init. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-3-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (dell-smm) Prepare for multiple SMM calling backendsArmin Wolf2023-12-111-52/+79
| | | | | | | | | | | | | | Modern Dell machines support multiple ways to issue an SMM call. Prepare support for those by introducing dell_smm_ops, which is used by dell_smm_call() to perform a SMM call. Each SMM backend needs to provide a dell_smm_ops structure. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-2-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (hp-wmi-sensors) Fix failure to load on EliteDesk 800 G6James Seo2023-12-111-16/+111
| | | | | | | | | | | | | | | | | | | | | The EliteDesk 800 G6 stores a raw WMI string within the ACPI object in its BIOS corresponding to one instance of HPBIOS_PlatformEvents.Name. This is evidently a valid way of representing a WMI data item as far as the Microsoft ACPI-WMI mapper is concerned, but is preventing the driver from loading. This seems quite rare, but add support for such strings. Treating this as a quirk pretty much means adding that support anyway. Also clean up an oversight in update_numeric_sensor_from_wobj() in which the result of hp_wmi_strdup() was being used without error checking. Reported-by: Lukasz Stelmach <l.stelmach@samsung.com> Closes: https://lore.kernel.org/linux-hwmon/7850a0bd-60e7-88f8-1d6c-0bb0e3234fdc@roeck-us.net/ Tested-by: Lukasz Stelmach <l.stelmach@samsung.com> Signed-off-by: James Seo <james@equiv.tech> Link: https://lore.kernel.org/r/20231123054918.157098-1-james@equiv.tech Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (tmp513) Use SI constants from units.hAndy Shevchenko2023-12-111-11/+10
| | | | | | | | | MILLI and MICRO may be used in the driver to make code more robust against possible miscalculations. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20231128180654.395692-4-andriy.shevchenko@linux.intel.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (tmp513) Simplify with dev_err_probe()Andy Shevchenko2023-12-111-20/+15
| | | | | | | | | | Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20231128180654.395692-3-andriy.shevchenko@linux.intel.com [groeck: Fixed excessive line length] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (tmp513) Don't use "proxy" headersAndy Shevchenko2023-12-111-2/+6
| | | | | | | | | | The driver uses math.h and not util_macros.h. All the same for the kernel.h, replace it with what the driver is using. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20231128180654.395692-2-andriy.shevchenko@linux.intel.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (peci/dimmtemp) Bump timeoutPatrick Rudolph2023-12-111-1/+1
| | | | | | | | | | | | | | | | | The PECI CPU sensors are available as soon as the CPU is powered, however the PECI DIMM sensors are available after DRAM has been trained and thresholds have been written by host firmware. The default timeout of 30 seconds isn't enough for modern multisocket platforms utilizing DDR5 memory to bring up the memory and enable PECI sensor data. Bump the default timeout to 10 minutes in case the system starts without cached DDR5 training data. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Link: https://lore.kernel.org/r/20231130090422.2535542-1-patrick.rudolph@9elements.com [groeck: List affected driver in patch subject] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pc87360) Bounds check data->innr usageKees Cook2023-12-111-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without visibility into the initializers for data->innr, GCC suspects using it as an index could walk off the end of the various 14-element arrays in data. Perform an explicit clamp to the array size. Silences the following warning with GCC 12+: ../drivers/hwmon/pc87360.c: In function 'pc87360_update_device': ../drivers/hwmon/pc87360.c:341:49: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 341 | data->in_max[i] = pc87360_read_value(data, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ 342 | LD_IN, i, | ~~~~~~~~~ 343 | PC87365_REG_IN_MAX); | ~~~~~~~~~~~~~~~~~~~ ../drivers/hwmon/pc87360.c:209:12: note: at offset 255 into destination object 'in_max' of size 14 209 | u8 in_max[14]; /* Register value */ | ^~~~~~ Cc: Jim Cromie <jim.cromie@gmail.com> Cc: Jean Delvare <jdelvare@suse.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: linux-hwmon@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/r/20231130200207.work.679-kees@kernel.org [groeck: Added comment into code clarifying context] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (nct6775) Fix fan speed set failure in automatic modeXing Tong Wu2023-12-111-0/+7
| | | | | | | | | | Setting the fan speed is only valid in manual mode; it is not possible to set the fan's speed in automatic mode. Return error when attempting to set the fan speed in automatic mode. Signed-off-by: Xing Tong Wu <xingtong.wu@siemens.com> Link: https://lore.kernel.org/r/20231121081604.2499-3-xingtong_wu@163.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (nct6775) Add support for 2 additional fan controlsXing Tong Wu2023-12-111-4/+4
| | | | | | | | | The nct6116 has 2 additional PWM pins compared to the nct6106. Extend the nct6106 PWM arrays to support the nct6116. Signed-off-by: Xing Tong Wu <xingtong.wu@siemens.com> Link: https://lore.kernel.org/r/20231121081604.2499-2-xingtong_wu@163.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (pmbus) Add support for MPS Multi-phase mp5990Peter Yin2023-12-113-0/+189
| | | | | | | | | | Add support for mp5990 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a Hot-Swap Controller. Signed-off-by: Peter Yin <peteryin.openbmc@gmail.com> Link: https://lore.kernel.org/r/20231113155008.2147090-3-peteryin.openbmc@gmail.com [groeck: Improved and clarified comments] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (lm25066) Use i2c_get_match_data()Rob Herring2023-12-111-11/+3
| | | | | | | | | | | | | | Use preferred i2c_get_match_data() instead of of_match_device() and i2c_match_id() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Adjust the 'chips' enum to not use 0, so that no match data can be distinguished from a valid enum value. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231115205703.3730448-3-robh@kernel.org [groeck: Use double cast for enum chips assignment to make compiler happy] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (nct6775-core) Explicitly initialize nct6775_device_names indexesGuenter Roeck2023-12-111-13/+13
| | | | | | | | | | | | | | Changing the "kinds" enum start value to be 1-indexed instead of 0-indexed caused look-ups in nct6775_device_names[] to be misaligned or off the end. Initialize the string list with explicit indexes. Cc: Rob Herring <robh@kernel.org> Cc: Kees Cook <keescook@chromium.org> Fixes: 10a0575ea09d ("hwmon: nct6775-i2c: Use i2c_get_match_data()") Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (nct6775-platform) Explicitly initialize nct6775_sio_names indexesKees Cook2023-12-111-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changing the "kinds" enum start value to be 1-indexed instead of 0-indexed caused look-ups in nct6775_sio_namesp[] to be misaligned or off the end. Coverity reported: *** CID 1571052: Memory - illegal accesses (OVERRUN) drivers/hwmon/nct6775-platform.c:1075 in nct6775_find() 1069 sio_data->kind == nct6793 || sio_data->kind == nct6795 || 1070 sio_data->kind == nct6796 || sio_data->kind == nct6797 || 1071 sio_data->kind == nct6798 || sio_data->kind == nct6799) 1072 nct6791_enable_io_mapping(sio_data); 1073 1074 sio_data->sio_exit(sio_data); vvv CID 1571052: Memory - illegal accesses (OVERRUN) vvv Overrunning array "nct6775_sio_names" of 13 8-byte elements at element index 13 (byte offset 111) using index "sio_data->kind" (which evaluates to 13). 1075 pr_info("Found %s or compatible chip at %#x:%#x\n", 1076 nct6775_sio_names[sio_data->kind], sioaddr, addr); 1077 1078 return addr; 1079 } 1080 Initialize the string list with explicit indexes. Cc: Guenter Roeck <linux@roeck-us.net> Cc: Rob Herring <robh@kernel.org> Cc: Jean Delvare <jdelvare@suse.com> Cc: linux-hwmon@vger.kernel.org Fixes: 10a0575ea09d ("hwmon: nct6775-i2c: Use i2c_get_match_data()") Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20231116140144.work.027-kees@kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (nct6775-i2c) Use i2c_get_match_data()Rob Herring2023-12-112-13/+3
| | | | | | | | | | | | | | Use preferred i2c_get_match_data() instead of of_match_device() and i2c_match_id() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Adjust the 'kinds' enum to not use 0, so that no match data can be distinguished from a valid enum value. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231115205703.3730448-2-robh@kernel.org [groeck: Use double cast for i2c_get_match_data() to make clang happy] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (max6650) Use i2c_get_match_data()Rob Herring2023-12-111-5/+3
| | | | | | | | | | Use preferred i2c_get_match_data() instead of of_match_device() and i2c_match_id() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231115205703.3730448-1-robh@kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (aspeed-pwm-tacho) Fix -Wstringop-overflow warning in ↵Gustavo A. R. Silva2023-12-111-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | aspeed_create_fan_tach_channel() Based on the documentation below, the maximum number of Fan tach channels is 16: Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt:45: 45 - aspeed,fan-tach-ch : should specify the Fan tach input channel. 46 integer value in the range 0 through 15, with 0 indicating 47 Fan tach channel 0 and 15 indicating Fan tach channel 15. 48 At least one Fan tach input channel is required. However, the compiler doesn't know that, and legitimaly warns about a potential overwrite in array `u8 fan_tach_ch_source[16]` in `struct aspeed_pwm_tacho_data`, in case `index` takes a value outside the boundaries of the array: drivers/hwmon/aspeed-pwm-tacho.c: 179 struct aspeed_pwm_tacho_data { ... 184 bool fan_tach_present[16]; ... 193 u8 fan_tach_ch_source[16]; 196 }; In function ‘aspeed_create_fan_tach_channel’, inlined from ‘aspeed_create_fan’ at drivers/hwmon/aspeed-pwm-tacho.c:877:2, inlined from ‘aspeed_pwm_tacho_probe’ at drivers/hwmon/aspeed-pwm-tacho.c:936:9: drivers/hwmon/aspeed-pwm-tacho.c:751:49: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 751 | priv->fan_tach_ch_source[index] = pwm_source; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ drivers/hwmon/aspeed-pwm-tacho.c: In function ‘aspeed_pwm_tacho_probe’: drivers/hwmon/aspeed-pwm-tacho.c:193:12: note: at offset [48, 255] into destination object ‘fan_tach_ch_source’ of size 16 193 | u8 fan_tach_ch_source[16]; | ^~~~~~~~~~~~~~~~~~ Fix this by sanity checking `index` before using it to index arrays of size 16 elements in `struct aspeed_pwm_tacho_data`. Also, pass `dev` as argument to function `aspeed_create_fan_tach_channel()`, and add an error message in case `index` is out-of-bounds, in which case return `-EINVAL`. Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/ZVPQJIP26dIzRAr6@work [groeck: Fixed continuation line alignment] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: Fix some kernel-doc commentsYang Li2023-12-111-1/+2
| | | | | | | | | | | | | | | Fix some kernel-doc comments to silence the warnings: drivers/hwmon/sht4x.c:65: warning: Function parameter or member 'valid' not described in 'sht4x_data' drivers/hwmon/sht4x.c:73: warning: Function parameter or member 'data' not described in 'sht4x_read_values' drivers/hwmon/sht4x.c:73: warning: Excess function parameter 'sht4x_data' description in 'sht4x_read_values' Reported-by: Abaci Robot <abaci@linux.alibaba.com> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7220 Signed-off-by: Yang Li <yang.lee@linux.alibaba.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Link: https://lore.kernel.org/r/20231110055341.39939-1-yang.lee@linux.alibaba.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (emc1403) Add support for EMC1442Delphine CC Chiu2023-12-111-1/+5
| | | | | | | | | | Add support for EMC1442 which is compatible with EMC1402. Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com> Reviewed-by: Patrick Williams <patrick@stwcx.xyz> Link: https://lore.kernel.org/r/20231102090808.427351-1-Delphine_CC_Chiu@wiwynn.com [groeck: compatible with EMC1402, not EMC1403] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (ltc2991) remove device reference from stateAntoniu Miclaus2023-12-111-11/+9
| | | | | | | | | | | Remove device reference from struct ltc2991_state since it is used only inside the init function. Pass the struct device as parameter to the init function instead. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Link: https://lore.kernel.org/r/20231031095647.48376-1-antoniu.miclaus@analog.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (npcm750-pwm-fan) Add NPCM8xx supportTomer Maimon2023-12-111-4/+26
| | | | | | | | | | | | | | Adding Pulse Width Modulation (PWM) and fan tacho NPCM8xx support to NPCM PWM and fan tacho driver. NPCM8xx uses a different number of PWM devices. As part of adding NPCM8XX support: - Add NPCM8xx specific compatible string. - Add data to handle architecture-specific PWM parameters. Signed-off-by: Tomer Maimon <tmaimon77@gmail.com> Link: https://lore.kernel.org/r/20231031075806.400872-2-tmaimon77@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (corsair-psu) Fix probe when built-inArmin Wolf2023-12-081-1/+17
| | | | | | | | | | | | | | It seems that when the driver is built-in, the HID bus is initialized after the driver is loaded, which whould cause module_hid_driver() to fail. Fix this by registering the driver after the HID bus using late_initcall() in accordance with other hwmon HID drivers. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231207210723.222552-1-W_Armin@gmx.de [groeck: Dropped "compile tested" comment; the patch has been tested but the tester did not provide a Tested-by: tag] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (nzxt-kraken2) Fix error handling path in kraken2_probe()Christophe JAILLET2023-12-031-2/+2
| | | | | | | | | | | | | | | There is no point in calling hid_hw_stop() if hid_hw_start() has failed. There is no point in calling hid_hw_close() if hid_hw_open() has failed. Update the error handling path accordingly. Fixes: 82e3430dfa8c ("hwmon: add driver for NZXT Kraken X42/X52/X62/X72") Reported-by: Aleksa Savic <savicaleksa83@gmail.com> Closes: https://lore.kernel.org/all/121470f0-6c1f-418a-844c-7ec2e8a54b8e@gmail.com/ Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Jonas Malaco <jonas@protocubo.io> Link: https://lore.kernel.org/r/a768e69851a07a1f4e29f270f4e2559063f07343.1701617030.git.christophe.jaillet@wanadoo.fr Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: (acpi_power_meter) Fix 4.29 MW bugArmin Wolf2023-11-301-0/+4
| | | | | | | | | | | | | | | | | | | The ACPI specification says: "If an error occurs while obtaining the meter reading or if the value is not available then an Integer with all bits set is returned" Since the "integer" is 32 bits in case of the ACPI power meter, userspace will get a power reading of 2^32 * 1000 miliwatts (~4.29 MW) in case of such an error. This was discovered due to a lm_sensors bugreport (https://github.com/lm-sensors/lm-sensors/issues/460). Fix this by returning -ENODATA instead. Tested-by: <urbinek@gmail.com> Fixes: de584afa5e18 ("hwmon driver for ACPI 4.0 power meters") Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231124182747.13956-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
* hwmon: max31827: include regulator headerAntoniu Miclaus2023-11-141-0/+1
| | | | | | | | | Include `linux/regulator/consumer.h` since the driver is using `devm_regulator_get_enable` function. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Link: https://lore.kernel.org/r/20231031091324.23991-1-antoniu.miclaus@analog.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>