Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20210303133845.3939403-2-geert+renesas@glider.be
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Geert Uytterhoeven and committed by
Jonathan Corbet
d944f0b1 0e2c578c

+8 -2
+8 -2
Documentation/driver-api/driver-model/device.rst
··· 63 63 64 64 Example::: 65 65 66 - static DEVICE_ATTR(type, 0444, show_type, NULL); 67 - static DEVICE_ATTR(power, 0644, show_power, store_power); 66 + static DEVICE_ATTR(type, 0444, type_show, NULL); 67 + static DEVICE_ATTR(power, 0644, power_show, power_store); 68 + 69 + Helper macros are available for common values of mode, so the above examples 70 + can be simplified to::: 71 + 72 + static DEVICE_ATTR_RO(type); 73 + static DEVICE_ATTR_RW(power); 68 74 69 75 This declares two structures of type struct device_attribute with respective 70 76 names 'dev_attr_type' and 'dev_attr_power'. These two attributes can be