summaryrefslogtreecommitdiffstats
path: root/Documentation/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2016-12-27 18:28:19 -0500
committerGuenter Roeck <linux@roeck-us.net>2018-12-16 18:13:22 -0500
commita5c47c0d388b939dd578fd466aa804b7f2445390 (patch)
treea599b1995485e5907df5ebf9562c3591b6773c08 /Documentation/hwmon
parent2e9a41bbc1079776dabe42ed8113b086b99ae56c (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.txt24
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.
299The header file linux/hwmon-sysfs.h provides a number of useful macros to 299The header file linux/hwmon-sysfs.h provides a number of useful macros to
300declare and use hardware monitoring sysfs attributes. 300declare and use hardware monitoring sysfs attributes.
301 301
302In many cases, you can use the exsting define DEVICE_ATTR to declare such 302In many cases, you can use the exsting define DEVICE_ATTR or its variants
303attributes. This is feasible if an attribute has no additional context. However, 303DEVICE_ATTR_{RW,RO,WO} to declare such attributes. This is feasible if an
304in many cases there will be additional information such as a sensor index which 304attribute has no additional context. However, in many cases there will be
305will need to be passed to the sysfs attribute handling function. 305additional information such as a sensor index which will need to be passed
306to the sysfs attribute handling function.
306 307
307SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 can be used to define attributes 308SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 can be used to define attributes
308which need such additional context information. SENSOR_DEVICE_ATTR requires 309which need such additional context information. SENSOR_DEVICE_ATTR requires
309one additional argument, SENSOR_DEVICE_ATTR_2 requires two. 310one additional argument, SENSOR_DEVICE_ATTR_2 requires two.
310 311
311SENSOR_DEVICE_ATTR defines a struct sensor_device_attribute variable. 312Simplified variants of SENSOR_DEVICE_ATTR and SENSOR_DEVICE_ATTR_2 are available
312This structure has the following fields. 313and should be used if standard attribute permissions and function names are
314feasible. Standard permissions are 0644 for SENSOR_DEVICE_ATTR[_2]_RW,
3150444 for SENSOR_DEVICE_ATTR[_2]_RO, and 0200 for SENSOR_DEVICE_ATTR[_2]_WO.
316Standard functions, similar to DEVICE_ATTR_{RW,RO,WO}, have _show and _store
317appended to the provided function name.
318
319SENSOR_DEVICE_ATTR and its variants define a struct sensor_device_attribute
320variable. This structure has the following fields.
313 321
314struct sensor_device_attribute { 322struct 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
320attribute read or write function. Its parameter is the device to which the 328attribute read or write function. Its parameter is the device to which the
321attribute is attached. 329attribute is attached.
322 330
323SENSOR_DEVICE_ATTR_2 defines a struct sensor_device_attribute_2 variable, 331SENSOR_DEVICE_ATTR_2 and its variants define a struct sensor_device_attribute_2
324which is defined as follows. 332variable, which is defined as follows.
325 333
326struct sensor_device_attribute_2 { 334struct sensor_device_attribute_2 {
327 struct device_attribute dev_attr; 335 struct device_attribute dev_attr;