|
@@ -1,4 +1,4 @@
|
|
-From dfe3b509e98f3f8b1df867927490e3862655b7a4 Mon Sep 17 00:00:00 2001
|
|
|
|
|
|
+From 9ec51d0d15ab736230deeeb6a9699163666e159e Mon Sep 17 00:00:00 2001
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
Date: Sun, 16 Aug 2020 23:39:56 +0200
|
|
Date: Sun, 16 Aug 2020 23:39:56 +0200
|
|
Subject: [PATCH 6/6] surface-gpe
|
|
Subject: [PATCH 6/6] surface-gpe
|
|
@@ -6,8 +6,8 @@ Subject: [PATCH 6/6] surface-gpe
|
|
---
|
|
---
|
|
drivers/platform/x86/Kconfig | 9 +
|
|
drivers/platform/x86/Kconfig | 9 +
|
|
drivers/platform/x86/Makefile | 1 +
|
|
drivers/platform/x86/Makefile | 1 +
|
|
- drivers/platform/x86/surface_gpe.c | 299 +++++++++++++++++++++++++++++
|
|
|
|
- 3 files changed, 309 insertions(+)
|
|
|
|
|
|
+ drivers/platform/x86/surface_gpe.c | 303 +++++++++++++++++++++++++++++
|
|
|
|
+ 3 files changed, 313 insertions(+)
|
|
create mode 100644 drivers/platform/x86/surface_gpe.c
|
|
create mode 100644 drivers/platform/x86/surface_gpe.c
|
|
|
|
|
|
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
|
|
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
|
|
@@ -44,10 +44,10 @@ index 5156523b58639..ef0c3fcab3194 100644
|
|
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
|
|
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
|
|
diff --git a/drivers/platform/x86/surface_gpe.c b/drivers/platform/x86/surface_gpe.c
|
|
diff --git a/drivers/platform/x86/surface_gpe.c b/drivers/platform/x86/surface_gpe.c
|
|
new file mode 100644
|
|
new file mode 100644
|
|
-index 0000000000000..4c141fef7a5f4
|
|
|
|
|
|
+index 0000000000000..10e563f253b9e
|
|
--- /dev/null
|
|
--- /dev/null
|
|
+++ b/drivers/platform/x86/surface_gpe.c
|
|
+++ b/drivers/platform/x86/surface_gpe.c
|
|
-@@ -0,0 +1,299 @@
|
|
|
|
|
|
+@@ -0,0 +1,303 @@
|
|
+// SPDX-License-Identifier: GPL-2.0-or-later
|
|
+// SPDX-License-Identifier: GPL-2.0-or-later
|
|
+/*
|
|
+/*
|
|
+ * Surface GPE/Lid driver to enable wakeup from suspend via the lid by
|
|
+ * Surface GPE/Lid driver to enable wakeup from suspend via the lid by
|
|
@@ -60,29 +60,36 @@ index 0000000000000..4c141fef7a5f4
|
|
+#include <linux/module.h>
|
|
+#include <linux/module.h>
|
|
+#include <linux/platform_device.h>
|
|
+#include <linux/platform_device.h>
|
|
+
|
|
+
|
|
|
|
++/*
|
|
|
|
++ * Note: The GPE numbers for the lid devices found below have been obtained
|
|
|
|
++ * from ACPI/the DSDT table, specifically from the GPE handler for the
|
|
|
|
++ * lid.
|
|
|
|
++ */
|
|
+
|
|
+
|
|
-+struct surface_lid_device {
|
|
|
|
-+ u32 gpe_number;
|
|
|
|
-+};
|
|
|
|
-+
|
|
|
|
-+static const struct surface_lid_device lid_device_l17 = {
|
|
|
|
-+ .gpe_number = 0x17,
|
|
|
|
|
|
++static const struct property_entry lid_device_props_l17[] = {
|
|
|
|
++ PROPERTY_ENTRY_U32("gpe", 0x17),
|
|
|
|
++ {},
|
|
+};
|
|
+};
|
|
+
|
|
+
|
|
-+static const struct surface_lid_device lid_device_l4D = {
|
|
|
|
-+ .gpe_number = 0x4D,
|
|
|
|
|
|
++static const struct property_entry lid_device_props_l4D[] = {
|
|
|
|
++ PROPERTY_ENTRY_U32("gpe", 0x4D),
|
|
|
|
++ {},
|
|
+};
|
|
+};
|
|
+
|
|
+
|
|
-+static const struct surface_lid_device lid_device_l4F = {
|
|
|
|
-+ .gpe_number = 0x4F,
|
|
|
|
|
|
++static const struct property_entry lid_device_props_l4F[] = {
|
|
|
|
++ PROPERTY_ENTRY_U32("gpe", 0x4F),
|
|
|
|
++ {},
|
|
+};
|
|
+};
|
|
+
|
|
+
|
|
-+static const struct surface_lid_device lid_device_l57 = {
|
|
|
|
-+ .gpe_number = 0x57,
|
|
|
|
|
|
++static const struct property_entry lid_device_props_l57[] = {
|
|
|
|
++ PROPERTY_ENTRY_U32("gpe", 0x57),
|
|
|
|
++ {},
|
|
+};
|
|
+};
|
|
+
|
|
+
|
|
-+
|
|
|
|
-+// Note: When changing this don't forget to change the MODULE_ALIAS below.
|
|
|
|
|
|
++/*
|
|
|
|
++ * Note: When changing this, don't forget to check that the MODULE_ALIAS below
|
|
|
|
++ * still fits.
|
|
|
|
++ */
|
|
+static const struct dmi_system_id dmi_lid_device_table[] = {
|
|
+static const struct dmi_system_id dmi_lid_device_table[] = {
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Pro 4",
|
|
+ .ident = "Surface Pro 4",
|
|
@@ -90,7 +97,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 4"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 4"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l17,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l17,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Pro 5",
|
|
+ .ident = "Surface Pro 5",
|
|
@@ -102,7 +109,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1796"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1796"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l4F,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l4F,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Pro 5 (LTE)",
|
|
+ .ident = "Surface Pro 5 (LTE)",
|
|
@@ -114,7 +121,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1807"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1807"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l4F,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l4F,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Pro 6",
|
|
+ .ident = "Surface Pro 6",
|
|
@@ -122,7 +129,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 6"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 6"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l4F,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l4F,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Pro 7",
|
|
+ .ident = "Surface Pro 7",
|
|
@@ -130,7 +137,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 7"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 7"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l4D,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l4D,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Book 1",
|
|
+ .ident = "Surface Book 1",
|
|
@@ -138,7 +145,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l17,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l17,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Book 2",
|
|
+ .ident = "Surface Book 2",
|
|
@@ -146,7 +153,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book 2"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book 2"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l17,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l17,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Book 3",
|
|
+ .ident = "Surface Book 3",
|
|
@@ -154,7 +161,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book 3"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book 3"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l4D,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l4D,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Laptop 1",
|
|
+ .ident = "Surface Laptop 1",
|
|
@@ -162,7 +169,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l57,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l57,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Laptop 2",
|
|
+ .ident = "Surface Laptop 2",
|
|
@@ -170,7 +177,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop 2"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop 2"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l57,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l57,
|
|
+ },
|
|
+ },
|
|
+ {
|
|
+ {
|
|
+ .ident = "Surface Laptop 3 (Intel 13\")",
|
|
+ .ident = "Surface Laptop 3 (Intel 13\")",
|
|
@@ -182,16 +189,18 @@ index 0000000000000..4c141fef7a5f4
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Laptop_3_1867:1868"),
|
|
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Laptop_3_1867:1868"),
|
|
+ },
|
|
+ },
|
|
-+ .driver_data = (void *)&lid_device_l4D,
|
|
|
|
|
|
++ .driver_data = (void *)lid_device_props_l4D,
|
|
+ },
|
|
+ },
|
|
+ { }
|
|
+ { }
|
|
+};
|
|
+};
|
|
+
|
|
+
|
|
|
|
++struct surface_lid_device {
|
|
|
|
++ u32 gpe_number;
|
|
|
|
++};
|
|
+
|
|
+
|
|
-+static int surface_lid_enable_wakeup(struct device *dev,
|
|
|
|
-+ const struct surface_lid_device *lid,
|
|
|
|
-+ bool enable)
|
|
|
|
|
|
++static int surface_lid_enable_wakeup(struct device *dev, bool enable)
|
|
+{
|
|
+{
|
|
|
|
++ const struct surface_lid_device *lid = dev_get_drvdata(dev);
|
|
+ int action = enable ? ACPI_GPE_ENABLE : ACPI_GPE_DISABLE;
|
|
+ int action = enable ? ACPI_GPE_ENABLE : ACPI_GPE_DISABLE;
|
|
+ acpi_status status;
|
|
+ acpi_status status;
|
|
+
|
|
+
|
|
@@ -204,50 +213,52 @@ index 0000000000000..4c141fef7a5f4
|
|
+ return 0;
|
|
+ return 0;
|
|
+}
|
|
+}
|
|
+
|
|
+
|
|
-+
|
|
|
|
+static int surface_gpe_suspend(struct device *dev)
|
|
+static int surface_gpe_suspend(struct device *dev)
|
|
+{
|
|
+{
|
|
-+ const struct surface_lid_device *lid;
|
|
|
|
-+
|
|
|
|
-+ lid = dev_get_platdata(dev);
|
|
|
|
-+ return surface_lid_enable_wakeup(dev, lid, true);
|
|
|
|
|
|
++ return surface_lid_enable_wakeup(dev, true);
|
|
+}
|
|
+}
|
|
+
|
|
+
|
|
+static int surface_gpe_resume(struct device *dev)
|
|
+static int surface_gpe_resume(struct device *dev)
|
|
+{
|
|
+{
|
|
-+ const struct surface_lid_device *lid;
|
|
|
|
-+
|
|
|
|
-+ lid = dev_get_platdata(dev);
|
|
|
|
-+ return surface_lid_enable_wakeup(dev, lid, false);
|
|
|
|
|
|
++ return surface_lid_enable_wakeup(dev, false);
|
|
+}
|
|
+}
|
|
+
|
|
+
|
|
+static SIMPLE_DEV_PM_OPS(surface_gpe_pm, surface_gpe_suspend, surface_gpe_resume);
|
|
+static SIMPLE_DEV_PM_OPS(surface_gpe_pm, surface_gpe_suspend, surface_gpe_resume);
|
|
+
|
|
+
|
|
-+
|
|
|
|
+static int surface_gpe_probe(struct platform_device *pdev)
|
|
+static int surface_gpe_probe(struct platform_device *pdev)
|
|
+{
|
|
+{
|
|
-+ const struct surface_lid_device *lid;
|
|
|
|
|
|
++ struct surface_lid_device *lid;
|
|
|
|
++ u32 gpe_number;
|
|
+ int status;
|
|
+ int status;
|
|
+
|
|
+
|
|
-+ lid = dev_get_platdata(&pdev->dev);
|
|
|
|
-+ if (!lid)
|
|
|
|
|
|
++ status = device_property_read_u32(&pdev->dev, "gpe", &gpe_number);
|
|
|
|
++ if (status)
|
|
+ return -ENODEV;
|
|
+ return -ENODEV;
|
|
+
|
|
+
|
|
-+ status = acpi_mark_gpe_for_wake(NULL, lid->gpe_number);
|
|
|
|
|
|
++ status = acpi_mark_gpe_for_wake(NULL, gpe_number);
|
|
+ if (status) {
|
|
+ if (status) {
|
|
+ dev_err(&pdev->dev, "failed to mark GPE for wake: %d\n", status);
|
|
+ dev_err(&pdev->dev, "failed to mark GPE for wake: %d\n", status);
|
|
+ return -EINVAL;
|
|
+ return -EINVAL;
|
|
+ }
|
|
+ }
|
|
+
|
|
+
|
|
-+ status = acpi_enable_gpe(NULL, lid->gpe_number);
|
|
|
|
|
|
++ status = acpi_enable_gpe(NULL, gpe_number);
|
|
+ if (status) {
|
|
+ if (status) {
|
|
+ dev_err(&pdev->dev, "failed to enable GPE: %d\n", status);
|
|
+ dev_err(&pdev->dev, "failed to enable GPE: %d\n", status);
|
|
+ return -EINVAL;
|
|
+ return -EINVAL;
|
|
+ }
|
|
+ }
|
|
+
|
|
+
|
|
-+ status = surface_lid_enable_wakeup(&pdev->dev, lid, false);
|
|
|
|
|
|
++ lid = devm_kzalloc(&pdev->dev, sizeof(struct surface_lid_device),
|
|
|
|
++ GFP_KERNEL);
|
|
|
|
++ if (!lid)
|
|
|
|
++ return -ENOMEM;
|
|
|
|
++
|
|
|
|
++ lid->gpe_number = gpe_number;
|
|
|
|
++ platform_set_drvdata(pdev, lid);
|
|
|
|
++
|
|
|
|
++ status = surface_lid_enable_wakeup(&pdev->dev, false);
|
|
+ if (status) {
|
|
+ if (status) {
|
|
-+ acpi_disable_gpe(NULL, lid->gpe_number);
|
|
|
|
|
|
++ acpi_disable_gpe(NULL, gpe_number);
|
|
|
|
++ platform_set_drvdata(pdev, NULL);
|
|
+ return status;
|
|
+ return status;
|
|
+ }
|
|
+ }
|
|
+
|
|
+
|
|
@@ -256,12 +267,13 @@ index 0000000000000..4c141fef7a5f4
|
|
+
|
|
+
|
|
+static int surface_gpe_remove(struct platform_device *pdev)
|
|
+static int surface_gpe_remove(struct platform_device *pdev)
|
|
+{
|
|
+{
|
|
-+ struct surface_lid_device *lid = dev_get_platdata(&pdev->dev);
|
|
|
|
|
|
++ struct surface_lid_device *lid = dev_get_drvdata(&pdev->dev);
|
|
+
|
|
+
|
|
+ /* restore default behavior without this module */
|
|
+ /* restore default behavior without this module */
|
|
-+ surface_lid_enable_wakeup(&pdev->dev, lid, false);
|
|
|
|
|
|
++ surface_lid_enable_wakeup(&pdev->dev, false);
|
|
+ acpi_disable_gpe(NULL, lid->gpe_number);
|
|
+ acpi_disable_gpe(NULL, lid->gpe_number);
|
|
+
|
|
+
|
|
|
|
++ platform_set_drvdata(pdev, NULL);
|
|
+ return 0;
|
|
+ return 0;
|
|
+}
|
|
+}
|
|
+
|
|
+
|
|
@@ -275,14 +287,14 @@ index 0000000000000..4c141fef7a5f4
|
|
+ },
|
|
+ },
|
|
+};
|
|
+};
|
|
+
|
|
+
|
|
-+
|
|
|
|
+static struct platform_device *surface_gpe_device;
|
|
+static struct platform_device *surface_gpe_device;
|
|
+
|
|
+
|
|
+static int __init surface_gpe_init(void)
|
|
+static int __init surface_gpe_init(void)
|
|
+{
|
|
+{
|
|
+ const struct dmi_system_id *match;
|
|
+ const struct dmi_system_id *match;
|
|
-+ const struct surface_lid_device *lid;
|
|
|
|
|
|
++ const struct property_entry *props;
|
|
+ struct platform_device *pdev;
|
|
+ struct platform_device *pdev;
|
|
|
|
++ struct fwnode_handle *fwnode;
|
|
+ int status;
|
|
+ int status;
|
|
+
|
|
+
|
|
+ match = dmi_first_match(dmi_lid_device_table);
|
|
+ match = dmi_first_match(dmi_lid_device_table);
|
|
@@ -291,7 +303,7 @@ index 0000000000000..4c141fef7a5f4
|
|
+ return 0;
|
|
+ return 0;
|
|
+ }
|
|
+ }
|
|
+
|
|
+
|
|
-+ lid = match->driver_data;
|
|
|
|
|
|
++ props = match->driver_data;
|
|
+
|
|
+
|
|
+ status = platform_driver_register(&surface_gpe_driver);
|
|
+ status = platform_driver_register(&surface_gpe_driver);
|
|
+ if (status)
|
|
+ if (status)
|
|
@@ -303,13 +315,15 @@ index 0000000000000..4c141fef7a5f4
|
|
+ return -ENOMEM;
|
|
+ return -ENOMEM;
|
|
+ }
|
|
+ }
|
|
+
|
|
+
|
|
-+ status = platform_device_add_data(pdev, lid, sizeof(*lid));
|
|
|
|
-+ if (status) {
|
|
|
|
|
|
++ fwnode = fwnode_create_software_node(props, NULL);
|
|
|
|
++ if (IS_ERR(fwnode)) {
|
|
+ platform_device_put(pdev);
|
|
+ platform_device_put(pdev);
|
|
+ platform_driver_unregister(&surface_gpe_driver);
|
|
+ platform_driver_unregister(&surface_gpe_driver);
|
|
-+ return status;
|
|
|
|
|
|
++ return PTR_ERR(fwnode);
|
|
+ }
|
|
+ }
|
|
+
|
|
+
|
|
|
|
++ pdev->dev.fwnode = fwnode;
|
|
|
|
++
|
|
+ status = platform_device_add(pdev);
|
|
+ status = platform_device_add(pdev);
|
|
+ if (status) {
|
|
+ if (status) {
|
|
+ platform_device_put(pdev);
|
|
+ platform_device_put(pdev);
|
|
@@ -320,33 +334,23 @@ index 0000000000000..4c141fef7a5f4
|
|
+ surface_gpe_device = pdev;
|
|
+ surface_gpe_device = pdev;
|
|
+ return 0;
|
|
+ return 0;
|
|
+}
|
|
+}
|
|
|
|
++module_init(surface_gpe_init);
|
|
+
|
|
+
|
|
+static void __exit surface_gpe_exit(void)
|
|
+static void __exit surface_gpe_exit(void)
|
|
+{
|
|
+{
|
|
+ if (!surface_gpe_device)
|
|
+ if (!surface_gpe_device)
|
|
+ return;
|
|
+ return;
|
|
+
|
|
+
|
|
|
|
++ fwnode_remove_software_node(surface_gpe_device->dev.fwnode);
|
|
+ platform_device_unregister(surface_gpe_device);
|
|
+ platform_device_unregister(surface_gpe_device);
|
|
+ platform_driver_unregister(&surface_gpe_driver);
|
|
+ platform_driver_unregister(&surface_gpe_driver);
|
|
+}
|
|
+}
|
|
-+
|
|
|
|
-+module_init(surface_gpe_init);
|
|
|
|
+module_exit(surface_gpe_exit);
|
|
+module_exit(surface_gpe_exit);
|
|
+
|
|
+
|
|
+MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>");
|
|
+MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>");
|
|
+MODULE_DESCRIPTION("Surface GPE/Lid Driver");
|
|
+MODULE_DESCRIPTION("Surface GPE/Lid Driver");
|
|
+MODULE_LICENSE("GPL");
|
|
+MODULE_LICENSE("GPL");
|
|
-+
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfacePro:*");
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfacePro4:*");
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfacePro6:*");
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfacePro7:*");
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceBook:*");
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceBook2:*");
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceBook3:*");
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceLaptop:*");
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceLaptop2:*");
|
|
|
|
-+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceLaptop3:*");
|
|
|
|
|
|
++MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurface*:*");
|
|
--
|
|
--
|
|
2.28.0
|
|
2.28.0
|
|
|
|
|