diff options
author | Guenter Roeck <linux@roeck-us.net> | 2016-12-27 18:28:19 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2018-12-16 18:13:22 -0500 |
commit | a5c47c0d388b939dd578fd466aa804b7f2445390 (patch) | |
tree | a599b1995485e5907df5ebf9562c3591b6773c08 /Documentation/hwmon | |
parent | 2e9a41bbc1079776dabe42ed8113b086b99ae56c (diff) |
hwmon: Introduce SENSOR_DEVICE_ATTR_{RO, RW, WO} and variants
Introduce SENSOR_DEVICE_ATTR_{RO,RW,WO} and SENSOR_DEVICE_ATTR_2_{RO,RW,WO}
as simplified variants of SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 to
simplify the source code, improve readbility, and reduce the chance of
inconsistencies.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'Documentation/hwmon')
-rw-r--r-- | Documentation/hwmon/hwmon-kernel-api.txt | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Documentation/hwmon/hwmon-kernel-api.txt b/Documentation/hwmon/hwmon-kernel-api.txt index eb7a78aebb38..8bdefb41be30 100644 --- a/Documentation/hwmon/hwmon-kernel-api.txt +++ b/Documentation/hwmon/hwmon-kernel-api.txt | |||
@@ -299,17 +299,25 @@ functions is used. | |||
299 | The header file linux/hwmon-sysfs.h provides a number of useful macros to | 299 | The header file linux/hwmon-sysfs.h provides a number of useful macros to |
300 | declare and use hardware monitoring sysfs attributes. | 300 | declare and use hardware monitoring sysfs attributes. |
301 | 301 | ||
302 | In many cases, you can use the exsting define DEVICE_ATTR to declare such | 302 | In many cases, you can use the exsting define DEVICE_ATTR or its variants |
303 | attributes. This is feasible if an attribute has no additional context. However, | 303 | DEVICE_ATTR_{RW,RO,WO} to declare such attributes. This is feasible if an |
304 | in many cases there will be additional information such as a sensor index which | 304 | attribute has no additional context. However, in many cases there will be |
305 | will need to be passed to the sysfs attribute handling function. | 305 | additional information such as a sensor index which will need to be passed |
306 | to the sysfs attribute handling function. | ||
306 | 307 | ||
307 | SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 can be used to define attributes | 308 | SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 can be used to define attributes |
308 | which need such additional context information. SENSOR_DEVICE_ATTR requires | 309 | which need such additional context information. SENSOR_DEVICE_ATTR requires |
309 | one additional argument, SENSOR_DEVICE_ATTR_2 requires two. | 310 | one additional argument, SENSOR_DEVICE_ATTR_2 requires two. |
310 | 311 | ||
311 | SENSOR_DEVICE_ATTR defines a struct sensor_device_attribute variable. | 312 | Simplified variants of SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 are available |
312 | This structure has the following fields. | 313 | and should be used if standard attribute permissions and function names are |
314 | feasible. Standard permissions are 0644 for SENSOR_DEVICE_ATTR[_2]_RW, | ||
315 | 0444 for SENSOR_DEVICE_ATTR[_2]_RO, and 0200 for SENSOR_DEVICE_ATTR[_2]_WO. | ||
316 | Standard functions, similar to DEVICE_ATTR_{RW,RO,WO}, have _show and _store | ||
317 | appended to the provided function name. | ||
318 | |||
319 | SENSOR_DEVICE_ATTR and its variants define a struct sensor_device_attribute | ||
320 | variable. This structure has the following fields. | ||
313 | 321 | ||
314 | struct sensor_device_attribute { | 322 | struct sensor_device_attribute { |
315 | struct device_attribute dev_attr; | 323 | struct device_attribute dev_attr; |
@@ -320,8 +328,8 @@ You can use to_sensor_dev_attr to get the pointer to this structure from the | |||
320 | attribute read or write function. Its parameter is the device to which the | 328 | attribute read or write function. Its parameter is the device to which the |
321 | attribute is attached. | 329 | attribute is attached. |
322 | 330 | ||
323 | SENSOR_DEVICE_ATTR_2 defines a struct sensor_device_attribute_2 variable, | 331 | SENSOR_DEVICE_ATTR_2 and its variants define a struct sensor_device_attribute_2 |
324 | which is defined as follows. | 332 | variable, which is defined as follows. |
325 | 333 | ||
326 | struct sensor_device_attribute_2 { | 334 | struct sensor_device_attribute_2 { |
327 | struct device_attribute dev_attr; | 335 | struct device_attribute dev_attr; |