lkml.org 
[lkml]   [2021]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 09/24] platform/x86: acer-wmi: Cleanup accelerometer device handling
    Date
    From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    From: Hans de Goede <hdegoede@redhat.com>

    [ Upstream commit 9feb0763e4985ccfae632de3bb2f029cc8389842 ]

    Cleanup accelerometer device handling:
    -Drop acer_wmi_accel_destroy instead directly call input_unregister_device.
    -The information tracked by the CAP_ACCEL flag mirrors acer_wmi_accel_dev
    being NULL. Drop the CAP flag, this is a preparation change for allowing
    users to override the capability flags. Dropping the flag stops users
    from causing a NULL pointer dereference by forcing the capability.

    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20201019185628.264473-3-hdegoede@redhat.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/platform/x86/acer-wmi.c | 20 ++++++--------------
    1 file changed, 6 insertions(+), 14 deletions(-)

    diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
    index daf692fe7f77..167d0446f560 100644
    --- a/drivers/platform/x86/acer-wmi.c
    +++ b/drivers/platform/x86/acer-wmi.c
    @@ -211,7 +211,6 @@ struct hotkey_function_type_aa {
    #define ACER_CAP_BLUETOOTH BIT(2)
    #define ACER_CAP_BRIGHTNESS BIT(3)
    #define ACER_CAP_THREEG BIT(4)
    -#define ACER_CAP_ACCEL BIT(5)

    /*
    * Interface type flags
    @@ -1516,7 +1515,7 @@ static int acer_gsensor_event(void)
    struct acpi_buffer output;
    union acpi_object out_obj[5];

    - if (!has_cap(ACER_CAP_ACCEL))
    + if (!acer_wmi_accel_dev)
    return -1;

    output.length = sizeof(out_obj);
    @@ -1890,8 +1889,6 @@ static int __init acer_wmi_accel_setup(void)
    gsensor_handle = acpi_device_handle(adev);
    acpi_dev_put(adev);

    - interface->capability |= ACER_CAP_ACCEL;
    -
    acer_wmi_accel_dev = input_allocate_device();
    if (!acer_wmi_accel_dev)
    return -ENOMEM;
    @@ -1917,11 +1914,6 @@ err_free_dev:
    return err;
    }

    -static void acer_wmi_accel_destroy(void)
    -{
    - input_unregister_device(acer_wmi_accel_dev);
    -}
    -
    static int __init acer_wmi_input_setup(void)
    {
    acpi_status status;
    @@ -2076,7 +2068,7 @@ static int acer_resume(struct device *dev)
    if (has_cap(ACER_CAP_BRIGHTNESS))
    set_u32(data->brightness, ACER_CAP_BRIGHTNESS);

    - if (has_cap(ACER_CAP_ACCEL))
    + if (acer_wmi_accel_dev)
    acer_gsensor_init();

    return 0;
    @@ -2266,8 +2258,8 @@ error_device_alloc:
    error_platform_register:
    if (wmi_has_guid(ACERWMID_EVENT_GUID))
    acer_wmi_input_destroy();
    - if (has_cap(ACER_CAP_ACCEL))
    - acer_wmi_accel_destroy();
    + if (acer_wmi_accel_dev)
    + input_unregister_device(acer_wmi_accel_dev);

    return err;
    }
    @@ -2277,8 +2269,8 @@ static void __exit acer_wmi_exit(void)
    if (wmi_has_guid(ACERWMID_EVENT_GUID))
    acer_wmi_input_destroy();

    - if (has_cap(ACER_CAP_ACCEL))
    - acer_wmi_accel_destroy();
    + if (acer_wmi_accel_dev)
    + input_unregister_device(acer_wmi_accel_dev);

    remove_debugfs();
    platform_device_unregister(acer_platform_device);
    --
    2.30.1


    \
     
     \ /
      Last update: 2021-03-10 14:40    [W:5.633 / U:0.168 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site