]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
platform/x86: fujitsu-laptop: switch to managed LED class devices
authorMichał Kępień <kernel@kempniu.pl>
Fri, 7 Apr 2017 13:07:11 +0000 (15:07 +0200)
committerDarren Hart (VMware) <dvhart@infradead.org>
Wed, 19 Apr 2017 19:57:19 +0000 (12:57 -0700)
commit81f6821f3f7e231b83dca1fb44bf9ddaa3313421
tree95be66176d4b4c4efb7d75a7c00d1dc28b226129
parente33ca45ca8fe130d10dda07391c967a8a3851f3a
platform/x86: fujitsu-laptop: switch to managed LED class devices

Use devm_led_classdev_register() for registering LED class devices in
order to simplify cleanup and remove LED-related fields with the
"_registered" suffix from struct fujitsu_laptop.  This also fixes a
cleanup bug: with non-managed LED class devices, if e.g. two supported
LEDs are detected, the first one gets registered successfully but the
second one does not, acpi_fujitsu_laptop_add() will return an error, but
the successfully registered LED will never get unregistered.

Change the parent device for LED class devices to the FUJ02E3 ACPI
device due to this being the logically correct relationship as LED class
devices do not depend on any facility provided by the platform device
registered by fujitsu-laptop, which was their parent until now.

Each managed LED class device is automatically unregistered when the
last reference to its parent device is dropped.  Taking the parent
change described above into account, LED class devices registered by
fujitsu-laptop will be unregistered after acpi_fujitsu_laptop_remove()
is called.  During unregistration, LED brightness is reset to LED_OFF by
LED core, so do not set the acpi_handle field of struct fujitsu_laptop
to NULL inside acpi_fujitsu_laptop_remove() to prevent call_fext_func()
from generating errors upon module removal.

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