History log of /linux-master/include/linux/hwmon.h
Revision Date Author Comments
# 5f85c4d1 30-Jan-2024 Javier Carrasco <javier.carrasco.cruz@gmail.com>

hwmon: (core) Add support for humidity min/max alarm

Add min_alarm and max_alarm attributes for humidityX to support devices
that can generate these alarms.
Such attributes already exist for other magnitudes such as tempX.

Tested with a ChipCap 2 temperature-humidity sensor.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240130-topic-chipcap2-v6-2-260bea05cf9b@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 35c1bfb9 29-Jan-2024 Nuno Sa <nuno.sa@analog.com>

hwmon: add fault attribute for voltage channels

Sometimes a voltage channel might have an hard failure (eg: a shorted
MOSFET). Hence, add a fault attribute to report such failures.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240129-b4-ltc4282-support-v4-2-fe75798164cc@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b9f55084 17-Jan-2024 Jani Nikula <jani.nikula@intel.com>

hwmon: put HWMON_CHANNEL_INFO() initializers in rodata

HWMON_CHANNEL_INFO() is supposed to be used as initializer for arrays of
const struct hwmon_channel_info *. However, without explicit const,
HWMON_CHANNEL_INFO() creates mutable compound literals, and the const
pointers point at the mutable data. Add const to place the data in
rodata.

Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://lore.kernel.org/r/20240117114405.1506775-1-jani.nikula@intel.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# fe6ac237 07-May-2023 James Seo <james@equiv.tech>

hwmon: (core) Add missing beep-related standard attributes

beep_enable, inX_beep, currX_beep, fanX_beep, and tempX_beep
are standard attributes mentioned in the sysfs interface
specification but not implemented in the hwmon core. Since
these are not deprecated, implement them.

Adding beep_mask is not necessary, as it is deprecated and
the drivers already using it are manually defining it.

Signed-off-by: James Seo <james@equiv.tech>
Link: https://lore.kernel.org/r/20230507152216.1862653-1-james@equiv.tech
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# d8cc9415 06-Apr-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

hwmon: constify pointers to hwmon_channel_info

HWmon core receives an array of pointers to hwmon_channel_info and it
does not modify it, thus it can be array of const pointers for safety.
This allows drivers to make them also const.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 5720a18b 16-Feb-2023 Guenter Roeck <linux@roeck-us.net>

hwmon: Deprecate [devm_]hwmon_device_register_with_groups

Even though the hardware monitoring documentation already stated that new
drivers should use [devm_]devm_hwmon_device_register_with_info() to
register with the hardware monitoring subsystem, we still get submissions
for new drivers using the older APIs. There is no benefit to use those
APIs. On the contrary, using the older APIs results in substantially larger
code size. Explicitly deprecate [devm_]hwmon_device_register_with_groups()
to ensure that all new drivers use the latest API.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# e5d21072 11-May-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: Introduce hwmon_device_register_for_thermal

The thermal subsystem registers a hwmon driver without providing
chip or sysfs group information. This is for legacy reasons and
would be difficult to change. At the same time, we want to enforce
that chip information is provided when registering a hwmon device
using hwmon_device_register_with_info(). To enable this, introduce
a special API for use only by the thermal subsystem.

Acked-by: Rafael J . Wysocki <rafael@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 1ad6c3b7 05-Apr-2022 Michael Walle <michael@walle.cc>

hwmon: introduce hwmon_sanitize_name()

More and more drivers will check for bad characters in the hwmon name
and all are using the same code snippet. Consolidate that code by adding
a new hwmon_sanitize_name() function.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20220405092452.4033674-2-michael@walle.cc
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# e75d16e5 23-Feb-2022 Armin Wolf <W_Armin@gmx.de>

hwmon: (core) Add support for pwm auto channels attribute

pwm[1-*]_auto_channels_temp is documented as an official
hwmon sysfs attribute, yet there is no support for it in
the new with_info-API. Fix that.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20220224061210.16452-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 130d1688 16-Dec-2021 Lukas Bulwahn <lukas.bulwahn@gmail.com>

hwmon: prefix kernel-doc comments for structs with struct

The command ./scripts/kernel-doc -none include/linux/hwmon.h warns:

include/linux/hwmon.h:406: warning: This comment starts with '/**', but
isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* Channel information
include/linux/hwmon.h:425: warning: This comment starts with '/**', but
isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
* Chip configuration

Address those kernel-doc warnings by prefixing kernel-doc descriptions for
structs with the keyword 'struct'.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Link: https://lore.kernel.org/r/20211216154257.26758-1-lukas.bulwahn@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 1967f712 31-Jul-2020 Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>

hwmon: (core) Add support for rated attributes

Adding implementation for new attributes (rated_min/rated_max) for
currentX, inX, powerX, tempX and humidityX.

Tested with OpenBMC stack and simple hwmon driver using
rated_min/rated_max for the following types of sensors: hwmon_temp,
hwmon_in, hwmon_curr, hwmon_power, hwmon_humidity.
For each sensor rated attributes were available and returned
expected values.

Signed-off-by: Zbigniew Lukwinski <zbigniew.lukwinski@linux.intel.com>
Link: https://lore.kernel.org/r/1596224237-32280-3-git-send-email-zbigniew.lukwinski@linux.intel.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 1597b374 28-May-2020 Guenter Roeck <linux@roeck-us.net>

hwmon: Add notification support

For hwmon drivers using the hwmon_device_register_with_info() API, it
is desirable to have a generic notification mechanism available. This
mechanism can be used to notify userspace as well as the thermal
subsystem if the driver experiences any events, such as warning or
critical alarms.

Implement hwmon_notify_event() to provide this mechanism. The function
generates a sysfs event and a udev event. If the device is registered
with the thermal subsystem and the event is associated with a temperature
sensor, also notify the thermal subsystem that a thermal event occurred.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Maxim Kaurkin <Maxim.Kaurkin@baikalelectronics.ru>
Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: linux-mips@vger.kernel.org
Cc: devicetree@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 002c6b54 17-Jul-2018 Guenter Roeck <linux@roeck-us.net>

hwmon: Add support for enable attributes to hwmon core

The hwmon ABI supports enable attributes since commit fb41a710f84e
("hwmon: Document the sensor enable attribute"), but did not
add support for those attributes to the hwmon core. Do that now.

Since the enable attributes are logically the most important attributes,
they are added as first attribute to the attribute list. Move
hwmon_in_enable from last to first place for consistency.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 4413405f 24-Nov-2019 Dr. David Alan Gilbert <linux@treblig.org>

hwmon: Add intrusion templates

Add templates for intrusion%d_alarm and intrusion%d_beep.
Note, these start at 0.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Link: https://lore.kernel.org/r/20191124202030.45360-2-linux@treblig.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 30945d31 24-Sep-2019 Nuno Sá <nuno.sa@analog.com>

hwmon: Fix HWMON_P_MIN_ALARM mask

Both HWMON_P_MIN_ALARM and HWMON_P_MAX_ALARM were using
BIT(hwmon_power_max_alarm).

Fixes: aa7f29b07c870 ("hwmon: Add support for power min, lcrit, min_alarm and lcrit_alarm")
CC: <stable@vger.kernel.org>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20190924124945.491326-2-nuno.sa@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b886d83c 01-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation version 2 of the license

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 315 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Armijn Hemel <armijn@tjaldur.nl>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190531190115.503150771@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9f00995e 15-Apr-2019 Guenter Roeck <linux@roeck-us.net>

hwmon: Add support for samples attributes

Add support for the new samples attributes to the hwmon core.

Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Cc: Nicolin Chen <nicoleotsuka@gmail.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# c43a113c 20-Mar-2019 Charles Keepax <ckeepax@opensource.cirrus.com>

hwmon: Add convience macro to define simple static sensors

It takes a fair amount of boiler plate code to add new sensors, add a
macro that can be used to specify simple static sensors.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 68c0d69d 05-Oct-2018 Nicolin Chen <nicoleotsuka@gmail.com>

hwmon: (core) Add hwmon_in_enable attribute

According to hwmon ABI, in%d_enable is a sysfs interface that
allows user space to enable and disable the input sensor. So
this patch just simply adds the attribute to the list.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# dcb5d0fc 17-Jul-2018 Andrew Lunn <andrew@lunn.ch>

hwmon: Add helper to tell if a char is invalid in a name

HWMON device names are not allowed to contain "-* \t\n". Add a helper
which will return true if passed an invalid character. It can be used
to massage a string into a hwmon compatible name by replacing invalid
characters with '_'.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>


# aa7f29b0 17-Jul-2018 Andrew Lunn <andrew@lunn.ch>

hwmon: Add support for power min, lcrit, min_alarm and lcrit_alarm

Some sensors support reporting minimal and lower critical power, as
well as alarms when these thresholds are reached. Add support for
these attributes to the hwmon core.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>


# 2fe31e43 17-Jul-2018 Andrew Lunn <andrew@lunn.ch>

hwmon: Add missing HWMON_T_LCRIT_ALARM define

The enum hwmon_temp_lcrit_alarm exists, but the BIT definition is
missing.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: David S. Miller <davem@davemloft.net>


# d5753800 27-Sep-2017 Sudeep Holla <sudeep.holla@arm.com>

hwmon: (core) Add hwmon_max to hwmon_sensor_types enumeration

It's useful to know the maximum types of sensor supported by hwmon
framework. It can be used to allocate some data structures when sorting
the monitors based on their type.

This will be used by scmi hwmon support.

Cc: linux-hwmon@vger.kernel.org
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>


# 5ba6bcbc 07-Mar-2017 Jean Delvare <jdelvare@suse.de>

hwmon: Constify str parameter of hwmon_ops->read_string

The read_string callback is supposed to retrieve a pointer to a
constant string.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# a5023a99 16-Mar-2017 Peter Huewe <PeterHuewe@gmx.de>

hwmon: Add missing HWMON_T_ALARM

Unfortunately the HWMON_T_ALARM define was missing,
although the associated entry was present in hwmon_temp_attributes.
This is needed to convert drivers to the new interface which use channel
based alarms.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 848ba0a2 16-Oct-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Rename groups parameter in API to extra_groups

The 'groups' parameter of hwmon_device_register_with_info() and
devm_hwmon_device_register_with_info() is only necessary if extra
non-standard attributes need to be provided. Rename the parameter
to extra_groups and clarify the documentation.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# af1bd36c 16-Oct-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Deprecate hwmon_device_register()

Inform the user that hwmon_device_register() is deprecated,
and suggest conversion to the newest API. Also remove
hwmon_device_register() from the kernel API documentation.

Note that hwmon_device_register() is not marked as __deprecated()
since doing so might result in build errors.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# e159ab5c 07-Aug-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Add support for string attributes to new API

The new API is so far only suited for data attributes and does not work
well for string attributes, specifically for the 'label' attributes.
Provide a separate callback function for those.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f680b284 20-Nov-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Clarify when read and write callbacks are mandatory

The callback descrption in hwmon.h was misleading and stated that read and
write callbacks would be optional. More accurate is is that the callbacks
are mandatory if readable / writeable attributes are present.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f9f7bb3a 26-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Add basic pwm attribute support to new API

Add basic pwm attribute support (no auto attributes) to new API.

Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 8faee73f 25-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Add fan attribute support to new API

Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 6bfcca44 20-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Add energy and humidity attribute support to new API

Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b308f5c7 20-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Add power attribute support to new API

Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 9b26947c 20-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Add current attribute support to new API

Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 00d616cf 20-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) Add voltage attribute support to new API

Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# d560168b 26-Aug-2015 Guenter Roeck <linux@roeck-us.net>

hwmon: (core) New hwmon registration API

Up to now, each hwmon driver has to implement its own sysfs attributes.
This requires a lot of template code, and distracts from the driver's core
function to read and write chip registers.

To be able to reduce driver complexity, move sensor attribute handling
and thermal zone registration into hwmon core. By using the new API,
driver code and data size is typically reduced by 20-70%, depending
on driver complexity and the number of sysfs attributes supported.

With this patch, the new API only supports thermal sensors. Support for
other sensor types will be added with subsequent patches.

Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 74188cba 11-Jul-2013 Guenter Roeck <linux@roeck-us.net>

hwmon: Provide managed hwmon registration

Drivers using the new hwmon_device_register_with_groups API often have a
remove function which consists solely of a call hwmon_device_unregister().

Provide support for devm_hwmon_device_register_with_groups and
devm_hwmon_device_unregister to allow this repeated code to be removed
and help eliminate error handling code.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# bab2243c 06-Jul-2013 Guenter Roeck <linux@roeck-us.net>

hwmon: Introduce hwmon_device_register_with_groups

hwmon_device_register_with_groups() lets callers register a hwmon device
together with all sysfs attributes in a single call.

When using hwmon_device_register_with_groups(), hwmon attributes are attached
to the hwmon device directly and no longer with its parent device.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# c25fb816 09-Jan-2013 Guenter Roeck <linux@roeck-us.net>

hwmon: Retire SENSORS_LIMIT

SENSORS_LIMIT and clamp_val have the same functionality, so retire SENSORS_LIMIT
as it is no longer needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>


# 313162d0 30-Jan-2012 Paul Gortmaker <paul.gortmaker@windriver.com>

device.h: audit and cleanup users in main include dir

The <linux/device.h> header includes a lot of stuff, and
it in turn gets a lot of use just for the basic "struct device"
which appears so often.

Clean up the users as follows:

1) For those headers only needing "struct device" as a pointer
in fcn args, replace the include with exactly that.

2) For headers not really using anything from device.h, simply
delete the include altogether.

3) For headers relying on getting device.h implicitly before
being included themselves, now explicitly include device.h

4) For files in which doing #1 or #2 uncovers an implicit
dependency on some other header, fix by explicitly adding
the required header(s).

Any C files that were implicitly relying on device.h to be
present have already been dealt with in advance.

Total removals from #1 and #2: 51. Total additions coming
from #3: 9. Total other implicit dependencies from #4: 7.

As of 3.3-rc1, there were 110, so a net removal of 42 gives
about a 38% reduction in device.h presence in include/*

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>


# 1beeffe4 20-Aug-2007 Tony Jones <tonyj@suse.de>

hwmon: Convert from class_device to device

Convert from class_device to device for hwmon_device_register/unregister

Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>


# 53ae11b0 28-Jul-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] hwmon: move SENSORS_LIMIT to hwmon.h

Move SENSORS_LIMIT from i2c-sensor.h to hwmon.h, as it is in no way
related to i2c.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 1236441f 15-Jul-2005 Mark M. Hoffman <mhoffman@lightlink.com>

[PATCH] I2C hwmon: hwmon sysfs class

This patch adds the sysfs class "hwmon" for use by hardware monitoring
(sensors) chip drivers. It also fixes up the related Kconfig/Makefile
bits.

Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>