• Michał Kępień's avatar
    platform/x86: fujitsu-laptop: switch to managed LED class devices · 81f6821f
    Michał Kępień authored
    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: default avatarMichał Kępień <kernel@kempniu.pl>
    Reviewed-by: default avatarJonathan Woithe <jwoithe@just42.net>
    Signed-off-by: default avatarDarren Hart (VMware) <dvhart@infradead.org>
    81f6821f
fujitsu-laptop.c 28.2 KB