eeepc-laptop: move platform driver registration out of eeepc_hotk_add()
Strictly speaking we should register the platform driver exactly once, whether there are zero, one, or multiple matching acpi devices. Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
bf9598bcd5
commit
22072e92a0
1 changed files with 15 additions and 10 deletions
|
@ -1276,13 +1276,10 @@ static int __devinit eeepc_hotk_add(struct acpi_device *device)
|
||||||
|
|
||||||
result = eeepc_hotk_init();
|
result = eeepc_hotk_init();
|
||||||
if (result)
|
if (result)
|
||||||
goto fail_platform_driver;
|
goto fail_platform_device1;
|
||||||
eeepc_enable_camera();
|
eeepc_enable_camera();
|
||||||
|
|
||||||
/* Register platform stuff */
|
/* Register platform stuff */
|
||||||
result = platform_driver_register(&platform_driver);
|
|
||||||
if (result)
|
|
||||||
goto fail_platform_driver;
|
|
||||||
platform_device = platform_device_alloc(EEEPC_HOTK_FILE, -1);
|
platform_device = platform_device_alloc(EEEPC_HOTK_FILE, -1);
|
||||||
if (!platform_device) {
|
if (!platform_device) {
|
||||||
result = -ENOMEM;
|
result = -ENOMEM;
|
||||||
|
@ -1340,8 +1337,6 @@ fail_sysfs:
|
||||||
fail_platform_device2:
|
fail_platform_device2:
|
||||||
platform_device_put(platform_device);
|
platform_device_put(platform_device);
|
||||||
fail_platform_device1:
|
fail_platform_device1:
|
||||||
platform_driver_unregister(&platform_driver);
|
|
||||||
fail_platform_driver:
|
|
||||||
kfree(ehotk);
|
kfree(ehotk);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -1357,7 +1352,6 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type)
|
||||||
sysfs_remove_group(&platform_device->dev.kobj,
|
sysfs_remove_group(&platform_device->dev.kobj,
|
||||||
&platform_attribute_group);
|
&platform_attribute_group);
|
||||||
platform_device_unregister(platform_device);
|
platform_device_unregister(platform_device);
|
||||||
platform_driver_unregister(&platform_driver);
|
|
||||||
|
|
||||||
kfree(ehotk);
|
kfree(ehotk);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1367,19 +1361,30 @@ static int __init eeepc_laptop_init(void)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = acpi_bus_register_driver(&eeepc_hotk_driver);
|
result = platform_driver_register(&platform_driver);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
result = acpi_bus_register_driver(&eeepc_hotk_driver);
|
||||||
|
if (result < 0)
|
||||||
|
goto fail_acpi_driver;
|
||||||
if (!ehotk) {
|
if (!ehotk) {
|
||||||
acpi_bus_unregister_driver(&eeepc_hotk_driver);
|
result = -ENODEV;
|
||||||
return -ENODEV;
|
goto fail_no_device;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
fail_no_device:
|
||||||
|
acpi_bus_unregister_driver(&eeepc_hotk_driver);
|
||||||
|
fail_acpi_driver:
|
||||||
|
platform_driver_unregister(&platform_driver);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit eeepc_laptop_exit(void)
|
static void __exit eeepc_laptop_exit(void)
|
||||||
{
|
{
|
||||||
acpi_bus_unregister_driver(&eeepc_hotk_driver);
|
acpi_bus_unregister_driver(&eeepc_hotk_driver);
|
||||||
|
platform_driver_unregister(&platform_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(eeepc_laptop_init);
|
module_init(eeepc_laptop_init);
|
||||||
|
|
Loading…
Add table
Reference in a new issue