From: Guenter Roeck Date: Mon, 17 Oct 2016 00:11:52 +0000 (-0700) Subject: hwmon: (core) Explain why at least two attribute groups are allocated X-Git-Tag: v4.10-rc1~140^2~15 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b2a4cc3a060da0de17ab1e854cef89f5e74e2064;p=karo-tx-linux.git 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 --- diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index a0b5becf91fa..8dc0466a9307 100644 --- a/drivers/hwmon/hwmon.c +++ b/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++)