hwmon: (core) Simplify sysfs attribute name allocation
authorGuenter Roeck <linux@roeck-us.net>
Sun, 16 Oct 2016 17:52:04 +0000 (10:52 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jan 2020 09:24:37 +0000 (10:24 +0100)
commitcb4412e39224f96d616d288a7c83ddafdf3e98bd
treec92cce694f227b2617e1d1316dccb726fb52bfcd
parentc5e1aae008fd1180bb9a263fbdc5ee18a08cfff0
hwmon: (core) Simplify sysfs attribute name allocation

commit 3a412d5e4a1c831723d0aaf305f1cf9a78ad9c90 upstream.

Allocating the sysfs attribute name only if needed and only with the
required minimum length looks optimal, but does not take the additional
overhead for both devm_ data structures and the allocation header itself
into account. This also results in unnecessary memory fragmentation.
Move the sysfs name string into struct hwmon_device_attribute and give it
a sufficient length to reduce this overhead.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwmon/hwmon.c