From: Hans de Goede <hdegoede@redhat.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Hans de Goede <hdegoede@redhat.com>,
Yauhen Kharuzhy <jekhor@gmail.com>,
platform-driver-x86@vger.kernel.org, linux-pwm@vger.kernel.org
Subject: [PATCH 15/19] platform/x86: lenovo-yogabook: Group WMI specific code together
Date: Sat, 29 Apr 2023 20:15:47 +0200 [thread overview]
Message-ID: <20230429181551.98201-16-hdegoede@redhat.com> (raw)
In-Reply-To: <20230429181551.98201-1-hdegoede@redhat.com>
Group WMI specific code together. Note this just moves a bunch of
code-blocks around, not a single line is changed.
This is a preparation patch for making lenovo-yogabook-wmi also work
on the Android version of the Yoga Book 1 which does not have a WMI
interface to deal with toggling the keyboard half between
touch-keyboard and wacom-digitizer mode.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/lenovo-yogabook-wmi.c | 160 ++++++++++-----------
1 file changed, 80 insertions(+), 80 deletions(-)
diff --git a/drivers/platform/x86/lenovo-yogabook-wmi.c b/drivers/platform/x86/lenovo-yogabook-wmi.c
index 9cfb2515740b..cc280ec80b8c 100644
--- a/drivers/platform/x86/lenovo-yogabook-wmi.c
+++ b/drivers/platform/x86/lenovo-yogabook-wmi.c
@@ -40,39 +40,6 @@ struct yogabook_data {
u8 brightness;
};
-/*
- * To control keyboard backlight, call the method KBLC() of the TCS1 ACPI
- * device (Goodix touchpad acts as virtual sensor keyboard).
- */
-static int yogabook_wmi_set_kbd_backlight(struct yogabook_data *data, u8 level)
-{
- struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
- struct acpi_object_list input;
- union acpi_object param;
- acpi_status status;
-
- dev_dbg(data->dev, "Set KBLC level to %u\n", level);
-
- /* Ensure keyboard touchpad is on before we call KBLC() */
- acpi_device_set_power(data->kbd_adev, ACPI_STATE_D0);
-
- input.count = 1;
- input.pointer = ¶m;
-
- param.type = ACPI_TYPE_INTEGER;
- param.integer.value = 255 - level;
-
- status = acpi_evaluate_object(acpi_device_handle(data->kbd_adev), "KBLC",
- &input, &output);
- if (ACPI_FAILURE(status)) {
- dev_err(data->dev, "Failed to call KBLC method: 0x%x\n", status);
- return status;
- }
-
- kfree(output.pointer);
- return 0;
-}
-
static void yogabook_work(struct work_struct *work)
{
struct yogabook_data *data = container_of(work, struct yogabook_data, work);
@@ -145,11 +112,6 @@ static void yogabook_toggle_digitizer_mode(struct yogabook_data *data)
schedule_work(&data->work);
}
-static void yogabook_wmi_notify(struct wmi_device *wdev, union acpi_object *dummy)
-{
- yogabook_toggle_digitizer_mode(dev_get_drvdata(&wdev->dev));
-}
-
static irqreturn_t yogabook_backside_hall_irq(int irq, void *_data)
{
struct yogabook_data *data = _data;
@@ -275,6 +237,83 @@ static int yogabook_probe(struct device *dev, struct yogabook_data *data,
return r;
}
+static void yogabook_remove(struct yogabook_data *data)
+{
+ int r = 0;
+
+ free_irq(data->backside_hall_irq, data);
+ cancel_work_sync(&data->work);
+
+ if (!test_bit(YB_KBD_IS_ON, &data->flags))
+ r |= device_reprobe(data->kbd_dev);
+
+ if (!test_bit(YB_DIGITIZER_IS_ON, &data->flags))
+ r |= device_reprobe(data->dig_dev);
+
+ if (r)
+ dev_warn(data->dev, "Reprobe of devices failed\n");
+}
+
+static int yogabook_suspend(struct device *dev)
+{
+ struct yogabook_data *data = dev_get_drvdata(dev);
+
+ set_bit(YB_SUSPENDED, &data->flags);
+
+ flush_work(&data->work);
+ return 0;
+}
+
+static int yogabook_resume(struct device *dev)
+{
+ struct yogabook_data *data = dev_get_drvdata(dev);
+
+ if (test_bit(YB_KBD_IS_ON, &data->flags))
+ data->set_kbd_backlight(data, data->brightness);
+
+ clear_bit(YB_SUSPENDED, &data->flags);
+
+ /* Check for YB_TABLET_MODE changes made during suspend */
+ schedule_work(&data->work);
+
+ return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(yogabook_pm_ops, yogabook_suspend, yogabook_resume);
+
+/*
+ * To control keyboard backlight, call the method KBLC() of the TCS1 ACPI
+ * device (Goodix touchpad acts as virtual sensor keyboard).
+ */
+static int yogabook_wmi_set_kbd_backlight(struct yogabook_data *data, u8 level)
+{
+ struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+ struct acpi_object_list input;
+ union acpi_object param;
+ acpi_status status;
+
+ dev_dbg(data->dev, "Set KBLC level to %u\n", level);
+
+ /* Ensure keyboard touchpad is on before we call KBLC() */
+ acpi_device_set_power(data->kbd_adev, ACPI_STATE_D0);
+
+ input.count = 1;
+ input.pointer = ¶m;
+
+ param.type = ACPI_TYPE_INTEGER;
+ param.integer.value = 255 - level;
+
+ status = acpi_evaluate_object(acpi_device_handle(data->kbd_adev), "KBLC",
+ &input, &output);
+ if (ACPI_FAILURE(status)) {
+ dev_err(data->dev, "Failed to call KBLC method: 0x%x\n", status);
+ return status;
+ }
+
+ kfree(output.pointer);
+ return 0;
+}
+
static int yogabook_wmi_probe(struct wmi_device *wdev, const void *context)
{
struct device *dev = &wdev->dev;
@@ -326,23 +365,6 @@ static int yogabook_wmi_probe(struct wmi_device *wdev, const void *context)
return r;
}
-static void yogabook_remove(struct yogabook_data *data)
-{
- int r = 0;
-
- free_irq(data->backside_hall_irq, data);
- cancel_work_sync(&data->work);
-
- if (!test_bit(YB_KBD_IS_ON, &data->flags))
- r |= device_reprobe(data->kbd_dev);
-
- if (!test_bit(YB_DIGITIZER_IS_ON, &data->flags))
- r |= device_reprobe(data->dig_dev);
-
- if (r)
- dev_warn(data->dev, "Reprobe of devices failed\n");
-}
-
static void yogabook_wmi_remove(struct wmi_device *wdev)
{
struct yogabook_data *data = dev_get_drvdata(&wdev->dev);
@@ -355,29 +377,9 @@ static void yogabook_wmi_remove(struct wmi_device *wdev)
acpi_dev_put(data->kbd_adev);
}
-static int yogabook_suspend(struct device *dev)
-{
- struct yogabook_data *data = dev_get_drvdata(dev);
-
- set_bit(YB_SUSPENDED, &data->flags);
-
- flush_work(&data->work);
- return 0;
-}
-
-static int yogabook_resume(struct device *dev)
+static void yogabook_wmi_notify(struct wmi_device *wdev, union acpi_object *dummy)
{
- struct yogabook_data *data = dev_get_drvdata(dev);
-
- if (test_bit(YB_KBD_IS_ON, &data->flags))
- data->set_kbd_backlight(data, data->brightness);
-
- clear_bit(YB_SUSPENDED, &data->flags);
-
- /* Check for YB_TABLET_MODE changes made during suspend */
- schedule_work(&data->work);
-
- return 0;
+ yogabook_toggle_digitizer_mode(dev_get_drvdata(&wdev->dev));
}
static const struct wmi_device_id yogabook_wmi_id_table[] = {
@@ -386,8 +388,7 @@ static const struct wmi_device_id yogabook_wmi_id_table[] = {
},
{ } /* Terminating entry */
};
-
-static DEFINE_SIMPLE_DEV_PM_OPS(yogabook_pm_ops, yogabook_suspend, yogabook_resume);
+MODULE_DEVICE_TABLE(wmi, yogabook_wmi_id_table);
static struct wmi_driver yogabook_wmi_driver = {
.driver = {
@@ -402,7 +403,6 @@ static struct wmi_driver yogabook_wmi_driver = {
};
module_wmi_driver(yogabook_wmi_driver);
-MODULE_DEVICE_TABLE(wmi, yogabook_wmi_id_table);
MODULE_AUTHOR("Yauhen Kharuzhy");
MODULE_DESCRIPTION("Lenovo Yoga Book WMI driver");
MODULE_LICENSE("GPL v2");
--
2.39.2
next prev parent reply other threads:[~2023-04-29 18:17 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-29 18:15 [PATCH 00/19] platform/x86: lenovo-yogabook: Modify to also work on Android version Hans de Goede
2023-04-29 18:15 ` [PATCH 01/19] pwm: Export pwm_add_table() / pwm_remove_table() Hans de Goede
2023-04-29 18:15 ` [PATCH 02/19] platform/x86: lenovo-yogabook: Fix work race on remove() Hans de Goede
2023-04-29 18:15 ` [PATCH 03/19] platform/x86: lenovo-yogabook: Reprobe devices " Hans de Goede
2023-04-29 18:15 ` [PATCH 04/19] platform/x86: lenovo-yogabook: Set default keyboard backligh brightness on probe() Hans de Goede
2023-04-29 18:15 ` [PATCH 05/19] platform/x86: lenovo-yogabook: Simplify gpio lookup table cleanup Hans de Goede
2023-04-29 18:15 ` [PATCH 06/19] platform/x86: lenovo-yogabook: Switch to DEFINE_SIMPLE_DEV_PM_OPS() Hans de Goede
2023-04-29 18:15 ` [PATCH 07/19] platform/x86: lenovo-yogabook: Store dev instead of wdev in drvdata struct Hans de Goede
2023-04-29 18:15 ` [PATCH 08/19] platform/x86: lenovo-yogabook: Add dev local variable to probe() Hans de Goede
2023-04-30 10:31 ` Andy Shevchenko
2023-04-29 18:15 ` [PATCH 09/19] platform/x86: lenovo-yogabook: Use PMIC LED driver for pen icon LED control Hans de Goede
2023-04-30 10:35 ` Andy Shevchenko
2023-04-29 18:15 ` [PATCH 10/19] platform/x86: lenovo-yogabook: Split probe() into generic and WMI specific parts Hans de Goede
2023-04-30 10:38 ` Andy Shevchenko
2023-04-29 18:15 ` [PATCH 11/19] platform/x86: lenovo-yogabook: Stop checking adev->power.state Hans de Goede
2023-04-29 18:15 ` [PATCH 12/19] platform/x86: lenovo-yogabook: Abstract kbd backlight setting Hans de Goede
2023-04-30 10:41 ` Andy Shevchenko
2023-04-29 18:15 ` [PATCH 13/19] platform/x86: lenovo-yogabook: Add a yogabook_toggle_digitizer_mode() helper function Hans de Goede
2023-04-29 18:15 ` [PATCH 14/19] platform/x86: lenovo-yogabook: Drop _wmi_ from remaining generic symbols Hans de Goede
2023-04-30 10:44 ` Andy Shevchenko
2023-04-29 18:15 ` Hans de Goede [this message]
2023-04-29 18:15 ` [PATCH 16/19] platform/x86: lenovo-yogabook: Add YB_KBD_BL_MAX define Hans de Goede
2023-04-29 18:15 ` [PATCH 17/19] platform/x86: lenovo-yogabook: Add platform driver support Hans de Goede
2023-04-30 10:49 ` Andy Shevchenko
2023-04-30 15:39 ` Hans de Goede
2023-04-29 18:15 ` [PATCH 18/19] platform/x86: lenovo-yogabook: Add keyboard backlight control to platform driver Hans de Goede
2023-04-30 10:51 ` Andy Shevchenko
2023-04-29 18:15 ` [PATCH 19/19] platform/x86: lenovo-yogabook: Rename lenovo-yogabook-wmi to lenovo-yogabook Hans de Goede
2023-05-03 18:16 ` [PATCH 00/19] platform/x86: lenovo-yogabook: Modify to also work on Android version Yauhen Kharuzhy
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=20230429181551.98201-16-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jekhor@gmail.com \
--cc=linux-pwm@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).