Commit d944f0b1 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Jonathan Corbet

docs: driver-model: device: Add DEVICE_ATTR_{RO,RW} examples

bus.rst, driver.rst, and hwmon-kernel-api.rst refer to the
DEVICE_ATTR_* macros for devices, but device.rst does not mention them.

Add a paragraph about these helper macros, and use them in the examples.
Retain the old description, as it is still useful for less common values
of mode.  Change the names of the example "show" and "store" methods, to
match the expectations of the DEVICE_ATTR_* macros.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20210303133845.3939403-2-geert+renesas@glider.beSigned-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 0e2c578c
...@@ -63,8 +63,14 @@ Attributes are declared using a macro called DEVICE_ATTR:: ...@@ -63,8 +63,14 @@ Attributes are declared using a macro called DEVICE_ATTR::
Example::: Example:::
static DEVICE_ATTR(type, 0444, show_type, NULL); static DEVICE_ATTR(type, 0444, type_show, NULL);
static DEVICE_ATTR(power, 0644, show_power, store_power); static DEVICE_ATTR(power, 0644, power_show, power_store);
Helper macros are available for common values of mode, so the above examples
can be simplified to:::
static DEVICE_ATTR_RO(type);
static DEVICE_ATTR_RW(power);
This declares two structures of type struct device_attribute with respective This declares two structures of type struct device_attribute with respective
names 'dev_attr_type' and 'dev_attr_power'. These two attributes can be names 'dev_attr_type' and 'dev_attr_power'. These two attributes can be
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment