]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86: xo15-ebook: Fix wakeup source and GPE handling
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 8 May 2026 17:40:31 +0000 (19:40 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 11 May 2026 16:10:06 +0000 (19:10 +0300)
The device_set_wakeup_enable() call in ebook_switch_add() doesn't
actually do anything because power.can_wakeup is not set for ACPI
device objects.  Moreover, had it done anything, it would have
registered a wakeup source object that wouldn't have been used
going forward and that wakeup source would have been leaked after
driver removal because ebook_switch_remove() doesn't clean it up.
Accordingly, remove that call from ebook_switch_add().

Also prevent leaking an enabled ACPI GPE after removing the driver by
adding appropriate cleanup code to ebook_switch_remove().

Fixes: 89ca11771a4b ("OLPC XO-1.5 ebook switch driver")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/1966125.tdWV9SEqCh@rafael.j.wysocki
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/xo15-ebook.c

index 4d1b1b310cc563f4c20d62b12844a3a2c0ebefff..1568169b78727bda48ed7a25a88ab88e603469cc 100644 (file)
@@ -38,6 +38,7 @@ MODULE_DEVICE_TABLE(acpi, ebook_device_ids);
 struct ebook_switch {
        struct input_dev *input;
        char phys[32];                  /* for input device */
+       bool gpe_enabled;
 };
 
 static int ebook_send_state(struct acpi_device *device)
@@ -128,7 +129,7 @@ static int ebook_switch_add(struct acpi_device *device)
                /* Button's GPE is run-wake GPE */
                acpi_enable_gpe(device->wakeup.gpe_device,
                                device->wakeup.gpe_number);
-               device_set_wakeup_enable(&device->dev, true);
+               button->gpe_enabled = true;
        }
 
        return 0;
@@ -144,6 +145,10 @@ static void ebook_switch_remove(struct acpi_device *device)
 {
        struct ebook_switch *button = acpi_driver_data(device);
 
+       if (button->gpe_enabled)
+               acpi_disable_gpe(device->wakeup.gpe_device,
+                                device->wakeup.gpe_number);
+
        input_unregister_device(button->input);
        kfree(button);
 }