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 ATTRIBUTE_GROUPS() example

Add a paragraph about the ATTRIBUTE_GROUPS() helper macro, and use it in
the example. Retain the old description, as it is still useful in case
of multiple groups. Change the names of the group(s) structures, to
match the ATTRIBUTE_GROUPS() macro.

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-3-geert+renesas@glider.be
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Geert Uytterhoeven and committed by
Jonathan Corbet
459d7ed8 d944f0b1

+9 -4
+9 -4
Documentation/driver-api/driver-model/device.rst
··· 82 82 NULL, 83 83 }; 84 84 85 - static struct attribute_group dev_attr_group = { 85 + static struct attribute_group dev_group = { 86 86 .attrs = dev_attrs, 87 87 }; 88 88 89 - static const struct attribute_group *dev_attr_groups[] = { 90 - &dev_attr_group, 89 + static const struct attribute_group *dev_groups[] = { 90 + &dev_group, 91 91 NULL, 92 92 }; 93 + 94 + A helper macro is available for the common case of a single group, so the 95 + above two structures can be declared using::: 96 + 97 + ATTRIBUTE_GROUPS(dev); 93 98 94 99 This array of groups can then be associated with a device by setting the 95 100 group pointer in struct device before device_register() is invoked:: 96 101 97 - dev->groups = dev_attr_groups; 102 + dev->groups = dev_groups; 98 103 device_register(dev); 99 104 100 105 The device_register() function will use the 'groups' pointer to create the