diff options
| -rw-r--r-- | drivers/acpi/dock.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index bf5b79ed3613..336d94cdf2a0 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | #include <linux/notifier.h> | 29 | #include <linux/notifier.h> |
| 30 | #include <linux/platform_device.h> | ||
| 30 | #include <linux/jiffies.h> | 31 | #include <linux/jiffies.h> |
| 31 | #include <acpi/acpi_bus.h> | 32 | #include <acpi/acpi_bus.h> |
| 32 | #include <acpi/acpi_drivers.h> | 33 | #include <acpi/acpi_drivers.h> |
| @@ -39,6 +40,8 @@ MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME); | |||
| 39 | MODULE_LICENSE("GPL"); | 40 | MODULE_LICENSE("GPL"); |
| 40 | 41 | ||
| 41 | static struct atomic_notifier_head dock_notifier_list; | 42 | static struct atomic_notifier_head dock_notifier_list; |
| 43 | static struct platform_device dock_device; | ||
| 44 | static char dock_device_name[] = "dock"; | ||
| 42 | 45 | ||
| 43 | struct dock_station { | 46 | struct dock_station { |
| 44 | acpi_handle handle; | 47 | acpi_handle handle; |
| @@ -629,6 +632,15 @@ static int dock_add(acpi_handle handle) | |||
| 629 | spin_lock_init(&dock_station->hp_lock); | 632 | spin_lock_init(&dock_station->hp_lock); |
| 630 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); | 633 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); |
| 631 | 634 | ||
| 635 | /* initialize platform device stuff */ | ||
| 636 | dock_device.name = dock_device_name; | ||
| 637 | ret = platform_device_register(&dock_device); | ||
| 638 | if (ret) { | ||
| 639 | printk(KERN_ERR PREFIX "Error registering dock device\n", ret); | ||
| 640 | kfree(dock_station); | ||
| 641 | return ret; | ||
| 642 | } | ||
| 643 | |||
| 632 | /* Find dependent devices */ | 644 | /* Find dependent devices */ |
| 633 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 645 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
| 634 | ACPI_UINT32_MAX, find_dock_devices, dock_station, | 646 | ACPI_UINT32_MAX, find_dock_devices, dock_station, |
| @@ -638,7 +650,8 @@ static int dock_add(acpi_handle handle) | |||
| 638 | dd = alloc_dock_dependent_device(handle); | 650 | dd = alloc_dock_dependent_device(handle); |
| 639 | if (!dd) { | 651 | if (!dd) { |
| 640 | kfree(dock_station); | 652 | kfree(dock_station); |
| 641 | return -ENOMEM; | 653 | ret = -ENOMEM; |
| 654 | goto dock_add_err_unregister; | ||
| 642 | } | 655 | } |
| 643 | add_dock_dependent_device(dock_station, dd); | 656 | add_dock_dependent_device(dock_station, dd); |
| 644 | 657 | ||
| @@ -658,8 +671,10 @@ static int dock_add(acpi_handle handle) | |||
| 658 | return 0; | 671 | return 0; |
| 659 | 672 | ||
| 660 | dock_add_err: | 673 | dock_add_err: |
| 661 | kfree(dock_station); | ||
| 662 | kfree(dd); | 674 | kfree(dd); |
| 675 | dock_add_err_unregister: | ||
| 676 | platform_device_unregister(&dock_device); | ||
| 677 | kfree(dock_station); | ||
| 663 | return ret; | 678 | return ret; |
| 664 | } | 679 | } |
| 665 | 680 | ||
| @@ -686,6 +701,9 @@ static int dock_remove(void) | |||
| 686 | if (ACPI_FAILURE(status)) | 701 | if (ACPI_FAILURE(status)) |
| 687 | printk(KERN_ERR "Error removing notify handler\n"); | 702 | printk(KERN_ERR "Error removing notify handler\n"); |
| 688 | 703 | ||
| 704 | /* cleanup sysfs */ | ||
| 705 | platform_device_unregister(&dock_device); | ||
| 706 | |||
| 689 | /* free dock station memory */ | 707 | /* free dock station memory */ |
| 690 | kfree(dock_station); | 708 | kfree(dock_station); |
| 691 | return 0; | 709 | return 0; |
