Skip to content

hwmon Subsystem

The hwmon subsystem is used for hardware monitoring devices, such as temperature sensors, voltage monitors, fan controllers, and current sensors. It exposes standard attributes under /sys/class/hwmon so user space can read monitoring values without a custom ABI.

What Problem It Solves

A basic sensor driver can expose custom sysfs attributes, but user space then needs device-specific knowledge. hwmon provides standard attribute names such as temp1_input, making the driver easier to integrate with existing monitoring tools.

Core Concepts

Concept Description
hwmon device Registered monitoring device under /sys/class/hwmon.
Channel info Describes supported sensor channels and attributes.
read() callback Provides values in standard hwmon units.
Standard units Temperature in millidegrees Celsius, voltage in millivolts, etc.

Typical Driver Flow

probe()
initialize chip state
prepare hwmon channel info
devm_hwmon_device_register_with_info()
/sys/class/hwmon/hwmonX/

Design Notes

  • Use hwmon when the data is a monitoring value rather than a high-rate sampled stream.
  • Use standard units expected by hwmon attributes.
  • Use caching when hardware reads are slow or expensive.
  • Prefer standard hwmon attributes over custom sysfs names when possible.

hwmon vs IIO

Use hwmon when... Use IIO when...
Values are slow monitoring data. Data is sampled, buffered, or streamed.
User space reads sysfs attributes. User space uses scan elements or /dev/iio:deviceX.
Data maps to standard monitoring channels. Device has ADC/sensor-style channels and triggers.