]> www.infradead.org Git - users/willy/xarray.git/log
users/willy/xarray.git
7 months agohwmon: Remove devm_hwmon_device_unregister() API function
Guenter Roeck [Fri, 13 Sep 2024 14:11:42 +0000 (07:11 -0700)]
hwmon: Remove devm_hwmon_device_unregister() API function

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 <m@ttsande.rs>
Closes: https://lore.kernel.org/linux-hwmon/488b3bdf870ea76c4b943dbe5fd15ac8113019dc.camel@kernel.org/
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (sch5636) Print unknown ID in error string via %*pE
Andy Shevchenko [Wed, 11 Sep 2024 20:19:03 +0000 (23:19 +0300)]
hwmon: (sch5636) Print unknown ID in error string via %*pE

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 <andriy.shevchenko@linux.intel.com>
Message-ID: <20240911201903.2886874-1-andriy.shevchenko@linux.intel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (sht21) Use %*ph to print small buffer
Andy Shevchenko [Wed, 11 Sep 2024 19:46:27 +0000 (22:46 +0300)]
hwmon: (sht21) Use %*ph to print small buffer

Use %*ph format to print small buffer as hex string.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Message-ID: <20240911194627.2885506-1-andriy.shevchenko@linux.intel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (pmbus/mpq7932) Constify struct regulator_desc
Christophe JAILLET [Sun, 8 Sep 2024 08:32:38 +0000 (10:32 +0200)]
hwmon: (pmbus/mpq7932) Constify struct regulator_desc

'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 <christophe.jaillet@wanadoo.fr>
Message-ID: <c0585a07547ec58d99a5bff5e02b398114bbe312.1725784343.git.christophe.jaillet@wanadoo.fr>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: pmbus: pli12096bc: Add write delay
Patrick Rudolph [Mon, 2 Sep 2024 07:53:16 +0000 (09:53 +0200)]
hwmon: pmbus: pli12096bc: Add write delay

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 <patrick.rudolph@9elements.com>
Message-ID: <20240902075319.585656-5-patrick.rudolph@9elements.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: pmbus: zl6100: Use generic code
Patrick Rudolph [Mon, 2 Sep 2024 07:53:15 +0000 (09:53 +0200)]
hwmon: pmbus: zl6100: Use generic code

Use generic pmbus bus access delay.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Message-ID: <20240902075319.585656-4-patrick.rudolph@9elements.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: pmbus: ucd9000: Use generic code
Patrick Rudolph [Mon, 2 Sep 2024 07:53:14 +0000 (09:53 +0200)]
hwmon: pmbus: ucd9000: Use generic code

Use generic pmbus bus write access delay.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Message-ID: <20240902075319.585656-3-patrick.rudolph@9elements.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: pmbus: max15301: Use generic code
Patrick Rudolph [Mon, 2 Sep 2024 07:53:13 +0000 (09:53 +0200)]
hwmon: pmbus: max15301: Use generic code

Use the generic pmbus bus access delay.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Message-ID: <20240902075319.585656-2-patrick.rudolph@9elements.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: pmbus: Implement generic bus access delay
Patrick Rudolph [Mon, 2 Sep 2024 07:53:12 +0000 (09:53 +0200)]
hwmon: pmbus: Implement generic bus access delay

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 <patrick.rudolph@9elements.com>
Message-ID: <20240902075319.585656-1-patrick.rudolph@9elements.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Use shunt voltage to calculate current
Guenter Roeck [Thu, 29 Aug 2024 00:21:41 +0000 (17:21 -0700)]
hwmon: (ina2xx) Use shunt voltage to calculate current

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Add support for current limits
Guenter Roeck [Wed, 28 Aug 2024 22:23:53 +0000 (15:23 -0700)]
hwmon: (ina2xx) Add support for current limits

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Pass register to alert limit write functions
Guenter Roeck [Wed, 28 Aug 2024 22:18:51 +0000 (15:18 -0700)]
hwmon: (ina2xx) Pass register to alert limit write functions

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Convert to use with_info hwmon API
Guenter Roeck [Thu, 25 Jul 2024 05:41:16 +0000 (22:41 -0700)]
hwmon: (ina2xx) Convert to use with_info hwmon API

Convert driver to use the with_info hardware monitoring API
to reduce its dependency on sysfs attribute functions.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Move ina2xx_get_value()
Guenter Roeck [Thu, 1 Aug 2024 22:34:48 +0000 (15:34 -0700)]
hwmon: (ina2xx) Move ina2xx_get_value()

ina2xx_get_value() will be needed earlier in the next patch, so move it.
No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Set alert latch
Guenter Roeck [Tue, 23 Jul 2024 23:17:02 +0000 (16:17 -0700)]
hwmon: (ina2xx) Set alert latch

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Consolidate chip initialization code
Guenter Roeck [Wed, 24 Jul 2024 16:31:08 +0000 (09:31 -0700)]
hwmon: (ina2xx) Consolidate chip initialization code

Move all chip initialization code into a single function.

No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Fix various overflow issues
Guenter Roeck [Wed, 24 Jul 2024 16:42:16 +0000 (09:42 -0700)]
hwmon: (ina2xx) Fix various overflow issues

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Re-initialize chip using regmap functions
Guenter Roeck [Tue, 23 Jul 2024 23:04:29 +0000 (16:04 -0700)]
hwmon: (ina2xx) Re-initialize chip using regmap functions

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Use local regmap pointer if used more than once
Guenter Roeck [Thu, 1 Aug 2024 21:57:39 +0000 (14:57 -0700)]
hwmon: (ina2xx) Use local regmap pointer if used more than once

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Mark regmap_config as const
Guenter Roeck [Thu, 1 Aug 2024 23:43:03 +0000 (16:43 -0700)]
hwmon: (ina2xx) Mark regmap_config as const

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Use bit operations
Guenter Roeck [Tue, 23 Jul 2024 20:25:31 +0000 (13:25 -0700)]
hwmon: (ina2xx) Use bit operations

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Replace platform data with device properties
Guenter Roeck [Tue, 23 Jul 2024 20:23:30 +0000 (13:23 -0700)]
hwmon: (ina2xx) Replace platform data with device properties

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina2xx) Reorder include files to alphabetic order
Guenter Roeck [Tue, 23 Jul 2024 20:21:12 +0000 (13:21 -0700)]
hwmon: (ina2xx) Reorder include files to alphabetic order

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 <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agodt-bindings: hwmon: Convert ltc2978.txt to yaml
Frank Li [Thu, 29 Aug 2024 15:06:41 +0000 (11:06 -0400)]
dt-bindings: hwmon: Convert ltc2978.txt to yaml

Convert binding doc ltc2978.txt to yaml format.
Additional change:
- add i2c node.

Fix below warning:
arch/arm64/boot/dts/freescale/fsl-lx2160a-clearfog-cx.dtb: /soc/i2c@2000000/i2c-mux@77/i2c@2/regulator@5c:
failed to match any schema with compatible: ['lltc,ltc3882']

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Message-ID: <20240829150641.1307906-1-Frank.Li@nxp.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (oxp-sensors) Add missing breaks to fix -Wimplicit-fallthrough with clang
Nathan Chancellor [Wed, 28 Aug 2024 18:05:35 +0000 (11:05 -0700)]
hwmon: (oxp-sensors) Add missing breaks to fix -Wimplicit-fallthrough with clang

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 <nathan@kernel.org>
Message-ID: <20240828-hwmon-oxp-sensors-fix-clang-implicit-fallthrough-v1-1-dc48496ac67a@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (pwmfan) Do not force disable pwm controller
Johannes Kirchmair [Tue, 27 Aug 2024 05:44:54 +0000 (07:44 +0200)]
hwmon: (pwmfan) Do not force disable pwm controller

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 <johannes.kirchmair@skidata.com>
Message-ID: <20240827054454.521494-1-mailinglist1@johanneskirchmair.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (pc87360) Use min() macro
Shen Lichuan [Tue, 27 Aug 2024 07:04:42 +0000 (15:04 +0800)]
hwmon: (pc87360) Use min() macro

Use the min() macro to simplify the pc87360_init_device() function
and improve its readability.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
Message-ID: <20240827070442.40667-1-shenlichuan@vivo.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: Add sophgo SG2042 external hardware monitor support
Inochi Amaoto [Sat, 17 Aug 2024 02:22:57 +0000 (10:22 +0800)]
hwmon: Add sophgo SG2042 external hardware monitor support

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 <inochiama@outlook.com>
Message-ID: <IA1PR20MB49536C786048D1E676BB9C20BB822@IA1PR20MB4953.namprd20.prod.outlook.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agodt-bindings: hwmon: Add Sophgo SG2042 external hardware monitor support
Inochi Amaoto [Sat, 17 Aug 2024 02:22:56 +0000 (10:22 +0800)]
dt-bindings: hwmon: Add Sophgo SG2042 external hardware monitor support

Due to the design, Sophgo SG2042 use an external MCU to provide
hardware information, thermal information and reset control.

Add bindings for this monitor device.

Signed-off-by: Inochi Amaoto <inochiama@outlook.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Chen Wang <unicorn_wang@outlook.com>
Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
Message-ID: <IA1PR20MB49538276F283C4D01364AEB6BB822@IA1PR20MB4953.namprd20.prod.outlook.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (tmp464): Simplify with scoped for each OF child loop
Jinjie Ruan [Thu, 22 Aug 2024 06:29:56 +0000 (14:29 +0800)]
hwmon: (tmp464): Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Message-ID: <20240822062956.3490387-9-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (tmp421): Simplify with scoped for each OF child loop
Jinjie Ruan [Thu, 22 Aug 2024 06:29:55 +0000 (14:29 +0800)]
hwmon: (tmp421): Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Message-ID: <20240822062956.3490387-8-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (npcm750-pwm-fan): Simplify with scoped for each OF child loop
Jinjie Ruan [Thu, 22 Aug 2024 06:29:54 +0000 (14:29 +0800)]
hwmon: (npcm750-pwm-fan): Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Message-ID: <20240822062956.3490387-7-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (nct7802): Simplify with scoped for each OF child loop
Jinjie Ruan [Thu, 22 Aug 2024 06:29:53 +0000 (14:29 +0800)]
hwmon: (nct7802): Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Message-ID: <20240822062956.3490387-6-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (lm90): Simplify with scoped for each OF child loop
Jinjie Ruan [Thu, 22 Aug 2024 06:29:52 +0000 (14:29 +0800)]
hwmon: (lm90): Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Message-ID: <20240822062956.3490387-5-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ina3221): Simplify with scoped for each OF child loop
Jinjie Ruan [Thu, 22 Aug 2024 06:29:51 +0000 (14:29 +0800)]
hwmon: (ina3221): Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Message-ID: <20240822062956.3490387-4-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (aspeed-pwm-tacho): Simplify with scoped for each OF child loop
Jinjie Ruan [Thu, 22 Aug 2024 06:29:50 +0000 (14:29 +0800)]
hwmon: (aspeed-pwm-tacho): Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Message-ID: <20240822062956.3490387-3-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (aspeed-g6-pwm-tacho): Simplify with scoped for each OF child loop
Jinjie Ruan [Thu, 22 Aug 2024 06:29:49 +0000 (14:29 +0800)]
hwmon: (aspeed-g6-pwm-tacho): Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Message-ID: <20240822062956.3490387-2-ruanjinjie@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (k10temp): Use cpu_feature_enabled() for detecting zen
Mario Limonciello [Tue, 20 Aug 2024 05:35:57 +0000 (00:35 -0500)]
hwmon: (k10temp): Use cpu_feature_enabled() for detecting zen

This removes some boilerplate from the code and will allow adding
future CPUs by just device IDs.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Message-ID: <20240820053558.1052853-1-superm1@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agodt-bindings: hwmon: Add maxim max31790
Chanh Nguyen [Thu, 22 Aug 2024 08:48:08 +0000 (08:48 +0000)]
dt-bindings: hwmon: Add maxim max31790

Add device tree bindings and an example for max31790 device.

Signed-off-by: Chanh Nguyen <chanh@os.amperecomputing.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Message-ID: <20240822084808.299884-1-chanh@os.amperecomputing.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (oxp-sensors) Add support for multiple new devices.
Derek J. Clark [Thu, 22 Aug 2024 18:35:25 +0000 (11:35 -0700)]
hwmon: (oxp-sensors) Add support for multiple new devices.

Add support for the OrangePi NEO-01. It uses different registers for PWM
manual mode, set PWM, and read fan speed than previous devices. Valid PWM
input and duty cycle is 1-244, we scale this from 1-255 to maintain
compatibility with the existing interface.

Add OneXPlayer 2 series, OneXFly, and X1 series models. The 2/X1 series use
new registers for turbo button takeover and read fan speed. X1 has an Intel
variant so change the CPU detection at init to only check for the affected
devices. While at it, adjust formatting of some constants and reorder all
cases alphabetically for consistency. Rename OXP_OLD constants to OXP_MINI
for disambiguation. Update code comments for clarity.

Add support for AYANEO models 2S, AIR 1S, Flip series, GEEK 1S, and KUN.

Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
Tested-by: Kevin Greenberg <kdgreenberg234@protonmail.com>
Tested-by: Joshua Tam <csinaction@pm.me>
Tested-by: Parth Menon <parthasarathymenon@gmail.com>
Tested-by: Philip Müller <philm@manjaro.org>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202408160329.TLNbIwRC-lkp@intel.com/
Message-ID: <20240822183525.27289-2-derekjohn.clark@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (stts751) Add "st" vendor prefix to "stts751" compatible string
Rob Herring (Arm) [Mon, 26 Aug 2024 19:18:11 +0000 (14:18 -0500)]
hwmon: (stts751) Add "st" vendor prefix to "stts751" compatible string

The documented compatible string is "st,stts751", not "stts751". Even if
"stts751" was in use, there's no need to list "stts751" in the DT match
table. The I2C core will strip any vendor prefix and match against the
i2c_device_id table which has an "stts751" entry.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Message-ID: <20240826191811.1416011-1-robh@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (ntc_thermistor) fix module autoloading
Yuntao Liu [Thu, 15 Aug 2024 08:30:21 +0000 (08:30 +0000)]
hwmon: (ntc_thermistor) fix module autoloading

Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded
based on the alias from of_device_id table.

Fixes: 9e8269de100d ("hwmon: (ntc_thermistor) Add DT with IIO support to NTC thermistor driver")
Signed-off-by: Yuntao Liu <liuyuntao12@huawei.com>
Message-ID: <20240815083021.756134-1-liuyuntao12@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (sch5627) Remove unused declaration sch56xx_watchdog_unregister()
Yue Haibing [Fri, 16 Aug 2024 09:57:40 +0000 (17:57 +0800)]
hwmon: (sch5627) Remove unused declaration sch56xx_watchdog_unregister()

Commit 2be5f0d75325 ("hwmon: (sch56xx) Use devres functions for watchdog")
removed the implementation but leave declaration.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Message-ID: <20240816095740.877729-1-yuehaibing@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (gsc-hwmon) fix module autoloading
Liao Chen [Wed, 14 Aug 2024 02:45:55 +0000 (02:45 +0000)]
hwmon: (gsc-hwmon) fix module autoloading

Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded
based on the alias from of_device_id table.

Signed-off-by: Liao Chen <liaochen4@huawei.com>
Message-ID: <20240814024555.3875387-1-liaochen4@huawei.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: Add thermal sensor driver for Surface Aggregator Module
Maximilian Luz [Sun, 11 Aug 2024 00:14:41 +0000 (02:14 +0200)]
hwmon: Add thermal sensor driver for Surface Aggregator Module

Some of the newer Microsoft Surface devices (such as the Surface Book
3 and Pro 9) have thermal sensors connected via the Surface Aggregator
Module (the embedded controller on those devices). Add a basic driver
to read out the temperature values of those sensors.

The EC can have up to 16 thermal sensors connected via a single
sub-device, each providing temperature readings and a label string.

Link: https://github.com/linux-surface/surface-aggregator-module/issues/59
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Co-developed-by: Ivor Wanders <ivor@iwanders.net>
Signed-off-by: Ivor Wanders <ivor@iwanders.net>
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Message-ID: <20240811001503.753728-1-luzmaximilian@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (nct6775) add G15CF to ASUS WMI monitoring list
Denis Pauk [Mon, 12 Aug 2024 15:26:38 +0000 (18:26 +0300)]
hwmon: (nct6775) add G15CF to ASUS WMI monitoring list

Boards G15CF has got a nct6775 chip, but by default there's no use of it
because of resource conflict with WMI method.

Add the board to the WMI monitoring list.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=204807
Signed-off-by: Denis Pauk <pauk.denis@gmail.com>
Tested-by: Attila <attila@fulop.one>
Message-ID: <20240812152652.1303-1-pauk.denis@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (chipcap2) Drop cc2_disable() in the probe and return dev_err_probe()
Javier Carrasco [Mon, 12 Aug 2024 22:59:53 +0000 (00:59 +0200)]
hwmon: (chipcap2) Drop cc2_disable() in the probe and return dev_err_probe()

There is no need to actively disable a regulator that has not been
enabled by the driver, which makes the call to cc2_disable() in the
probe function meaningless, because the probe function never enables
the device's dedicated regulator.

Once the call to cc2_disable() is dropped, the error paths can directly
return dev_err_probe() in all cases.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Message-ID: <20240813-chipcap2-probe-improvements-v2-1-e9a2932a8a00@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (lm92) Update documentation
Guenter Roeck [Sun, 28 Jul 2024 22:52:25 +0000 (15:52 -0700)]
hwmon: (lm92) Update documentation

Update datasheet references. Replace misleading 'force parameter needed'
with 'must be instantiated explicitly'. Explain the reason for the missing
auto-detection. Mention all supported chips in Kconfig.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (lm92) Convert to with_info hwmon API
Guenter Roeck [Wed, 17 Jul 2024 04:46:43 +0000 (21:46 -0700)]
hwmon: (lm92) Convert to with_info hwmon API

Convert driver to with_info hwmon API to simplify the code and
to reduce its size.

No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (lm92) Convert to use regmap
Guenter Roeck [Wed, 17 Jul 2024 00:54:25 +0000 (17:54 -0700)]
hwmon: (lm92) Convert to use regmap

Use regmap for local caching and for multi-byte operations to be able
to use regmap API functions and to reduce the need for locking in the
driver.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (lm92) Replace chip IDs with limit register resolution
Guenter Roeck [Wed, 17 Jul 2024 04:48:07 +0000 (21:48 -0700)]
hwmon: (lm92) Replace chip IDs with limit register resolution

The chip IDs are not used by the driver. Drop them. Use driver data to
store the limit register resolution instead, and use this information
when writing temperature limits to improve chip specific rounding and
to avoid writing into unused register bits.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (lm92) Reorder include files to alphabetic order
Guenter Roeck [Wed, 17 Jul 2024 03:57:19 +0000 (20:57 -0700)]
hwmon: (lm92) Reorder include files to alphabetic order

Simplify driver maintenance by reordering files to alphabetic order.

No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (lm92) Improve auto-detection accuracy
Guenter Roeck [Wed, 17 Jul 2024 19:13:12 +0000 (12:13 -0700)]
hwmon: (lm92) Improve auto-detection accuracy

Checking three configuration register bits and the manufacturer ID
register to auto-detect LM92 is a bit vague. Repeat twice on replicated
register addresses to improve detection accuracy.  Check the manufacturer
ID first and bail out immediately without reading the other register if
there is a mismatch to reduce the number of i2c transfers needed in that
case. Also explicitly test for an error from reading the configuration
register to avoid potential situations where the returned error masked
against 0xe0 is 0.

While at it, drop "lm92: Found National Semiconductor LM92 chip" detection
noise.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 months agohwmon: (vexpress) Use of_property_present()
Rob Herring (Arm) [Wed, 31 Jul 2024 19:12:51 +0000 (13:12 -0600)]
hwmon: (vexpress) Use of_property_present()

Use of_property_present() to test for property presence rather than
of_get_property(). This is part of a larger effort to remove callers
of of_get_property() and similar functions. of_get_property() leaks
the DT property data pointer which is a problem for dynamically
allocated nodes which may be freed.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Link: https://lore.kernel.org/r/20240731191312.1710417-13-robh@kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1619) Improve chip detection code
Guenter Roeck [Fri, 26 Jul 2024 22:29:40 +0000 (15:29 -0700)]
hwmon: (max1619) Improve chip detection code

Bail out immediately if reading any of the registers used for chip
detection fails, or if it returns an unexpected value. Drop all log
messages from detection code.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1619) Add support for update_interval attribute
Guenter Roeck [Tue, 16 Jul 2024 16:01:27 +0000 (09:01 -0700)]
hwmon: (max1619) Add support for update_interval attribute

The chip supports reading and writing the conversion rate.
Add support for the update_interval sysfs attribute.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1619) Convert to with_info API
Guenter Roeck [Tue, 16 Jul 2024 15:24:28 +0000 (08:24 -0700)]
hwmon: (max1619) Convert to with_info API

Convert driver to with_info hwmon API to simplify the code and
with it its maintainability.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1619) Convert to use regmap
Guenter Roeck [Tue, 16 Jul 2024 05:26:22 +0000 (22:26 -0700)]
hwmon: (max1619) Convert to use regmap

Use regmap for local caching, to hide register read/write address
differences, and for multi-byte operations. With this change,
the driver specific lock is no longer necessary.

While at it, check errors seen when initializing the chip and bail out
if chip initialization fails.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1619) Mask valid alarm bits
Guenter Roeck [Sun, 28 Jul 2024 14:09:54 +0000 (07:09 -0700)]
hwmon: (max1619) Mask valid alarm bits

Bit 0, 5, and 6 in the status register are reserved and, if set, do not
indicate an alarm. Bit 7 is the 'busy' bit and also does not indicate
an alarm. Mask the non-alarm bits to avoid reporting them to userspace.

Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1619) Reorder include files to alphabetic order
Guenter Roeck [Tue, 16 Jul 2024 03:28:58 +0000 (20:28 -0700)]
hwmon: (max1619) Reorder include files to alphabetic order

Simplify maintenance by reordering include files to alphabetic order.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1619) Clamp temperature range when writing limits
Guenter Roeck [Tue, 16 Jul 2024 05:36:35 +0000 (22:36 -0700)]
hwmon: (max1619) Clamp temperature range when writing limits

Module test code reports underflows when writing sensor limits.

temp2_min: Suspected underflow: [min=-77000, read 101000, written -2147483648]
temp2_max: Suspected underflow: [min=-77000, read 101000, written -2147483648]
temp2_crit: Suspected underflow: [min=-77000, read 101000, written -2147483648]

Clamp temperature ranges when writing limits to fix the problem.
While at it, use sign_extend32() when reading temperatures to make
the code easier to understand.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max6697) Document discrepancy in overtemperature status bit values
Guenter Roeck [Sat, 27 Jul 2024 19:06:04 +0000 (12:06 -0700)]
hwmon: (max6697) Document discrepancy in overtemperature status bit values

In the MAX6581 datasheet Revision 0 to 3, the local channel overtemperature
status is reported in bit 6 of register 0x45, and the overtemperature
status for remote channel 7 is reported in bit 7. In Revision 4 and later,
the local channel overtemperature status is reported in bit 7, and the
remote channel 7 overtemperature status is reported in bit 6. A real
chip was found to match the functionality documented in Revision 4 and
later.

The code was fixed with commit 1ea3fd1eb986 ("hwmon: (max6697) Fix swapped
temp{1,8} critical alarms"). At that time it looked like this was an
original bug. It only turned out later that the problem was the result of
incorrect information in the chip datasheet.

Document the discrepancy to avoid confusion caused by old versions of the
datasheet.

Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1668) Convert to use with_info hwmon API
Guenter Roeck [Mon, 15 Jul 2024 14:48:24 +0000 (07:48 -0700)]
hwmon: (max1668) Convert to use with_info hwmon API

Convert to use with_info API to simplify the code and to reduce its size.

This patch reduces object file size by approximately 25%.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1668) Replace chip type with number of channels
Guenter Roeck [Mon, 15 Jul 2024 14:25:38 +0000 (07:25 -0700)]
hwmon: (max1668) Replace chip type with number of channels

The only difference between supported chips is the number of channels.
Drop enum chips and list the number of channels in struct i2c_device_id
directly.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1668) Convert to use regmap
Guenter Roeck [Mon, 15 Jul 2024 14:18:57 +0000 (07:18 -0700)]
hwmon: (max1668) Convert to use regmap

Use regmap for caching to simplify the code and to hide read/write
register address differences.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1668) Use BIT macro
Guenter Roeck [Mon, 15 Jul 2024 14:22:44 +0000 (07:22 -0700)]
hwmon: (max1668) Use BIT macro

Use bit macro to make the code easier to understand and reduce duplication.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max1668) Reorder include files to alphabetic order
Guenter Roeck [Mon, 15 Jul 2024 14:20:35 +0000 (07:20 -0700)]
hwmon: (max1668) Reorder include files to alphabetic order

Reorder include files to alphabetic order to simplify driver maintenance.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (oxp-sensors) Fix typo in driver documentation
Cryolitia PukNgae [Fri, 26 Jul 2024 01:21:14 +0000 (09:21 +0800)]
hwmon: (oxp-sensors) Fix typo in driver documentation

RMP -> RPM

Signed-off-by: Cryolitia PukNgae <Cryolitia@gmail.com>
Link: https://lore.kernel.org/r/20240726-typo-v1-1-3ca3f07f93e9@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (ltc2947) Move to firmware agnostic API
Nuno Sa [Fri, 26 Jul 2024 12:07:33 +0000 (14:07 +0200)]
hwmon: (ltc2947) Move to firmware agnostic API

Use the device property APIs so the driver does not depend on OF to
work.

While at it, properly include mod_devicetable for struct of_device_id
and fix some parameter alignment in the changed places.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240726-dev-hwmon-ltc6947-fw-agnostic-v1-1-f7d6cab7d438@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (adt7475) Add support for configuring initial PWM state
Chris Packham [Mon, 22 Jul 2024 22:17:37 +0000 (10:17 +1200)]
hwmon: (adt7475) Add support for configuring initial PWM state

By default the PWM duty cycle in hardware is 100%. On some systems this
can cause unwanted fan noise. Add the ability to specify the fan
connections and initial state of the PWMs via device properties.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20240722221737.3407958-4-chris.packham@alliedtelesis.co.nz
[groeck: Cleaned up formatting]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agodt-bindings: hwmon: adt7475: Deprecate adi,pwm-active-state
Chris Packham [Mon, 22 Jul 2024 22:17:36 +0000 (10:17 +1200)]
dt-bindings: hwmon: adt7475: Deprecate adi,pwm-active-state

Now that we have fan child nodes that can specify flags for the PWM
outputs we no longer need the adi,pwm-active-state property.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://lore.kernel.org/r/20240722221737.3407958-3-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agodt-bindings: hwmon: Add adt7475 fan/pwm properties
Chris Packham [Mon, 22 Jul 2024 22:17:35 +0000 (10:17 +1200)]
dt-bindings: hwmon: Add adt7475 fan/pwm properties

Add fan child nodes that allow describing the connections for the
ADT7475 to the fans it controls. This also allows setting some
initial values for the pwm duty cycle and frequency.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://lore.kernel.org/r/20240722221737.3407958-2-chris.packham@alliedtelesis.co.nz
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max6697) Add support for tempX_min and tempX_min_alarm
Guenter Roeck [Sat, 13 Jul 2024 21:20:34 +0000 (14:20 -0700)]
hwmon: (max6697) Add support for tempX_min and tempX_min_alarm

MAX6581 supports setting the minimum temperature as well as minimum
temperature alarms. Add support for it.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max6697) Convert to with_info hwmon API
Guenter Roeck [Sat, 13 Jul 2024 14:44:20 +0000 (07:44 -0700)]
hwmon: (max6697) Convert to with_info hwmon API

Convert to with_info hwmon API to simplify the code and reduce its size.

This patch reduces object file size by approximately 25%.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max6697) Convert to use regmap
Guenter Roeck [Fri, 12 Jul 2024 22:45:38 +0000 (15:45 -0700)]
hwmon: (max6697) Convert to use regmap

Use regmap for register caching, and use regmap API for bit operations
to simplify the code.

This patch reduces object file size by approximately 10%.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max6697) Use bit operations where possible
Guenter Roeck [Fri, 12 Jul 2024 21:46:19 +0000 (14:46 -0700)]
hwmon: (max6697) Use bit operations where possible

Use bit operations to improve code maintainability.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max6697) Drop platform data support
Guenter Roeck [Fri, 12 Jul 2024 20:57:13 +0000 (13:57 -0700)]
hwmon: (max6697) Drop platform data support

Platform data is not used anywhere in the upstram kernel.
Drop support for it to simplify code maintenance.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max6697) Reorder include files
Guenter Roeck [Fri, 12 Jul 2024 20:06:30 +0000 (13:06 -0700)]
hwmon: (max6697) Reorder include files

Reorder include files to alphabetic order to improve maintainability.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max16065) Fix alarm attributes
Guenter Roeck [Sun, 21 Jul 2024 13:41:17 +0000 (06:41 -0700)]
hwmon: (max16065) Fix alarm attributes

Chips reporting overcurrent alarms report it in the second alarm register.
That means the second alarm register has to be read, even if the chip only
supports 8 or fewer ADC channels.

MAX16067 and MAX16068 report undervoltage and overvoltage alarms in
separate registers. Fold register contents together to report both with
the existing alarm attribute. This requires actually storing the chip type
in struct max16065_data. Rename the variable 'chip' to match the variable
name used in the probe function.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Fixes: f5bae2642e3d ("hwmon: Driver for MAX16065 System Manager and compatibles")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max16065) Fix overflows seen when writing limits
Guenter Roeck [Thu, 18 Jul 2024 16:52:01 +0000 (09:52 -0700)]
hwmon: (max16065) Fix overflows seen when writing limits

Writing large limits resulted in overflows as reported by module tests.

in0_lcrit: Suspected overflow: [max=5538, read 0, written 2147483647]
in0_crit: Suspected overflow: [max=5538, read 0, written 2147483647]
in0_min: Suspected overflow: [max=5538, read 0, written 2147483647]

Fix the problem by clamping prior to multiplications and the use of
DIV_ROUND_CLOSEST, and by using consistent variable types.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Fixes: f5bae2642e3d ("hwmon: Driver for MAX16065 System Manager and compatibles")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (ltc2992) use device_for_each_child_node_scoped() to access child nodes
Javier Carrasco [Sun, 21 Jul 2024 15:19:02 +0000 (17:19 +0200)]
hwmon: (ltc2992) use device_for_each_child_node_scoped() to access child nodes

The iterated nodes are direct children of the device node, and the
`device_for_each_child_node()` macro accounts for child node
availability.

`fwnode_for_each_available_child_node()` is meant to access the child
nodes of an fwnode, and therefore not direct child nodes of the device
node.

In this case, the child nodes are not required outside the loop, and
the scoped version of the macro can be used to remove the repetitive
`goto put` pattern.

Use `device_for_each_child_node_scoped_scoped()` to indicate device's
direct child nodes.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240721-device_for_each_child_node-available-v2-2-f33748fd8b2d@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (dell-smm) Add Dell Latitude 7320 to fan control whitelist
Armin Wolf [Fri, 19 Jul 2024 20:37:06 +0000 (22:37 +0200)]
hwmon: (dell-smm) Add Dell Latitude 7320 to fan control whitelist

Add the Dell Latitude 7320 to the fan control whitelist to allow
for manual fan control.

Closes: https://github.com/Wer-Wolf/i8kutils/issues/8
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20240719203706.19466-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (lm95234) Use multi-byte regmap operations
Guenter Roeck [Thu, 11 Jul 2024 00:37:54 +0000 (17:37 -0700)]
hwmon: (lm95234) Use multi-byte regmap operations

Use  multi-byte regmap operations to simplify the code
and to reduce dependency on locking.

No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (lm95234) Add support for tempX_enable attribute
Guenter Roeck [Wed, 10 Jul 2024 22:57:18 +0000 (15:57 -0700)]
hwmon: (lm95234) Add support for tempX_enable attribute

LM95233/LM95234 support enabling temperature channels one by one.
Add support for tempX_enable attribute to be able to use that
functionality.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (lm95234) Convert to with_info hwmon API
Guenter Roeck [Wed, 10 Jul 2024 14:11:12 +0000 (07:11 -0700)]
hwmon: (lm95234) Convert to with_info hwmon API

Convert to with_info API to simplify the code and reduce its size.

This patch reduces the object file size by about 30%.

No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (lm95234) Convert to use regmap
Guenter Roeck [Sun, 7 Jul 2024 23:43:04 +0000 (16:43 -0700)]
hwmon: (lm95234) Convert to use regmap

Use regmap to replace local caching and to be able to use regmap API
functions.

No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (lm95234) Use find_closest to find matching update interval
Guenter Roeck [Wed, 10 Jul 2024 04:23:30 +0000 (21:23 -0700)]
hwmon: (lm95234) Use find_closest to find matching update interval

Use find_closest() instead of manually coding it to find best update
interval.

Since find_closest() uses rounding to find the best match, the resulting
update interval will now reflect the update interval that is closest to
the requested value, not the value that is lower or equal to the requested
value.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (lm95234) Reorder include files to be in alphabetic order
Guenter Roeck [Sun, 7 Jul 2024 14:49:51 +0000 (07:49 -0700)]
hwmon: (lm95234) Reorder include files to be in alphabetic order

Alphabetic include file order simplifies maintenance and makes it easier
to add or remove files.

No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (amc6821) Use multi-byte regmap operations
Guenter Roeck [Tue, 16 Jul 2024 19:01:21 +0000 (12:01 -0700)]
hwmon: (amc6821) Use multi-byte regmap operations

Use multi-byte regmap operations where possible to reduce code size.

No functional changes.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (max6639) Use multi-byte regmap operations
Guenter Roeck [Tue, 16 Jul 2024 19:14:12 +0000 (12:14 -0700)]
hwmon: (max6639) Use multi-byte regmap operations

Use multi-byte regmap operations where possible to reduce code size
and the need for mutex protection.

No functional changes.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (tmp464) Use multi-byte regmap operations
Guenter Roeck [Tue, 9 Jul 2024 21:07:19 +0000 (14:07 -0700)]
hwmon: (tmp464) Use multi-byte regmap operations

Use multi-byte regmap operations where possible to reduce code size
and the need for mutex protection.

No functional changes.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (adt7x10) Use multi-byte regmap operations
Guenter Roeck [Tue, 9 Jul 2024 21:06:17 +0000 (14:06 -0700)]
hwmon: (adt7x10) Use multi-byte regmap operations

Use multi-byte regmap operations where possible to reduce code size
and the need for mutex protection.

No functional changes.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (nct7802) Use multi-byte regmap operations
Guenter Roeck [Tue, 9 Jul 2024 21:03:06 +0000 (14:03 -0700)]
hwmon: (nct7802) Use multi-byte regmap operations

Use multi-byte regmap operations where possible to reduce code size
and the need for mutex protection.

No functional changes.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (lm95245) Use multi-byte regmap operations
Guenter Roeck [Tue, 9 Jul 2024 14:21:19 +0000 (07:21 -0700)]
hwmon: (lm95245) Use multi-byte regmap operations

Use multi-byte regmap operations where possible to reduce code size
and the need for mutex protection.

No functional change.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (tmp401) Use multi-byte regmap operations
Guenter Roeck [Tue, 9 Jul 2024 20:53:37 +0000 (13:53 -0700)]
hwmon: (tmp401) Use multi-byte regmap operations

Use multi-byte regmap operations where possible to reduce code size
and the need for mutex protection.

No functional change.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agohwmon: (adt7470) Use multi-byte regmap operations
Guenter Roeck [Tue, 9 Jul 2024 14:16:43 +0000 (07:16 -0700)]
hwmon: (adt7470) Use multi-byte regmap operations

Use multi-byte regmap operations where possible to reduce code size
and the need for mutex protection.

No functional change.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8 months agoLinux 6.11-rc1
Linus Torvalds [Sun, 28 Jul 2024 21:19:55 +0000 (14:19 -0700)]
Linux 6.11-rc1

8 months agoMerge tag 'kbuild-fixes-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masah...
Linus Torvalds [Sun, 28 Jul 2024 21:02:48 +0000 (14:02 -0700)]
Merge tag 'kbuild-fixes-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Fix RPM package build error caused by an incorrect locale setup

 - Mark modules.weakdep as ghost in RPM package

 - Fix the odd combination of -S and -c in stack protector scripts,
   which is an error with the latest Clang

* tag 'kbuild-fixes-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: Fix '-S -c' in x86 stack protector scripts
  kbuild: rpm-pkg: ghost modules.weakdep file
  kbuild: rpm-pkg: Fix C locale setup

8 months agominmax: simplify and clarify min_t()/max_t() implementation
Linus Torvalds [Sun, 28 Jul 2024 20:50:01 +0000 (13:50 -0700)]
minmax: simplify and clarify min_t()/max_t() implementation

This simplifies the min_t() and max_t() macros by no longer making them
work in the context of a C constant expression.

That means that you can no longer use them for static initializers or
for array sizes in type definitions, but there were only a couple of
such uses, and all of them were converted (famous last words) to use
MIN_T/MAX_T instead.

Cc: David Laight <David.Laight@aculab.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8 months agominmax: add a few more MIN_T/MAX_T users
Linus Torvalds [Sun, 28 Jul 2024 20:03:48 +0000 (13:03 -0700)]
minmax: add a few more MIN_T/MAX_T users

Commit 3a7e02c040b1 ("minmax: avoid overly complicated constant
expressions in VM code") added the simpler MIN_T/MAX_T macros in order
to avoid some excessive expansion from the rather complicated regular
min/max macros.

The complexity of those macros stems from two issues:

 (a) trying to use them in situations that require a C constant
     expression (in static initializers and for array sizes)

 (b) the type sanity checking

and MIN_T/MAX_T avoids both of these issues.

Now, in the whole (long) discussion about all this, it was pointed out
that the whole type sanity checking is entirely unnecessary for
min_t/max_t which get a fixed type that the comparison is done in.

But that still leaves min_t/max_t unnecessarily complicated due to
worries about the C constant expression case.

However, it turns out that there really aren't very many cases that use
min_t/max_t for this, and we can just force-convert those.

This does exactly that.

Which in turn will then allow for much simpler implementations of
min_t()/max_t().  All the usual "macros in all upper case will evaluate
the arguments multiple times" rules apply.

We should do all the same things for the regular min/max() vs MIN/MAX()
cases, but that has the added complexity of various drivers defining
their own local versions of MIN/MAX, so that needs another level of
fixes first.

Link: https://lore.kernel.org/all/b47fad1d0cf8449886ad148f8c013dae@AcuMS.aculab.com/
Cc: David Laight <David.Laight@aculab.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>