Prechádzať zdrojové kódy

hwmon: (core) Explain why at least two attribute groups are allocated

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>
Guenter Roeck 9 rokov pred
rodič
commit
b2a4cc3a06
1 zmenil súbory, kde vykonal 1 pridanie a 1 odobranie
  1. 1 1
      drivers/hwmon/hwmon.c

+ 1 - 1
drivers/hwmon/hwmon.c

@@ -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++)