Dsphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget*/translations/zh_CN/hwmon/hwmon-kernel-apimodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/zh_TW/hwmon/hwmon-kernel-apimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/it_IT/hwmon/hwmon-kernel-apimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/ja_JP/hwmon/hwmon-kernel-apimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/ko_KR/hwmon/hwmon-kernel-apimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget*/translations/sp_SP/hwmon/hwmon-kernel-apimodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h(The Linux Hardware Monitoring kernel APIh]h(The Linux Hardware Monitoring kernel API}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhD/var/lib/git/docbuild/linux/Documentation/hwmon/hwmon-kernel-api.rsthKubh paragraph)}(h Guenter Roeckh]h Guenter Roeck}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(h Introductionh]h Introduction}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hThis document describes the API that can be used by hardware monitoring drivers that want to use the hardware monitoring framework.h]hThis document describes the API that can be used by hardware monitoring drivers that want to use the hardware monitoring framework.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hX2This document does not describe what a hardware monitoring (hwmon) Driver or Device is. It also does not describe the API which can be used by user space to communicate with a hardware monitoring device. If you want to know this then please read the following file: Documentation/hwmon/sysfs-interface.rst.h]hX2This document does not describe what a hardware monitoring (hwmon) Driver or Device is. It also does not describe the API which can be used by user space to communicate with a hardware monitoring device. If you want to know this then please read the following file: Documentation/hwmon/sysfs-interface.rst.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hFor additional guidelines on how to write and improve hwmon drivers, please also read Documentation/hwmon/submitting-patches.rst.h]hFor additional guidelines on how to write and improve hwmon drivers, please also read Documentation/hwmon/submitting-patches.rst.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h] introductionah ]h"] introductionah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hThe APIh]hThe API}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhKubh)}(hEach hardware monitoring driver must #include and, in some cases, . linux/hwmon.h declares the following register/unregister functions::h]hEach hardware monitoring driver must #include and, in some cases, . linux/hwmon.h declares the following register/unregister functions:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh literal_block)}(hX\struct device * hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata, const struct hwmon_chip_info *info, const struct attribute_group **extra_groups); struct device * devm_hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata, const struct hwmon_chip_info *info, const struct attribute_group **extra_groups); void hwmon_device_unregister(struct device *dev); char *hwmon_sanitize_name(const char *name); char *devm_hwmon_sanitize_name(struct device *dev, const char *name); void hwmon_lock(struct device *dev); void hwmon_unlock(struct device *dev);h]hX\struct device * hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata, const struct hwmon_chip_info *info, const struct attribute_group **extra_groups); struct device * devm_hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata, const struct hwmon_chip_info *info, const struct attribute_group **extra_groups); void hwmon_device_unregister(struct device *dev); char *hwmon_sanitize_name(const char *name); char *devm_hwmon_sanitize_name(struct device *dev, const char *name); void hwmon_lock(struct device *dev); void hwmon_unlock(struct device *dev);}hj+sbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1j)hhhKhj hhubh)}(hXhwmon_device_register_with_info registers a hardware monitoring device. It creates the standard sysfs attributes in the hardware monitoring core, letting the driver focus on reading from and writing to the chip instead of having to bother with sysfs attributes. The parent device parameter as well as the chip parameter must not be NULL. Its parameters are described in more detail below.h]hXhwmon_device_register_with_info registers a hardware monitoring device. It creates the standard sysfs attributes in the hardware monitoring core, letting the driver focus on reading from and writing to the chip instead of having to bother with sysfs attributes. The parent device parameter as well as the chip parameter must not be NULL. Its parameters are described in more detail below.}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK0hj hhubh)}(hdevm_hwmon_device_register_with_info is similar to hwmon_device_register_with_info. However, it is device managed, meaning the hwmon device does not have to be removed explicitly by the removal function.h]hdevm_hwmon_device_register_with_info is similar to hwmon_device_register_with_info. However, it is device managed, meaning the hwmon device does not have to be removed explicitly by the removal function.}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK7hj hhubh)}(hoAll other hardware monitoring device registration functions are deprecated and must not be used in new drivers.h]hoAll other hardware monitoring device registration functions are deprecated and must not be used in new drivers.}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK;hj hhubh)}(hXFhwmon_device_unregister deregisters a registered hardware monitoring device. The parameter of this function is the pointer to the registered hardware monitoring device structure. This function must be called from the driver remove function if the hardware monitoring device was registered with hwmon_device_register_with_info.h]hXFhwmon_device_unregister deregisters a registered hardware monitoring device. The parameter of this function is the pointer to the registered hardware monitoring device structure. This function must be called from the driver remove function if the hardware monitoring device was registered with hwmon_device_register_with_info.}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK>hj hhubh)}(hXAll supported hwmon device registration functions only accept valid device names. Device names including invalid characters (whitespace, '*', or '-') will be rejected. If NULL is passed as name parameter, the hardware monitoring device name will be derived from the parent device name.h]hX%All supported hwmon device registration functions only accept valid device names. Device names including invalid characters (whitespace, ‘*’, or ‘-‘) will be rejected. If NULL is passed as name parameter, the hardware monitoring device name will be derived from the parent device name.}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhj hhubh)}(hXIf the driver doesn't use a static device name (for example it uses dev_name()), and therefore cannot make sure the name only contains valid characters, hwmon_sanitize_name can be used. This convenience function will duplicate the string and replace any invalid characters with an underscore. It will allocate memory for the new string and it is the responsibility of the caller to release the memory when the device is removed.h]hXIf the driver doesn’t use a static device name (for example it uses dev_name()), and therefore cannot make sure the name only contains valid characters, hwmon_sanitize_name can be used. This convenience function will duplicate the string and replace any invalid characters with an underscore. It will allocate memory for the new string and it is the responsibility of the caller to release the memory when the device is removed.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKIhj hhubh)}(hdevm_hwmon_sanitize_name is the resource managed version of hwmon_sanitize_name; the memory will be freed automatically on device removal.h]hdevm_hwmon_sanitize_name is the resource managed version of hwmon_sanitize_name; the memory will be freed automatically on device removal.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhj hhubh)}(hXWhen using ``[devm_]hwmon_device_register_with_info()`` to register the hardware monitoring device, accesses using the associated access functions are serialised by the hardware monitoring core. If a driver needs locking for other functions such as interrupt handlers or for attributes which are fully implemented in the driver, hwmon_lock() and hwmon_unlock() can be used to ensure that calls to those functions are serialized.h](h When using }(hjhhhNhNubhliteral)}(h,``[devm_]hwmon_device_register_with_info()``h]h([devm_]hwmon_device_register_with_info()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhXu to register the hardware monitoring device, accesses using the associated access functions are serialised by the hardware monitoring core. If a driver needs locking for other functions such as interrupt handlers or for attributes which are fully implemented in the driver, hwmon_lock() and hwmon_unlock() can be used to ensure that calls to those functions are serialized.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKUhj hhubeh}(h]the-apiah ]h"]the apiah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h,Using devm_hwmon_device_register_with_info()h]h,Using devm_hwmon_device_register_with_info()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK]ubh)}(hmhwmon_device_register_with_info() registers a hardware monitoring device. The parameters to this function areh]hmhwmon_device_register_with_info() registers a hardware monitoring device. The parameters to this function are}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hjhhubhtable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthK/uh1jhjubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK/uh1jhjubhtbody)}(hhh](hrow)}(hhh](hentry)}(hhh]h)}(h`struct device *dev`h]htitle_reference)}(hjh]hstruct device *dev}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhKchjubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(hPointer to parent deviceh]hPointer to parent device}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchj4ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h`const char *name`h]j)}(hjYh]hconst char *name}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjWubah}(h]h ]h"]h$]h&]uh1hhhhKdhjTubah}(h]h ]h"]h$]h&]uh1jhjQubj)}(hhh]h)}(h Device nameh]h Device name}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKdhjtubah}(h]h ]h"]h$]h&]uh1jhjQubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h`void *drvdata`h]j)}(hjh]h void *drvdata}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhKehjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hDriver private datah]hDriver private data}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKehjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h$`const struct hwmon_chip_info *info`h]j)}(hjh]h"const struct hwmon_chip_info *info}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhKfhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hPointer to chip description.h]hPointer to chip description.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h-`const struct attribute_group **extra_groups`h]j)}(hjh]h+const struct attribute_group **extra_groups}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhhhKghjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hGNull-terminated list of additional non-standard sysfs attribute groups.h]hGNull-terminated list of additional non-standard sysfs attribute groups.}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKghj4ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]colsKuh1jhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubh)}(h{This function returns a pointer to the created hardware monitoring device on success and a negative error code for failure.h]h{This function returns a pointer to the created hardware monitoring device on success and a negative error code for failure.}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhjhhubh)}(h0The hwmon_chip_info structure looks as follows::h]h/The hwmon_chip_info structure looks as follows:}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhjhhubj*)}(hwstruct hwmon_chip_info { const struct hwmon_ops *ops; const struct hwmon_channel_info * const *info; };h]hwstruct hwmon_chip_info { const struct hwmon_ops *ops; const struct hwmon_channel_info * const *info; };}hjsbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhKphjhhubh)}(h!It contains the following fields:h]h!It contains the following fields:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKuhjhhubh bullet_list)}(hhh](h list_item)}(h(ops: Pointer to device operations.h]hdefinition_list)}(hhh]hdefinition_list_item)}(h"ops: Pointer to device operations.h](hterm)}(hops:h]hops:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKwhjubh definition)}(hhh]h)}(hPointer to device operations.h]hPointer to device operations.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKxhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKwhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhjhhhNhNubj)}(h@info: NULL-terminated list of device channel descriptors. h]j)}(hhh]j)}(h:info: NULL-terminated list of device channel descriptors. h](j)}(hinfo:h]hinfo:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKzhjubj)}(hhh]h)}(h3NULL-terminated list of device channel descriptors.h]h3NULL-terminated list of device channel descriptors.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKzhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhjhhhNhNubeh}(h]h ]h"]h$]h&]bullet*uh1jhhhKwhjhhubh)}(h,The list of hwmon operations is defined as::h]h+The list of hwmon operations is defined as:}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK|hjhhubj*)}(hX_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); };h]hX_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); };}hjEsbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhK~hjhhubh)}(h$It defines the following operations.h]h$It defines the following operations.}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh](j)}(hxis_visible: Pointer to a function to return the file mode for each supported attribute. This function is mandatory. h]j)}(hhh]j)}(htis_visible: Pointer to a function to return the file mode for each supported attribute. This function is mandatory. h](j)}(h is_visible:h]h is_visible:}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjkubj)}(hhh]h)}(hgPointer to a function to return the file mode for each supported attribute. This function is mandatory.h]hgPointer to a function to return the file mode for each supported attribute. This function is mandatory.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj}ubah}(h]h ]h"]h$]h&]uh1jhjkubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhubah}(h]h ]h"]h$]h&]uh1jhjdubah}(h]h ]h"]h$]h&]uh1jhjahhhNhNubj)}(hread: Pointer to a function for reading a value from the chip. This function is optional, but must be provided if any readable attributes exist. h]j)}(hhh]j)}(hread: Pointer to a function for reading a value from the chip. This function is optional, but must be provided if any readable attributes exist. h](j)}(hread:h]hread:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hhh]h)}(hPointer to a function for reading a value from the chip. This function is optional, but must be provided if any readable attributes exist.h]hPointer to a function for reading a value from the chip. This function is optional, but must be provided if any readable attributes exist.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhjahhhNhNubj)}(hwrite: Pointer to a function for writing a value to the chip. This function is optional, but must be provided if any writeable attributes exist. h]j)}(hhh]j)}(hwrite: Pointer to a function for writing a value to the chip. This function is optional, but must be provided if any writeable attributes exist. h](j)}(hwrite:h]hwrite:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hhh]h)}(hPointer to a function for writing a value to the chip. This function is optional, but must be provided if any writeable attributes exist.h]hPointer to a function for writing a value to the chip. This function is optional, but must be provided if any writeable attributes exist.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhjahhhNhNubeh}(h]h ]h"]h$]h&]j5j6uh1jhhhKhjhhubh)}(h^Each sensor channel is described with struct hwmon_channel_info, which is defined as follows::h]h]Each sensor channel is described with struct hwmon_channel_info, which is defined as follows:}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj*)}(hYstruct hwmon_channel_info { enum hwmon_sensor_types type; u32 *config; };h]hYstruct hwmon_channel_info { enum hwmon_sensor_types type; u32 *config; };}hj>sbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhKhjhhubh)}(hIt contains following fields:h]hIt contains following fields:}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh](j)}(hXtype: 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 ================== ================================================== h]j)}(hhh]j)}(hXtype: 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 ================== ================================================== h](j)}(htype:h]htype:}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjdubj)}(hhh](h)}(h$The hardware monitoring sensor type.h]h$The hardware monitoring sensor type.}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjvubh)}(hSupported sensor types areh]hSupported sensor types are}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjvubh block_quote)}(hXr================== ================================================== 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 ================== ================================================== h]j)}(hhh]j)}(hhh](j)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK2uh1jhjubj)}(hhh](j )}(hhh](j)}(hhh]h)}(h hwmon_chiph]h hwmon_chip}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hdA virtual sensor type, used to describe attributes which are not bound to a specific input or outputh]hdA virtual sensor type, used to describe attributes which are not bound to a specific input or output}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h hwmon_temph]h hwmon_temp}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hTemperature sensorh]hTemperature sensor}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(hhwmon_inh]hhwmon_in}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj)ubah}(h]h ]h"]h$]h&]uh1jhj&ubj)}(hhh]h)}(hVoltage sensorh]hVoltage sensor}(hjChhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj@ubah}(h]h ]h"]h$]h&]uh1jhj&ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h hwmon_currh]h hwmon_curr}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj`ubah}(h]h ]h"]h$]h&]uh1jhj]ubj)}(hhh]h)}(hCurrent sensorh]hCurrent sensor}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjwubah}(h]h ]h"]h$]h&]uh1jhj]ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h hwmon_powerh]h hwmon_power}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h Power sensorh]h Power sensor}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h hwmon_energyh]h hwmon_energy}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h Energy sensorh]h Energy sensor}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(hhwmon_energy64h]hhwmon_energy64}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h.Energy sensor, reported as 64-bit signed valueh]h.Energy sensor, reported as 64-bit signed value}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(hhwmon_humidityh]hhwmon_humidity}(hj?hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj<ubah}(h]h ]h"]h$]h&]uh1jhj9ubj)}(hhh]h)}(hHumidity sensorh]hHumidity sensor}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjSubah}(h]h ]h"]h$]h&]uh1jhj9ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h hwmon_fanh]h hwmon_fan}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjsubah}(h]h ]h"]h$]h&]uh1jhjpubj)}(hhh]h)}(hFan speed sensorh]hFan speed sensor}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjpubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h hwmon_pwmh]h hwmon_pwm}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h PWM controlh]h PWM control}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]colsKuh1jhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjvubeh}(h]h ]h"]h$]h&]uh1jhjdubeh}(h]h ]h"]h$]h&]uh1jhhhKhjaubah}(h]h ]h"]h$]h&]uh1jhj]ubah}(h]h ]h"]h$]h&]uh1jhjZhhhNhNubj)}(hconfig: 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. h]j)}(hhh]j)}(hconfig: 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. h](j)}(hconfig:h]hconfig:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hhh]h)}(hPointer 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.h]hPointer 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.}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj(ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhjZhhhNhNubeh}(h]h ]h"]h$]h&]j5j6uh1jhhhKhjhhubh)}(hXAs an example, here is the complete description file for a LM75 compatible sensor chip. The chip has a single temperature sensor. The driver wants to register with the thermal subsystem (HWMON_C_REGISTER_TZ), and it supports the update_interval attribute (HWMON_C_UPDATE_INTERVAL). The chip supports reading the temperature (HWMON_T_INPUT), it has a maximum temperature register (HWMON_T_MAX) as well as a maximum temperature hysteresis register (HWMON_T_MAX_HYST)::h]hXAs an example, here is the complete description file for a LM75 compatible sensor chip. The chip has a single temperature sensor. The driver wants to register with the thermal subsystem (HWMON_C_REGISTER_TZ), and it supports the update_interval attribute (HWMON_C_UPDATE_INTERVAL). The chip supports reading the temperature (HWMON_T_INPUT), it has a maximum temperature register (HWMON_T_MAX) as well as a maximum temperature hysteresis register (HWMON_T_MAX_HYST):}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj*)}(hXstatic const u32 lm75_chip_config[] = { HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL, 0 }; static const struct hwmon_channel_info lm75_chip = { .type = hwmon_chip, .config = lm75_chip_config, }; static const u32 lm75_temp_config[] = { HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST, 0 }; static const struct hwmon_channel_info lm75_temp = { .type = hwmon_temp, .config = lm75_temp_config, }; static const struct hwmon_channel_info * const lm75_info[] = { &lm75_chip, &lm75_temp, NULL }; The HWMON_CHANNEL_INFO() macro can and should be used when possible. With this macro, the above example can be simplified to static const struct hwmon_channel_info * const lm75_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST), NULL }; The remaining declarations are as follows. static const struct hwmon_ops lm75_hwmon_ops = { .is_visible = lm75_is_visible, .read = lm75_read, .write = lm75_write, }; static const struct hwmon_chip_info lm75_chip_info = { .ops = &lm75_hwmon_ops, .info = lm75_info, };h]hXstatic const u32 lm75_chip_config[] = { HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL, 0 }; static const struct hwmon_channel_info lm75_chip = { .type = hwmon_chip, .config = lm75_chip_config, }; static const u32 lm75_temp_config[] = { HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST, 0 }; static const struct hwmon_channel_info lm75_temp = { .type = hwmon_temp, .config = lm75_temp_config, }; static const struct hwmon_channel_info * const lm75_info[] = { &lm75_chip, &lm75_temp, NULL }; The HWMON_CHANNEL_INFO() macro can and should be used when possible. With this macro, the above example can be simplified to static const struct hwmon_channel_info * const lm75_info[] = { HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL), HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST), NULL }; The remaining declarations are as follows. static const struct hwmon_ops lm75_hwmon_ops = { .is_visible = lm75_is_visible, .read = lm75_read, .write = lm75_write, }; static const struct hwmon_chip_info lm75_chip_info = { .ops = &lm75_hwmon_ops, .info = lm75_info, };}hjesbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhKhjhhubh)}(hA complete list of bit values indicating individual attribute support is defined in include/linux/hwmon.h. Definition prefixes are as follows.h]hA complete list of bit values indicating individual attribute support is defined in include/linux/hwmon.h. Definition prefixes are as follows.}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh]j)}(hhh](j)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhjubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK1uh1jhjubj)}(hhh](j )}(hhh](j)}(hhh]h)}(h HWMON_C_xxxxh]h HWMON_C_xxxx}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h)Chip attributes, for use with hwmon_chip.h]h)Chip attributes, for use with hwmon_chip.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h HWMON_T_xxxxh]h HWMON_T_xxxx}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h0Temperature attributes, for use with hwmon_temp.h]h0Temperature attributes, for use with hwmon_temp.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h HWMON_I_xxxxh]h HWMON_I_xxxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(h*Voltage attributes, for use with hwmon_in.h]h*Voltage attributes, for use with hwmon_in.}(hj) hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj& ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h HWMON_C_xxxxh]h HWMON_C_xxxx}(hjI hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjF ubah}(h]h ]h"]h$]h&]uh1jhjC ubj)}(hhh]h)}(h\Current attributes, for use with hwmon_curr. Notice the prefix overlap with chip attributes.h]h\Current attributes, for use with hwmon_curr. Notice the prefix overlap with chip attributes.}(hj` hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj] ubah}(h]h ]h"]h$]h&]uh1jhjC ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h HWMON_P_xxxxh]h HWMON_P_xxxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj} ubah}(h]h ]h"]h$]h&]uh1jhjz ubj)}(hhh]h)}(h+Power attributes, for use with hwmon_power.h]h+Power attributes, for use with hwmon_power.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhjz ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h HWMON_E_xxxxh]h HWMON_E_xxxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(h-Energy attributes, for use with hwmon_energy.h]h-Energy attributes, for use with hwmon_energy.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h HWMON_H_xxxxh]h HWMON_H_xxxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(h1Humidity attributes, for use with hwmon_humidity.h]h1Humidity attributes, for use with hwmon_humidity.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(h HWMON_F_xxxxh]h HWMON_F_xxxx}(hj% hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj" ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(h-Fan speed attributes, for use with hwmon_fan.h]h-Fan speed attributes, for use with hwmon_fan.}(hj< hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj9 ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hjubj )}(hhh](j)}(hhh]h)}(hHWMON_PWM_xxxxh]hHWMON_PWM_xxxx}(hj\ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjY ubah}(h]h ]h"]h$]h&]uh1jhjV ubj)}(hhh]h)}(h/PWM control attributes, for use with hwmon_pwm.h]h/PWM control attributes, for use with hwmon_pwm.}(hjs hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjp ubah}(h]h ]h"]h$]h&]uh1jhjV ubeh}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]colsKuh1jhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]*using-devm-hwmon-device-register-with-infoah ]h"],using devm_hwmon_device_register_with_info()ah$]h&]uh1hhhhhhhhK]ubh)}(hhh](h)}(hDriver callback functionsh]hDriver callback functions}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(h}Each driver provides is_visible, read, and write functions. Parameters and return values for those functions are as follows::h]h|Each driver provides is_visible, read, and write functions. Parameters and return values for those functions are as follows:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj*)}(hvumode_t is_visible_func(const void *data, enum hwmon_sensor_types type, u32 attr, int channel)h]hvumode_t is_visible_func(const void *data, enum hwmon_sensor_types type, u32 attr, int channel)}hj sbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhMhj hhubj)}(hhh](j)}(hXParameters: data: Pointer to device private data structure. type: The sensor type. attr: Attribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings of bit fields to attribute values please see include/linux/hwmon.h. channel: The sensor channel number. h](j)}(h Parameters:h]h Parameters:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh]j)}(hhh](j)}(h/data: Pointer to device private data structure.h](j)}(hdata:h]hdata:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM hj ubj)}(hhh]h)}(h)Pointer to device private data structure.h]h)Pointer to device private data structure.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM hj ubj)}(htype: The sensor type.h](j)}(htype:h]htype:}(hj# hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM hj ubj)}(hhh]h)}(hThe sensor type.h]hThe sensor type.}(hj4 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj1 ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM hj ubj)}(hattr: Attribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings of bit fields to attribute values please see include/linux/hwmon.h.h](j)}(hattr:h]hattr:}(hjR hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjN ubj)}(hhh]h)}(hAttribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings of bit fields to attribute values please see include/linux/hwmon.h.h]hAttribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings of bit fields to attribute values please see include/linux/hwmon.h.}(hjc hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj` ubah}(h]h ]h"]h$]h&]uh1jhjN ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(h$channel: The sensor channel number. h](j)}(hchannel:h]hchannel:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj} ubj)}(hhh]h)}(hThe sensor channel number.h]hThe sensor channel number.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj} ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubeh}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(h~Return value: The file mode for this attribute. Typically, this will be 0 (the attribute will not be created), 0444, or 0644. h](j)}(h Return value:h]h Return value:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh]h)}(hoThe file mode for this attribute. Typically, this will be 0 (the attribute will not be created), 0444, or 0644.h]hoThe file mode for this attribute. Typically, this will be 0 (the attribute will not be created), 0444, or 0644.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj hhubeh}(h]h ]h"]h$]h&]uh1jhj hhhNhNubj*)}(hoint read_func(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val)h]hoint read_func(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val)}hj sbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhMhj hhubj)}(hhh](j)}(hXParameters: dev: Pointer to the hardware monitoring device. type: The sensor type. attr: Attribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings please see include/linux/hwmon.h. channel: The sensor channel number. val: Pointer to attribute value. For hwmon_energy64, `'val`' is passed as `long *` but needs a typecast to `s64 *`. h](j)}(h Parameters:h]h Parameters:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM/hj ubj)}(hhh]j)}(hhh](j)}(h/dev: Pointer to the hardware monitoring device.h](j)}(hdev:h]hdev:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM!hj ubj)}(hhh]h)}(h*Pointer to the hardware monitoring device.h]h*Pointer to the hardware monitoring device.}(hj1 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM"hj. ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM!hj ubj)}(htype: The sensor type.h](j)}(htype:h]htype:}(hjO hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM#hjK ubj)}(hhh]h)}(hThe sensor type.h]hThe sensor type.}(hj` hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM$hj] ubah}(h]h ]h"]h$]h&]uh1jhjK ubeh}(h]h ]h"]h$]h&]uh1jhhhM#hj ubj)}(hattr: Attribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings please see include/linux/hwmon.h.h](j)}(hattr:h]hattr:}(hj~ hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM(hjz ubj)}(hhh]h)}(hAttribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings please see include/linux/hwmon.h.h]hAttribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings please see include/linux/hwmon.h.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM&hj ubah}(h]h ]h"]h$]h&]uh1jhjz ubeh}(h]h ]h"]h$]h&]uh1jhhhM(hj ubj)}(h#channel: The sensor channel number.h](j)}(hchannel:h]hchannel:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM*hj ubj)}(hhh]h)}(hThe sensor channel number.h]hThe sensor channel number.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM+hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM*hj ubj)}(htval: Pointer to attribute value. For hwmon_energy64, `'val`' is passed as `long *` but needs a typecast to `s64 *`. h](j)}(hval:h]hval:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM/hj ubj)}(hhh]h)}(hnPointer to attribute value. For hwmon_energy64, `'val`' is passed as `long *` but needs a typecast to `s64 *`.h](h0Pointer to attribute value. For hwmon_energy64, }(hj hhhNhNubj)}(h`'val`h]h‘val}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh’ is passed as }(hj hhhNhNubj)}(h`long *`h]hlong *}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh but needs a typecast to }(hj hhhNhNubj)}(h`s64 *`h]hs64 *}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM-hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM/hj ubeh}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM/hj ubj)}(h?Return value: 0 on success, a negative error number otherwise. h](j)}(h Return value:h]h Return value:}(hjS hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM2hjO ubj)}(hhh]h)}(h00 on success, a negative error number otherwise.h]h00 on success, a negative error number otherwise.}(hjd hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM2hja ubah}(h]h ]h"]h$]h&]uh1jhjO ubeh}(h]h ]h"]h$]h&]uh1jhhhM2hj hhubeh}(h]h ]h"]h$]h&]uh1jhj hhhNhNubj*)}(hpint write_func(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long val)h]hpint write_func(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long val)}hj sbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhM6hj hhubj)}(hhh](j)}(hXParameters: dev: Pointer to the hardware monitoring device. type: The sensor type. attr: Attribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings please see include/linux/hwmon.h. channel: The sensor channel number. val: The value to write to the chip. h](j)}(h Parameters:h]h Parameters:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMFhj ubj)}(hhh]j)}(hhh](j)}(h/dev: Pointer to the hardware monitoring device.h](j)}(hdev:h]hdev:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM:hj ubj)}(hhh]h)}(h*Pointer to the hardware monitoring device.h]h*Pointer to the hardware monitoring device.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM;hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM:hj ubj)}(htype: The sensor type.h](j)}(htype:h]htype:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM<hj ubj)}(hhh]h)}(hThe sensor type.h]hThe sensor type.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM=hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM<hj ubj)}(hattr: Attribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings please see include/linux/hwmon.h.h](j)}(hattr:h]hattr:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMAhj ubj)}(hhh]h)}(hAttribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings please see include/linux/hwmon.h.h]hAttribute identifier associated with a specific attribute. For example, the attribute value for HWMON_T_INPUT would be hwmon_temp_input. For complete mappings please see include/linux/hwmon.h.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM?hjubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMAhj ubj)}(h#channel: The sensor channel number.h](j)}(hchannel:h]hchannel:}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMChj:ubj)}(hhh]h)}(hThe sensor channel number.h]hThe sensor channel number.}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMDhjLubah}(h]h ]h"]h$]h&]uh1jhj:ubeh}(h]h ]h"]h$]h&]uh1jhhhMChj ubj)}(h%val: The value to write to the chip. h](j)}(hval:h]hval:}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMFhjiubj)}(hhh]h)}(hThe value to write to the chip.h]hThe value to write to the chip.}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMFhj{ubah}(h]h ]h"]h$]h&]uh1jhjiubeh}(h]h ]h"]h$]h&]uh1jhhhMFhj ubeh}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMFhj ubj)}(h@Return value: 0 on success, a negative error number otherwise. h](j)}(h Return value:h]h Return value:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMJhjubj)}(hhh]h)}(h00 on success, a negative error number otherwise.h]h00 on success, a negative error number otherwise.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMIhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMJhj hhubeh}(h]h ]h"]h$]h&]uh1jhj hhhNhNubeh}(h]driver-callback-functionsah ]h"]driver callback functionsah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h Driver-provided sysfs attributesh]h Driver-provided sysfs attributes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMMubh)}(hIn most situations it should not be necessary for a driver to provide sysfs attributes since the hardware monitoring core creates those internally. Only additional non-standard sysfs attributes need to be provided.h]hIn most situations it should not be necessary for a driver to provide sysfs attributes since the hardware monitoring core creates those internally. Only additional non-standard sysfs attributes need to be provided.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMOhjhhubh)}(hThe header file linux/hwmon-sysfs.h provides a number of useful macros to declare and use hardware monitoring sysfs attributes.h]hThe header file linux/hwmon-sysfs.h provides a number of useful macros to declare and use hardware monitoring sysfs attributes.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShjhhubh)}(hXSIn many cases, you can use the existing define DEVICE_ATTR or its variants DEVICE_ATTR_{RW,RO,WO} to declare such attributes. This is feasible if an attribute has no additional context. However, in many cases there will be additional information such as a sensor index which will need to be passed to the sysfs attribute handling function.h]hXSIn many cases, you can use the existing define DEVICE_ATTR or its variants DEVICE_ATTR_{RW,RO,WO} to declare such attributes. This is feasible if an attribute has no additional context. However, in many cases there will be additional information such as a sensor index which will need to be passed to the sysfs attribute handling function.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMVhjhhubh)}(hSENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 can be used to define attributes which need such additional context information. SENSOR_DEVICE_ATTR requires one additional argument, SENSOR_DEVICE_ATTR_2 requires two.h]hSENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 can be used to define attributes which need such additional context information. SENSOR_DEVICE_ATTR requires one additional argument, SENSOR_DEVICE_ATTR_2 requires two.}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM\hjhhubh)}(hXSimplified variants of SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 are available and should be used if standard attribute permissions and function names are feasible. Standard permissions are 0644 for SENSOR_DEVICE_ATTR[_2]_RW, 0444 for SENSOR_DEVICE_ATTR[_2]_RO, and 0200 for SENSOR_DEVICE_ATTR[_2]_WO. Standard functions, similar to DEVICE_ATTR_{RW,RO,WO}, have _show and _store appended to the provided function name.h]hXSimplified variants of SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 are available and should be used if standard attribute permissions and function names are feasible. Standard permissions are 0644 for SENSOR_DEVICE_ATTR[_2]_RW, 0444 for SENSOR_DEVICE_ATTR[_2]_RO, and 0200 for SENSOR_DEVICE_ATTR[_2]_WO. Standard functions, similar to DEVICE_ATTR_{RW,RO,WO}, have _show and _store appended to the provided function name.}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM`hjhhubh)}(hSENSOR_DEVICE_ATTR and its variants define a struct sensor_device_attribute variable. This structure has the following fields::h]h~SENSOR_DEVICE_ATTR and its variants define a struct sensor_device_attribute variable. This structure has the following fields:}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMghjhhubj*)}(h`struct sensor_device_attribute { struct device_attribute dev_attr; int index; };h]h`struct sensor_device_attribute { struct device_attribute dev_attr; int index; };}hjLsbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhMjhjhhubh)}(hYou can use to_sensor_dev_attr to get the pointer to this structure from the attribute read or write function. Its parameter is the device to which the attribute is attached.h]hYou can use to_sensor_dev_attr to get the pointer to this structure from the attribute read or write function. Its parameter is the device to which the attribute is attached.}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMohjhhubh)}(hwSENSOR_DEVICE_ATTR_2 and its variants define a struct sensor_device_attribute_2 variable, which is defined as follows::h]hvSENSOR_DEVICE_ATTR_2 and its variants define a struct sensor_device_attribute_2 variable, which is defined as follows:}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMshjhhubj*)}(hpstruct sensor_device_attribute_2 { struct device_attribute dev_attr; u8 index; u8 nr; };h]hpstruct sensor_device_attribute_2 { struct device_attribute dev_attr; u8 index; u8 nr; };}hjvsbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhMvhjhhubh)}(h~Use to_sensor_dev_attr_2 to get the pointer to this structure. Its parameter is the device to which the attribute is attached.h]h~Use to_sensor_dev_attr_2 to get the pointer to this structure. Its parameter is the device to which the attribute is attached.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM|hjhhubeh}(h] driver-provided-sysfs-attributesah ]h"] driver-provided sysfs attributesah$]h&]uh1hhhhhhhhMMubeh}(h](the-linux-hardware-monitoring-kernel-apiah ]h"](the linux hardware monitoring kernel apiah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksjfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjjjjj j jjjju nametypes}(jjjj jjuh}(jhjhjj j jjj jju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.