platform/x86: fujitsu-laptop: use device-specific data in LED-related code
authorMichał Kępień <kernel@kempniu.pl>
Fri, 19 May 2017 07:44:47 +0000 (09:44 +0200)
committerDarren Hart (VMware) <dvhart@infradead.org>
Sat, 3 Jun 2017 19:04:43 +0000 (12:04 -0700)
commita823f8e757a90ff5697fd9346c2dd0ede0083e89
tree42636a039672c00f1d4101d57269ea407fdf0ba4
parent84631e0c8b90411b424682eec4084006fae3f2cc
platform/x86: fujitsu-laptop: use device-specific data in LED-related code

In order to perform their duties, all LED callbacks need a pointer to
the struct acpi_device representing the FUJ02E3 ACPI device.  To limit
the use of the module-wide pointer, the same pointer should be extracted
from data that gets passed to LED callbacks as arguments.  However, LED
core does not currently support supplying driver-specific pointers to
struct led_classdev callbacks, so the latter have to be implemented a
bit differently than backlight device callbacks and platform device
attribute callbacks.  As the FUJ02E3 ACPI device is the parent device of
all LED class devices registered by fujitsu-laptop, struct acpi_device
representing the former can be extracted by following the parent link
present inside the struct device belonging to the struct led_classdev
passed as an argument to each LED callback.

To get rid of module-wide structures defining LED class devices,
allocate them dynamically using devm_kzalloc() and initialize them in
acpi_fujitsu_laptop_leds_register().

Signed-off-by: Michał Kępień <kernel@kempniu.pl>
Reviewed-by: Jonathan Woithe <jwoithe@just42.net>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
drivers/platform/x86/fujitsu-laptop.c