• Michał Kępień's avatar
    platform/x86: fujitsu-laptop: track the last instantiated FUJ02E3 ACPI device · ca0d9eab
    Michał Kępień authored
    fujitsu-laptop registers two ACPI drivers: one for ACPI device FUJ02B1
    enabling backlight control and another for ACPI device FUJ02E3 which
    handles various other stuff (hotkeys, LEDs, etc.)  In a perfect world,
    private data used by each of these drivers would be neatly encapsulated
    in a structure specific to a given driver instance.  Sadly, firmware
    present on some Fujitsu laptops makes that impossible by exposing
    backlight power control (which is what the FUJ02B1 ACPI device should
    take care of) through the FUJ02E3 ACPI device.  This means the backlight
    driver needs a way to access an ACPI device it is not bound to.  When
    the backlight driver is extracted into a separate module, it will not be
    able to rely on a module-wide variable any more and such access will
    happen through an API exposed by fujitsu-laptop.
    
    For all known firmwares out in the wild, it seems that whenever the
    FUJ02B1 ACPI device is present, it is always accompanied by a single
    instance of the FUJ02E3 ACPI device.  We could independently grab an
    ACPI handle to the FUJ02E3 ACPI device from the backlight driver, but
    that would require using a hardcoded absolute path to that ACPI device,
    which is subject to change.  It is easier to simply store a module-wide
    pointer to the last (most likely only) FUJ02E3 ACPI device found, make
    the aforementioned API use it and cover our bases by warning the user if
    firmware exposes multiple FUJ02E3 ACPI devices.
    
    Introducing this pointer in advance allows us to get rid of the
    acpi_handle field of struct fujitsu_bl and also enables a bit more
    step-by-step migration to a device-specific implementation of
    call_fext_func().
    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>
    ca0d9eab
fujitsu-laptop.c 27.8 KB