Skip to content

hwmon: Introduce uhwmon for userspace implementations

Jihong Min linux-api linux-doc linux-hwmon lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5hwmon: Export sensor and attribute definitions to userspaceMAINTAINERS include/linux/hwmon.h include/uapi/linux/hwmon.h+374 -3521 reply
2/5hwmon: Expose attribute validation and string helpersdrivers/hwmon/hwmon.c include/linux/hwmon.h+28 -50 replies
3/5hwmon: Add a generic interface for userspace implementationsDocumentation/userspace-api/ioctl/ioctl-number.rst MAINTAINERS drivers/hwmon/Kconfig +3 more+717 -01 reply
4/5hwmon: Reject truncated attribute namesdrivers/hwmon/hwmon.c+6 -20 replies
5/5docs: hwmon: Document the uhwmon userspace interfaceDocumentation/hwmon/index.rst Documentation/hwmon/uhwmon.rst+142 -03 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] hwmon: Introduce uhwmon for userspace implementations

This series introduces uhwmon, a generic hwmon interface connecting userspace implementations to the kernel. It exposes hwmon sensor and attribute definitions to userspace through <linux/hwmon.h>, allowing userspace drivers to create standard hwmon sysfs attributes. uhwmon forwards reads and writes through /dev/uhwmon. The hwmon core handles numeric text conversion and newlines for kernel and userspace drivers. The series also adds kernel documentation explaining the interface and how to use its UAPI.

In the October 2024 IT87 discussion [1], a read-only hwmon driver configured from userspace was suggested for chips without datasheets and for testing new chips. Guenter Roeck said he would need proposal details, but questioned whether the hwmon sysfs ABI justified new kernel
infrastructure: userspace drivers would still need hardware knowledge and access. He suggested an API between those drivers and libsensors as an alternative.

But I see practical value in retaining hwmon: the use case below already works with unmodified sensors through its existing hwmon interface. A common bridge can similarly let other daemons expose measurements without adding a new input path to existing hwmon applications, reducing duplicated integration work. The idea is conceptually similar to dummy_hcd with a userspace gadget interface.

uhwmon's goal is to let applications using the standard hwmon interface access sensors without mainline drivers, without adding per-device support to userspace libraries or building and loading separate DKMS modules. In theory, projects such as wireview-hwmon [2] could replace their device-specific DKMS module with uhwmon and adapt their daemon to use it. My current use case is bridging the Tapo API [3] to hwmon, using a TAPO P110M smart plug to measure my system's power draw at the wall in place of an ACPI power meter. I have tested this setup in an Ubuntu VM, including live readings, daemon disconnect and recovery, and reboot startup.

[1] https://lkml.iu.edu/2410.2/11841.html
[2] https://github.com/emaspa/wireview-hwmon
[3] https://github.com/mihai-dinculescu/tapo

Jihong Min (5):
hwmon: Export sensor and attribute definitions to userspace
hwmon: Expose attribute validation and string helpers
hwmon: Add a generic interface for userspace implementations
hwmon: Reject truncated attribute names
docs: hwmon: Document the uhwmon userspace interface

 Documentation/hwmon/index.rst                      |   1 +
 Documentation/hwmon/uhwmon.rst                     | 141 +++++
 Documentation/userspace-api/ioctl/ioctl-number.rst |   1 +
 MAINTAINERS                                        |   2 +
 drivers/hwmon/Kconfig                              |   9 +
 drivers/hwmon/Makefile                             |   1 +
 drivers/hwmon/hwmon.c                              |  38 +-
 drivers/hwmon/uhwmon.c                             | 641 +++++++++++++++++++++
 include/linux/hwmon.h                              | 356 +-----------
 include/uapi/linux/hwmon.h                         | 372 ++++++++++++
 include/uapi/linux/uhwmon.h                        |  64 ++
 11 files changed, 1267 insertions(+), 359 deletions(-)
 create mode 100644 Documentation/hwmon/uhwmon.rst
 create mode 100644 drivers/hwmon/uhwmon.c
 create mode 100644 include/uapi/linux/hwmon.h
 create mode 100644 include/uapi/linux/uhwmon.h

base-commit: 7b63ef2d55f24519e7e9e5f4d15dbea03f126e40

Sincerely,
Jihong Min