diff options
author | Alan Jenkins <alan-jenkins@tuffmail.co.uk> | 2009-12-03 02:45:06 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-12-09 15:54:32 -0500 |
commit | 9db106be554288df5a0a7c56c20257a4391b9738 (patch) | |
tree | cce9268fbff23c07124b172c14edf47f64312fc8 /drivers/platform/x86/eeepc-laptop.c | |
parent | 22072e92a038d2ee5848b3e54499ecab730c722c (diff) |
eeepc-laptop: move platform device initialisation to a separate function
This moves the sysfs_create_group() call just after the declaration of
the platform device attributes. It should make it easier to examine
the implementation of the platform device attributes in isolation
from the rest of the code. (The next commit will apply this pattern
to all of the sub-devices as well).
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.c | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index 3f9b286b854e..f4f67967aae2 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -509,6 +509,38 @@ static struct attribute_group platform_attribute_group = { | |||
509 | .attrs = platform_attributes | 509 | .attrs = platform_attributes |
510 | }; | 510 | }; |
511 | 511 | ||
512 | static int eeepc_platform_init(void) | ||
513 | { | ||
514 | int result; | ||
515 | |||
516 | platform_device = platform_device_alloc(EEEPC_HOTK_FILE, -1); | ||
517 | if (!platform_device) | ||
518 | return -ENOMEM; | ||
519 | |||
520 | result = platform_device_add(platform_device); | ||
521 | if (result) | ||
522 | goto fail_platform_device; | ||
523 | |||
524 | result = sysfs_create_group(&platform_device->dev.kobj, | ||
525 | &platform_attribute_group); | ||
526 | if (result) | ||
527 | goto fail_sysfs; | ||
528 | return 0; | ||
529 | |||
530 | fail_sysfs: | ||
531 | platform_device_del(platform_device); | ||
532 | fail_platform_device: | ||
533 | platform_device_put(platform_device); | ||
534 | return result; | ||
535 | } | ||
536 | |||
537 | static void eeepc_platform_exit(void) | ||
538 | { | ||
539 | sysfs_remove_group(&platform_device->dev.kobj, | ||
540 | &platform_attribute_group); | ||
541 | platform_device_unregister(platform_device); | ||
542 | } | ||
543 | |||
512 | /* | 544 | /* |
513 | * LEDs | 545 | * LEDs |
514 | */ | 546 | */ |
@@ -1276,22 +1308,12 @@ static int __devinit eeepc_hotk_add(struct acpi_device *device) | |||
1276 | 1308 | ||
1277 | result = eeepc_hotk_init(); | 1309 | result = eeepc_hotk_init(); |
1278 | if (result) | 1310 | if (result) |
1279 | goto fail_platform_device1; | 1311 | goto fail_platform; |
1280 | eeepc_enable_camera(); | 1312 | eeepc_enable_camera(); |
1281 | 1313 | ||
1282 | /* Register platform stuff */ | 1314 | result = eeepc_platform_init(); |
1283 | platform_device = platform_device_alloc(EEEPC_HOTK_FILE, -1); | ||
1284 | if (!platform_device) { | ||
1285 | result = -ENOMEM; | ||
1286 | goto fail_platform_device1; | ||
1287 | } | ||
1288 | result = platform_device_add(platform_device); | ||
1289 | if (result) | 1315 | if (result) |
1290 | goto fail_platform_device2; | 1316 | goto fail_platform; |
1291 | result = sysfs_create_group(&platform_device->dev.kobj, | ||
1292 | &platform_attribute_group); | ||
1293 | if (result) | ||
1294 | goto fail_sysfs; | ||
1295 | 1317 | ||
1296 | dev = &platform_device->dev; | 1318 | dev = &platform_device->dev; |
1297 | 1319 | ||
@@ -1300,8 +1322,7 @@ static int __devinit eeepc_hotk_add(struct acpi_device *device) | |||
1300 | if (result) | 1322 | if (result) |
1301 | goto fail_backlight; | 1323 | goto fail_backlight; |
1302 | } else | 1324 | } else |
1303 | pr_info("Backlight controlled by ACPI video " | 1325 | pr_info("Backlight controlled by ACPI video driver\n"); |
1304 | "driver\n"); | ||
1305 | 1326 | ||
1306 | result = eeepc_input_init(dev); | 1327 | result = eeepc_input_init(dev); |
1307 | if (result) | 1328 | if (result) |
@@ -1330,13 +1351,8 @@ fail_hwmon: | |||
1330 | fail_input: | 1351 | fail_input: |
1331 | eeepc_backlight_exit(); | 1352 | eeepc_backlight_exit(); |
1332 | fail_backlight: | 1353 | fail_backlight: |
1333 | sysfs_remove_group(&platform_device->dev.kobj, | 1354 | eeepc_platform_exit(); |
1334 | &platform_attribute_group); | 1355 | fail_platform: |
1335 | fail_sysfs: | ||
1336 | platform_device_del(platform_device); | ||
1337 | fail_platform_device2: | ||
1338 | platform_device_put(platform_device); | ||
1339 | fail_platform_device1: | ||
1340 | kfree(ehotk); | 1356 | kfree(ehotk); |
1341 | 1357 | ||
1342 | return result; | 1358 | return result; |
@@ -1349,9 +1365,7 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type) | |||
1349 | eeepc_input_exit(); | 1365 | eeepc_input_exit(); |
1350 | eeepc_hwmon_exit(); | 1366 | eeepc_hwmon_exit(); |
1351 | eeepc_led_exit(); | 1367 | eeepc_led_exit(); |
1352 | sysfs_remove_group(&platform_device->dev.kobj, | 1368 | eeepc_platform_exit(); |
1353 | &platform_attribute_group); | ||
1354 | platform_device_unregister(platform_device); | ||
1355 | 1369 | ||
1356 | kfree(ehotk); | 1370 | kfree(ehotk); |
1357 | return 0; | 1371 | return 0; |