Documentation/hwmon/hwmon-kernel-api.rst

Source file repositories/reference/linux-study-clean/Documentation/hwmon/hwmon-kernel-api.rst

File Facts

System
Linux kernel
Corpus path
Documentation/hwmon/hwmon-kernel-api.rst
Extension
.rst
Size
13645 bytes
Lines
383
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct hwmon_chip_info {
		const struct hwmon_ops *ops;
		const struct hwmon_channel_info * const *info;
	};

It contains the following fields:

* ops:
	Pointer to device operations.
* info:
	NULL-terminated list of device channel descriptors.

The list of hwmon operations is defined as::

  struct hwmon_ops {
	umode_t (*is_visible)(const void *, enum hwmon_sensor_types type,
			      u32 attr, int);
	int (*read)(struct device *, enum hwmon_sensor_types type,
		    u32 attr, int, long *);
	int (*write)(struct device *, enum hwmon_sensor_types type,
		     u32 attr, int, long);
  };

It defines the following operations.

* is_visible:
    Pointer to a function to return the file mode for each supported
    attribute. This function is mandatory.

* read:
    Pointer to a function for reading a value from the chip. This function
    is optional, but must be provided if any readable attributes exist.

* write:
    Pointer to a function for writing a value to the chip. This function is
    optional, but must be provided if any writeable attributes exist.

Each sensor channel is described with struct hwmon_channel_info, which is
defined as follows::

	struct hwmon_channel_info {
		enum hwmon_sensor_types type;
		u32 *config;
	};

It contains following fields:

* type:
    The hardware monitoring sensor type.

    Supported sensor types are

     ================== ==================================================
     hwmon_chip		A virtual sensor type, used to describe attributes
			which are not bound to a specific input or output
     hwmon_temp		Temperature sensor
     hwmon_in		Voltage sensor
     hwmon_curr		Current sensor
     hwmon_power		Power sensor
     hwmon_energy	Energy sensor
     hwmon_energy64	Energy sensor, reported as 64-bit signed value
     hwmon_humidity	Humidity sensor
     hwmon_fan		Fan speed sensor
     hwmon_pwm		PWM control
     ================== ==================================================

* config:
    Pointer to a 0-terminated list of configuration values for each
    sensor of the given type. Each value is a combination of bit values
    describing the attributes supposed by a single sensor.

Annotation

Implementation Notes