mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 05:55:44 +02:00
platform/x86: acer-wmi: Cleanup accelerometer device handling
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
This commit is contained in:
parent
7c936d8d26
commit
9feb0763e4
|
|
@ -210,7 +210,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
|
||||
|
|
@ -1509,7 +1508,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);
|
||||
|
|
@ -1883,8 +1882,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;
|
||||
|
|
@ -1910,11 +1907,6 @@ static int __init acer_wmi_accel_setup(void)
|
|||
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;
|
||||
|
|
@ -2069,7 +2061,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;
|
||||
|
|
@ -2259,8 +2251,8 @@ static int __init acer_wmi_init(void)
|
|||
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;
|
||||
}
|
||||
|
|
@ -2270,8 +2262,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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user