aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/eeepc-laptop.c
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2009-12-03 02:45:05 -0500
committerLen Brown <len.brown@intel.com>2009-12-09 15:54:32 -0500
commit22072e92a038d2ee5848b3e54499ecab730c722c (patch)
treeb154ef826c24c3a1970e752361a96146f83259ac /drivers/platform/x86/eeepc-laptop.c
parentbf9598bcd5a73385ced7880ea09998a545e03dd8 (diff)
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>
Diffstat (limited to 'drivers/platform/x86/eeepc-laptop.c')
-rw-r--r--drivers/platform/x86/eeepc-laptop.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index b4eacb68a19d..3f9b286b854e 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -1276,13 +1276,10 @@ static int __devinit eeepc_hotk_add(struct acpi_device *device)
1276 1276
1277 result = eeepc_hotk_init(); 1277 result = eeepc_hotk_init();
1278 if (result) 1278 if (result)
1279 goto fail_platform_driver; 1279 goto fail_platform_device1;
1280 eeepc_enable_camera(); 1280 eeepc_enable_camera();
1281 1281
1282 /* Register platform stuff */ 1282 /* Register platform stuff */
1283 result = platform_driver_register(&platform_driver);
1284 if (result)
1285 goto fail_platform_driver;
1286 platform_device = platform_device_alloc(EEEPC_HOTK_FILE, -1); 1283 platform_device = platform_device_alloc(EEEPC_HOTK_FILE, -1);
1287 if (!platform_device) { 1284 if (!platform_device) {
1288 result = -ENOMEM; 1285 result = -ENOMEM;
@@ -1340,8 +1337,6 @@ fail_sysfs:
1340fail_platform_device2: 1337fail_platform_device2:
1341 platform_device_put(platform_device); 1338 platform_device_put(platform_device);
1342fail_platform_device1: 1339fail_platform_device1:
1343 platform_driver_unregister(&platform_driver);
1344fail_platform_driver:
1345 kfree(ehotk); 1340 kfree(ehotk);
1346 1341
1347 return result; 1342 return result;
@@ -1357,7 +1352,6 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type)
1357 sysfs_remove_group(&platform_device->dev.kobj, 1352 sysfs_remove_group(&platform_device->dev.kobj,
1358 &platform_attribute_group); 1353 &platform_attribute_group);
1359 platform_device_unregister(platform_device); 1354 platform_device_unregister(platform_device);
1360 platform_driver_unregister(&platform_driver);
1361 1355
1362 kfree(ehotk); 1356 kfree(ehotk);
1363 return 0; 1357 return 0;
@@ -1367,19 +1361,30 @@ static int __init eeepc_laptop_init(void)
1367{ 1361{
1368 int result; 1362 int result;
1369 1363
1370 result = acpi_bus_register_driver(&eeepc_hotk_driver); 1364 result = platform_driver_register(&platform_driver);
1371 if (result < 0) 1365 if (result < 0)
1372 return result; 1366 return result;
1367
1368 result = acpi_bus_register_driver(&eeepc_hotk_driver);
1369 if (result < 0)
1370 goto fail_acpi_driver;
1373 if (!ehotk) { 1371 if (!ehotk) {
1374 acpi_bus_unregister_driver(&eeepc_hotk_driver); 1372 result = -ENODEV;
1375 return -ENODEV; 1373 goto fail_no_device;
1376 } 1374 }
1377 return 0; 1375 return 0;
1376
1377fail_no_device:
1378 acpi_bus_unregister_driver(&eeepc_hotk_driver);
1379fail_acpi_driver:
1380 platform_driver_unregister(&platform_driver);
1381 return result;
1378} 1382}
1379 1383
1380static void __exit eeepc_laptop_exit(void) 1384static void __exit eeepc_laptop_exit(void)
1381{ 1385{
1382 acpi_bus_unregister_driver(&eeepc_hotk_driver); 1386 acpi_bus_unregister_driver(&eeepc_hotk_driver);
1387 platform_driver_unregister(&platform_driver);
1383} 1388}
1384 1389
1385module_init(eeepc_laptop_init); 1390module_init(eeepc_laptop_init);