sphinx.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)}(hXstruct 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);h]hXstruct 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);}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&]uh1hhhhK-hj 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&]uh1hhhhK4hj 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&]uh1hhhhK8hj 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&]uh1hhhhKAhj 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&]uh1hhhhKFhj 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&]uh1hhhhKNhj 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&]uh1hhjhhhhhKSubh)}(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&]uh1hhhhKUhjhhubhtable)}(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&]uh1hhhhKYhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hPointer to parent deviceh]hPointer to parent device}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh](j)}(hhh]h)}(h`const char *name`h]j)}(hj7h]hconst char *name}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj5ubah}(h]h ]h"]h$]h&]uh1hhhhKZhj2ubah}(h]h ]h"]h$]h&]uh1jhj/ubj)}(hhh]h)}(h Device nameh]h Device name}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKZhjRubah}(h]h ]h"]h$]h&]uh1jhj/ubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh](j)}(hhh]h)}(h`void *drvdata`h]j)}(hjwh]h void *drvdata}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjuubah}(h]h ]h"]h$]h&]uh1hhhhK[hjrubah}(h]h ]h"]h$]h&]uh1jhjoubj)}(hhh]h)}(hDriver private datah]hDriver private data}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjubah}(h]h ]h"]h$]h&]uh1jhjoubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(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&]uh1hhhhK\hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hPointer to chip description.h]hPointer to chip description.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(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&]uh1hhhhK]hjubah}(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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK]hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(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.}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKahjhhubh)}(h0The hwmon_chip_info structure looks as follows::h]h/The hwmon_chip_info structure looks as follows:}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKdhjhhubj*)}(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; };}hj^sbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhKfhjhhubh)}(h!It contains the following fields:h]h!It contains the following fields:}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKkhjhhubh 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&]uh1jhhhKmhjubh definition)}(hhh]h)}(hPointer to device operations.h]hPointer to device operations.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKmhjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhj|hhhNhNubj)}(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&]uh1jhhhKphjubj)}(hhh]h)}(h3NULL-terminated list of device channel descriptors.h]h3NULL-terminated list of device channel descriptors.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKphjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1jhj|hhhNhNubeh}(h]h ]h"]h$]h&]bullet*uh1jzhhhKmhjhhubh)}(h,The list of hwmon operations is defined as::h]h+The list of hwmon operations is defined as:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKrhjhhubj*)}(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); };}hj#sbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhKthjhhubh)}(h$It defines the following operations.h]h$It defines the following operations.}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK}hjhhubj{)}(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:}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjIubj)}(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.}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj[ubah}(h]h ]h"]h$]h&]uh1jhjIubeh}(h]h ]h"]h$]h&]uh1jhhhKhjFubah}(h]h ]h"]h$]h&]uh1jhjBubah}(h]h ]h"]h$]h&]uh1jhj?hhhNhNubj)}(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&]uh1jhj?hhhNhNubj)}(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&]uh1jhj?hhhNhNubeh}(h]h ]h"]h$]h&]jjuh1jzhhhKhjhhubh)}(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:}(hjhhhNhNubah}(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; };}hjsbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhKhjhhubh)}(hIt contains following fields:h]hIt contains following fields:}(hj*hhhNhNubah}(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_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_humidity Humidity sensor hwmon_fan Fan speed sensor hwmon_pwm PWM control ================== ================================================== h](j)}(htype:h]htype:}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjBubj)}(hhh](h)}(h$The hardware monitoring sensor type.h]h$The hardware monitoring sensor type.}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjTubh)}(hSupported sensor types areh]hSupported sensor types are}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjTubh block_quote)}(hX0================== ================================================== 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_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&]colwidthKuh1jhj|ubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK2uh1jhj|ubj)}(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&]uh1jhjubj)}(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}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh](j)}(hhh]h)}(hhwmon_inh]hhwmon_in}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hVoltage sensorh]hVoltage sensor}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh](j)}(hhh]h)}(h hwmon_currh]h hwmon_curr}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj>ubah}(h]h ]h"]h$]h&]uh1jhj;ubj)}(hhh]h)}(hCurrent sensorh]hCurrent sensor}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjUubah}(h]h ]h"]h$]h&]uh1jhj;ubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh](j)}(hhh]h)}(h hwmon_powerh]h hwmon_power}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjuubah}(h]h ]h"]h$]h&]uh1jhjrubj)}(hhh]h)}(h Power sensorh]h Power sensor}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjrubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(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&]uh1jhjubj)}(hhh](j)}(hhh]h)}(hhwmon_humidityh]hhwmon_humidity}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hHumidity sensorh]hHumidity sensor}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh](j)}(hhh]h)}(h hwmon_fanh]h hwmon_fan}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(hFan speed sensorh]hFan speed sensor}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj1ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh](j)}(hhh]h)}(h hwmon_pwmh]h hwmon_pwm}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjQubah}(h]h ]h"]h$]h&]uh1jhjNubj)}(hhh]h)}(h PWM controlh]h PWM control}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhubah}(h]h ]h"]h$]h&]uh1jhjNubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhj|ubeh}(h]h ]h"]h$]h&]colsKuh1jhjyubah}(h]h ]h"]h$]h&]uh1jhjuubah}(h]h ]h"]h$]h&]uh1jshhhKhjTubeh}(h]h ]h"]h$]h&]uh1jhjBubeh}(h]h ]h"]h$]h&]uh1jhhhKhj?ubah}(h]h ]h"]h$]h&]uh1jhj;ubah}(h]h ]h"]h$]h&]uh1jhj8hhhNhNubj)}(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.}(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&]uh1jhj8hhhNhNubeh}(h]h ]h"]h$]h&]jjuh1jzhhhKhjhhubh)}(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):}(hjhhhNhNubah}(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, };}hj sbah}(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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hhh]j)}(hhh](j)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jhj+ubj)}(hhh]h}(h]h ]h"]h$]h&]colwidthK1uh1jhj+ubj)}(hhh](j)}(hhh](j)}(hhh]h)}(h HWMON_C_xxxxh]h HWMON_C_xxxx}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjHubah}(h]h ]h"]h$]h&]uh1jhjEubj)}(hhh]h)}(h)Chip attributes, for use with hwmon_chip.h]h)Chip attributes, for use with hwmon_chip.}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj_ubah}(h]h ]h"]h$]h&]uh1jhjEubeh}(h]h ]h"]h$]h&]uh1jhjBubj)}(hhh](j)}(hhh]h)}(h HWMON_T_xxxxh]h HWMON_T_xxxx}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhj|ubj)}(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&]uh1jhj|ubeh}(h]h ]h"]h$]h&]uh1jhjBubj)}(hhh](j)}(hhh]h)}(h HWMON_I_xxxxh]h HWMON_I_xxxx}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hhh]h)}(h*Voltage attributes, for use with hwmon_in.h]h*Voltage attributes, for use with hwmon_in.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjBubj)}(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\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&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjBubj)}(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&]uh1jhj! 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&]uh1jhj! ubeh}(h]h ]h"]h$]h&]uh1jhjBubj)}(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&]uh1jhjX ubj)}(hhh]h)}(h-Energy attributes, for use with hwmon_energy.h]h-Energy attributes, for use with hwmon_energy.}(hju hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjr ubah}(h]h ]h"]h$]h&]uh1jhjX ubeh}(h]h ]h"]h$]h&]uh1jhjBubj)}(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&]uh1jhjBubj)}(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&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhjBubj)}(hhh](j)}(hhh]h)}(hHWMON_PWM_xxxxh]hHWMON_PWM_xxxx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubj)}(hhh]h)}(h/PWM control attributes, for use with hwmon_pwm.h]h/PWM control attributes, for use with hwmon_pwm.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhjBubeh}(h]h ]h"]h$]h&]uh1jhj+ubeh}(h]h ]h"]h$]h&]colsKuh1jhj(ubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]*using-devm-hwmon-device-register-with-infoah ]h"],using devm_hwmon_device_register_with_info()ah$]h&]uh1hhhhhhhhKSubh)}(hhh](h)}(hDriver callback functionsh]hDriver callback functions}(hjR hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjO hhhhhKubh)}(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&]uh1hhhhKhjO 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)}hjn sbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhKhjO 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&]uh1jhhhM hj 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&]uh1jhhhMhj 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&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(htype: The sensor type.h](j)}(htype:h]htype:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh]h)}(hThe sensor type.h]hThe sensor type.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj 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:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj 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.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj 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&]uh1jhhhM hj$ ubj)}(hhh]h)}(hThe sensor channel number.h]hThe sensor channel number.}(hj9 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj6 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: 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:}(hji hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhje 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.}(hjz hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjw ubah}(h]h ]h"]h$]h&]uh1jhje ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj| hhubeh}(h]h ]h"]h$]h&]uh1jhjO 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)hhhMhjO 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. 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&]uh1jhhhMhj 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&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(htype: The sensor type.h](j)}(htype:h]htype:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh]h)}(hThe sensor type.h]hThe sensor type.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj 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&]uh1jhhhMhj! 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.}(hj6 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj3 ubah}(h]h ]h"]h$]h&]uh1jhj! ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(h#channel: The sensor channel number.h](j)}(hchannel:h]hchannel:}(hjT hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjP ubj)}(hhh]h)}(hThe sensor channel number.h]hThe sensor channel number.}(hje hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjb ubah}(h]h ]h"]h$]h&]uh1jhjP ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(h!val: Pointer to attribute value. h](j)}(hval:h]hval:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM"hj ubj)}(hhh]h)}(hPointer to attribute value.h]hPointer to attribute value.}(hj hhhNhNubah}(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:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM%hj ubj)}(hhh]h)}(h00 on success, a negative error number otherwise.h]h00 on success, a negative error number otherwise.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM%hj hhubeh}(h]h ]h"]h$]h&]uh1jhjO 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)hhhM)hjO 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&]uh1jhhhM9hj 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.}(hj3 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM.hj0 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:}(hjQ hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM/hjM ubj)}(hhh]h)}(hThe sensor type.h]hThe sensor type.}(hjb hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM0hj_ ubah}(h]h ]h"]h$]h&]uh1jhjM 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&]uh1jhhhM4hj| 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&]uh1hhhhM2hj ubah}(h]h ]h"]h$]h&]uh1jhj| ubeh}(h]h ]h"]h$]h&]uh1jhhhM4hj ubj)}(h#channel: The sensor channel number.h](j)}(hchannel:h]hchannel:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM6hj ubj)}(hhh]h)}(hThe sensor channel number.h]hThe sensor channel number.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM7hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM6hj ubj)}(h%val: The value to write to the chip. h](j)}(hval:h]hval:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM9hj ubj)}(hhh]h)}(hThe value to write to the chip.h]hThe value to write to the chip.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM9hj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM9hj ubeh}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM9hj 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&]uh1jhhhM=hjubj)}(hhh]h)}(h00 on success, a negative error number otherwise.h]h00 on success, a negative error number otherwise.}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM<hj-ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhM=hj hhubeh}(h]h ]h"]h$]h&]uh1jhjO hhhNhNubeh}(h]driver-callback-functionsah ]h"]driver callback functionsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Driver-provided sysfs attributesh]h Driver-provided sysfs attributes}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjXhhhhhM@ubh)}(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.}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMBhjXhhubh)}(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.}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMFhjXhhubh)}(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&]uh1hhhhMIhjXhhubh)}(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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMOhjXhhubh)}(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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShjXhhubh)}(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:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMZhjXhhubj*)}(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; };}hjsbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhM]hjXhhubh)}(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.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMbhjXhhubh)}(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:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMfhjXhhubj*)}(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; };}hjsbah}(h]h ]h"]h$]h&]j9j:uh1j)hhhMihjXhhubh)}(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&]uh1hhhhMohjXhhubeh}(h] driver-provided-sysfs-attributesah ]h"] driver-provided sysfs attributesah$]h&]uh1hhhhhhhhM@ubeh}(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_handlerj5error_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}(jj jjjjjL jI jUjRjju nametypes}(jjjjL jUjuh}(j hjhjj jI jjRjO jjXu 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.