Skip to content

Commit

Permalink
hwmon: (core) Explain why at least two attribute groups are allocated
Browse files Browse the repository at this point in the history
A list of sysfs attribute groups is NULL-terminated, so we always need
to allocate data for at least two groups (the dynamically generated group
plus the NULL pointer). Add a comment to explain the situation.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Guenter Roeck committed Dec 10, 2016
1 parent 239552f commit b2a4cc3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hwmon/hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,

if (chip) {
struct attribute **attrs;
int ngroups = 2;
int ngroups = 2; /* terminating NULL plus &hwdev->groups */

if (groups)
for (i = 0; groups[i]; i++)
Expand Down

0 comments on commit b2a4cc3

Please sign in to comment.