|
@@ -144,9 +144,6 @@ struct eeepc_wmi {
|
|
struct eeepc_wmi_debug debug;
|
|
struct eeepc_wmi_debug debug;
|
|
};
|
|
};
|
|
|
|
|
|
-/* Only used in eeepc_wmi_init() and eeepc_wmi_exit() */
|
|
|
|
-static struct platform_device *platform_device;
|
|
|
|
-
|
|
|
|
static int eeepc_wmi_input_init(struct eeepc_wmi *eeepc)
|
|
static int eeepc_wmi_input_init(struct eeepc_wmi *eeepc)
|
|
{
|
|
{
|
|
int err;
|
|
int err;
|
|
@@ -932,33 +929,12 @@ static int eeepc_wmi_sysfs_init(struct platform_device *device)
|
|
*/
|
|
*/
|
|
static int __init eeepc_wmi_platform_init(struct eeepc_wmi *eeepc)
|
|
static int __init eeepc_wmi_platform_init(struct eeepc_wmi *eeepc)
|
|
{
|
|
{
|
|
- int err;
|
|
|
|
-
|
|
|
|
- eeepc->platform_device = platform_device_alloc(EEEPC_WMI_FILE, -1);
|
|
|
|
- if (!eeepc->platform_device)
|
|
|
|
- return -ENOMEM;
|
|
|
|
- platform_set_drvdata(eeepc->platform_device, eeepc);
|
|
|
|
-
|
|
|
|
- err = platform_device_add(eeepc->platform_device);
|
|
|
|
- if (err)
|
|
|
|
- goto fail_platform_device;
|
|
|
|
-
|
|
|
|
- err = eeepc_wmi_sysfs_init(eeepc->platform_device);
|
|
|
|
- if (err)
|
|
|
|
- goto fail_sysfs;
|
|
|
|
- return 0;
|
|
|
|
-
|
|
|
|
-fail_sysfs:
|
|
|
|
- platform_device_del(eeepc->platform_device);
|
|
|
|
-fail_platform_device:
|
|
|
|
- platform_device_put(eeepc->platform_device);
|
|
|
|
- return err;
|
|
|
|
|
|
+ return eeepc_wmi_sysfs_init(eeepc->platform_device);
|
|
}
|
|
}
|
|
|
|
|
|
static void eeepc_wmi_platform_exit(struct eeepc_wmi *eeepc)
|
|
static void eeepc_wmi_platform_exit(struct eeepc_wmi *eeepc)
|
|
{
|
|
{
|
|
eeepc_wmi_sysfs_exit(eeepc->platform_device);
|
|
eeepc_wmi_sysfs_exit(eeepc->platform_device);
|
|
- platform_device_unregister(eeepc->platform_device);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -1094,7 +1070,7 @@ static void eeepc_dmi_check(struct eeepc_wmi *eeepc)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-static struct platform_device * __init eeepc_wmi_add(void)
|
|
|
|
|
|
+static int __init eeepc_wmi_add(struct platform_device *pdev)
|
|
{
|
|
{
|
|
struct eeepc_wmi *eeepc;
|
|
struct eeepc_wmi *eeepc;
|
|
acpi_status status;
|
|
acpi_status status;
|
|
@@ -1102,15 +1078,14 @@ static struct platform_device * __init eeepc_wmi_add(void)
|
|
|
|
|
|
eeepc = kzalloc(sizeof(struct eeepc_wmi), GFP_KERNEL);
|
|
eeepc = kzalloc(sizeof(struct eeepc_wmi), GFP_KERNEL);
|
|
if (!eeepc)
|
|
if (!eeepc)
|
|
- return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
+ return -ENOMEM;
|
|
|
|
+
|
|
|
|
+ eeepc->platform_device = pdev;
|
|
|
|
+ platform_set_drvdata(eeepc->platform_device, eeepc);
|
|
|
|
|
|
eeepc->hotplug_wireless = hotplug_wireless;
|
|
eeepc->hotplug_wireless = hotplug_wireless;
|
|
eeepc_dmi_check(eeepc);
|
|
eeepc_dmi_check(eeepc);
|
|
|
|
|
|
- /*
|
|
|
|
- * Register the platform device first. It is used as a parent for the
|
|
|
|
- * sub-devices below.
|
|
|
|
- */
|
|
|
|
err = eeepc_wmi_platform_init(eeepc);
|
|
err = eeepc_wmi_platform_init(eeepc);
|
|
if (err)
|
|
if (err)
|
|
goto fail_platform;
|
|
goto fail_platform;
|
|
@@ -1147,7 +1122,7 @@ static struct platform_device * __init eeepc_wmi_add(void)
|
|
if (err)
|
|
if (err)
|
|
goto fail_debugfs;
|
|
goto fail_debugfs;
|
|
|
|
|
|
- return eeepc->platform_device;
|
|
|
|
|
|
+ return 0;
|
|
|
|
|
|
fail_debugfs:
|
|
fail_debugfs:
|
|
wmi_remove_notify_handler(EEEPC_WMI_EVENT_GUID);
|
|
wmi_remove_notify_handler(EEEPC_WMI_EVENT_GUID);
|
|
@@ -1163,10 +1138,10 @@ fail_input:
|
|
eeepc_wmi_platform_exit(eeepc);
|
|
eeepc_wmi_platform_exit(eeepc);
|
|
fail_platform:
|
|
fail_platform:
|
|
kfree(eeepc);
|
|
kfree(eeepc);
|
|
- return ERR_PTR(err);
|
|
|
|
|
|
+ return err;
|
|
}
|
|
}
|
|
|
|
|
|
-static int eeepc_wmi_remove(struct platform_device *device)
|
|
|
|
|
|
+static int __exit eeepc_wmi_remove(struct platform_device *device)
|
|
{
|
|
{
|
|
struct eeepc_wmi *eeepc;
|
|
struct eeepc_wmi *eeepc;
|
|
|
|
|
|
@@ -1232,6 +1207,7 @@ static const struct dev_pm_ops eeepc_pm_ops = {
|
|
};
|
|
};
|
|
|
|
|
|
static struct platform_driver platform_driver = {
|
|
static struct platform_driver platform_driver = {
|
|
|
|
+ .remove = __exit_p(eeepc_wmi_remove),
|
|
.driver = {
|
|
.driver = {
|
|
.name = EEEPC_WMI_FILE,
|
|
.name = EEEPC_WMI_FILE,
|
|
.owner = THIS_MODULE,
|
|
.owner = THIS_MODULE,
|
|
@@ -1260,10 +1236,8 @@ static int __init eeepc_wmi_check_atkd(void)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
-static int __init eeepc_wmi_init(void)
|
|
|
|
|
|
+static int __init eeepc_wmi_probe(struct platform_device *pdev)
|
|
{
|
|
{
|
|
- int err;
|
|
|
|
-
|
|
|
|
if (!wmi_has_guid(EEEPC_WMI_EVENT_GUID) ||
|
|
if (!wmi_has_guid(EEEPC_WMI_EVENT_GUID) ||
|
|
!wmi_has_guid(EEEPC_WMI_MGMT_GUID)) {
|
|
!wmi_has_guid(EEEPC_WMI_MGMT_GUID)) {
|
|
pr_warning("No known WMI GUID found\n");
|
|
pr_warning("No known WMI GUID found\n");
|
|
@@ -1280,29 +1254,24 @@ static int __init eeepc_wmi_init(void)
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
- platform_device = eeepc_wmi_add();
|
|
|
|
- if (IS_ERR(platform_device)) {
|
|
|
|
- err = PTR_ERR(platform_device);
|
|
|
|
- goto fail_eeepc_wmi;
|
|
|
|
- }
|
|
|
|
|
|
+ return eeepc_wmi_add(pdev);
|
|
|
|
+}
|
|
|
|
|
|
- err = platform_driver_register(&platform_driver);
|
|
|
|
- if (err) {
|
|
|
|
- pr_warning("Unable to register platform driver\n");
|
|
|
|
- goto fail_platform_driver;
|
|
|
|
- }
|
|
|
|
|
|
+static struct platform_device *platform_device;
|
|
|
|
|
|
|
|
+static int __init eeepc_wmi_init(void)
|
|
|
|
+{
|
|
|
|
+ platform_device = platform_create_bundle(&platform_driver,
|
|
|
|
+ eeepc_wmi_probe,
|
|
|
|
+ NULL, 0, NULL, 0);
|
|
|
|
+ if (IS_ERR(platform_device))
|
|
|
|
+ return PTR_ERR(platform_device);
|
|
return 0;
|
|
return 0;
|
|
-
|
|
|
|
-fail_platform_driver:
|
|
|
|
- eeepc_wmi_remove(platform_device);
|
|
|
|
-fail_eeepc_wmi:
|
|
|
|
- return err;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static void __exit eeepc_wmi_exit(void)
|
|
static void __exit eeepc_wmi_exit(void)
|
|
{
|
|
{
|
|
- eeepc_wmi_remove(platform_device);
|
|
|
|
|
|
+ platform_device_unregister(platform_device);
|
|
platform_driver_unregister(&platform_driver);
|
|
platform_driver_unregister(&platform_driver);
|
|
}
|
|
}
|
|
|
|
|