From: Hans de Goede <hdegoede@redhat.com>
To: Mark Gross <mgross@linux.intel.com>, Lee Chun-Yi <jlee@suse.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
Andy Shevchenko <andy@infradead.org>,
platform-driver-x86@vger.kernel.org
Subject: [PATCH 3/6] platform/x86: acer-wmi: Cleanup accelerometer device handling
Date: Mon, 19 Oct 2020 20:56:25 +0200 [thread overview]
Message-ID: <20201019185628.264473-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20201019185628.264473-1-hdegoede@redhat.com>
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.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
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 2f69d418ed3b..f728cb5e5115 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -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
@@ -1510,7 +1509,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);
@@ -1884,8 +1883,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;
@@ -1911,11 +1908,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;
@@ -2070,7 +2062,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;
@@ -2260,8 +2252,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;
}
@@ -2271,8 +2263,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.28.0
next prev parent reply other threads:[~2020-10-19 18:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 18:56 [PATCH 1/6] platform/x86: acer-wmi: Drop no-op set_quirks call from find_quirks Hans de Goede
2020-10-19 18:56 ` [PATCH 2/6] platform/x86: acer-wmi: Cleanup ACER_CAP_FOO defines Hans de Goede
2020-10-26 15:10 ` Andy Shevchenko
2020-10-19 18:56 ` Hans de Goede [this message]
2020-10-19 18:56 ` [PATCH 4/6] platform/x86: acer-wmi: Add new force_caps module parameter Hans de Goede
2020-10-19 18:56 ` [PATCH 5/6] platform/x86: acer-wmi: Add ACER_CAP_SET_FUNCTION_MODE capability flag Hans de Goede
2020-10-19 18:56 ` [PATCH 6/6] platform/x86: acer-wmi: Add support for SW_TABLET_MODE on Switch devices Hans de Goede
2020-10-26 15:15 ` [PATCH 1/6] platform/x86: acer-wmi: Drop no-op set_quirks call from find_quirks Andy Shevchenko
2020-10-26 15:43 ` Hans de Goede
2020-10-26 16:55 ` Andy Shevchenko
2020-10-28 12:11 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201019185628.264473-3-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy@infradead.org \
--cc=jlee@suse.com \
--cc=mgross@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.