summaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2023-04-30 18:58:03 +0200
committerHans de Goede <hdegoede@redhat.com>2023-05-09 12:33:37 +0200
commit1c4a2e08a84effc7bd20fb68df3455c930ee175e (patch)
tree4ef42cf95665bcd635523a1de62cceb61046fa62 /drivers/platform
parentfe2d4d792e854de5c6efea5d9d036c07e11661d3 (diff)
downloadlinux-stable-1c4a2e08a84effc7bd20fb68df3455c930ee175e.tar.gz
linux-stable-1c4a2e08a84effc7bd20fb68df3455c930ee175e.tar.bz2
linux-stable-1c4a2e08a84effc7bd20fb68df3455c930ee175e.zip
platform/x86: lenovo-yogabook: Group WMI specific code together
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> Link: https://lore.kernel.org/r/20230430165807.472798-16-hdegoede@redhat.com
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/lenovo-yogabook-wmi.c162
1 files changed, 81 insertions, 81 deletions
diff --git a/drivers/platform/x86/lenovo-yogabook-wmi.c b/drivers/platform/x86/lenovo-yogabook-wmi.c
index aee9e37b27fe..d04603c3a2ad 100644
--- a/drivers/platform/x86/lenovo-yogabook-wmi.c
+++ b/drivers/platform/x86/lenovo-yogabook-wmi.c
@@ -39,40 +39,6 @@ struct yogabook_data {
uint8_t 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,
- uint8_t 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 = &param;
-
- 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 +111,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;
@@ -266,6 +227,84 @@ error_free_irq:
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,
+ uint8_t 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 = &param;
+
+ 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;
@@ -314,23 +353,6 @@ error_put_devs:
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);
@@ -343,29 +365,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[] = {
@@ -374,8 +376,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 = {
@@ -390,7 +391,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");