diff options
| -rw-r--r-- | drivers/acpi/dock.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 3bd89823402a..cfcd8eeb3b2a 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
| @@ -843,8 +843,7 @@ static ssize_t show_docked(struct device *dev, | |||
| 843 | { | 843 | { |
| 844 | struct acpi_device *tmp; | 844 | struct acpi_device *tmp; |
| 845 | 845 | ||
| 846 | struct dock_station *dock_station = *((struct dock_station **) | 846 | struct dock_station *dock_station = dev->platform_data; |
| 847 | dev->platform_data); | ||
| 848 | 847 | ||
| 849 | if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp))) | 848 | if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp))) |
| 850 | return snprintf(buf, PAGE_SIZE, "1\n"); | 849 | return snprintf(buf, PAGE_SIZE, "1\n"); |
| @@ -858,8 +857,7 @@ static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); | |||
| 858 | static ssize_t show_flags(struct device *dev, | 857 | static ssize_t show_flags(struct device *dev, |
| 859 | struct device_attribute *attr, char *buf) | 858 | struct device_attribute *attr, char *buf) |
| 860 | { | 859 | { |
| 861 | struct dock_station *dock_station = *((struct dock_station **) | 860 | struct dock_station *dock_station = dev->platform_data; |
| 862 | dev->platform_data); | ||
| 863 | return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags); | 861 | return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags); |
| 864 | 862 | ||
| 865 | } | 863 | } |
| @@ -872,8 +870,7 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr, | |||
| 872 | const char *buf, size_t count) | 870 | const char *buf, size_t count) |
| 873 | { | 871 | { |
| 874 | int ret; | 872 | int ret; |
| 875 | struct dock_station *dock_station = *((struct dock_station **) | 873 | struct dock_station *dock_station = dev->platform_data; |
| 876 | dev->platform_data); | ||
| 877 | 874 | ||
| 878 | if (!count) | 875 | if (!count) |
| 879 | return -EINVAL; | 876 | return -EINVAL; |
| @@ -891,8 +888,7 @@ static ssize_t show_dock_uid(struct device *dev, | |||
| 891 | struct device_attribute *attr, char *buf) | 888 | struct device_attribute *attr, char *buf) |
| 892 | { | 889 | { |
| 893 | unsigned long long lbuf; | 890 | unsigned long long lbuf; |
| 894 | struct dock_station *dock_station = *((struct dock_station **) | 891 | struct dock_station *dock_station = dev->platform_data; |
| 895 | dev->platform_data); | ||
| 896 | acpi_status status = acpi_evaluate_integer(dock_station->handle, | 892 | acpi_status status = acpi_evaluate_integer(dock_station->handle, |
| 897 | "_UID", NULL, &lbuf); | 893 | "_UID", NULL, &lbuf); |
| 898 | if (ACPI_FAILURE(status)) | 894 | if (ACPI_FAILURE(status)) |
| @@ -905,8 +901,7 @@ static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); | |||
| 905 | static ssize_t show_dock_type(struct device *dev, | 901 | static ssize_t show_dock_type(struct device *dev, |
| 906 | struct device_attribute *attr, char *buf) | 902 | struct device_attribute *attr, char *buf) |
| 907 | { | 903 | { |
| 908 | struct dock_station *dock_station = *((struct dock_station **) | 904 | struct dock_station *dock_station = dev->platform_data; |
| 909 | dev->platform_data); | ||
| 910 | char *type; | 905 | char *type; |
| 911 | 906 | ||
| 912 | if (dock_station->flags & DOCK_IS_DOCK) | 907 | if (dock_station->flags & DOCK_IS_DOCK) |
| @@ -944,20 +939,18 @@ static struct attribute_group dock_attribute_group = { | |||
| 944 | */ | 939 | */ |
| 945 | static int dock_add(acpi_handle handle) | 940 | static int dock_add(acpi_handle handle) |
| 946 | { | 941 | { |
| 947 | int ret; | 942 | int ret, id; |
| 948 | struct dock_station *dock_station; | 943 | struct dock_station ds, *dock_station; |
| 949 | struct platform_device *dock_device; | 944 | struct platform_device *dock_device; |
| 950 | 945 | ||
| 946 | id = dock_station_count; | ||
| 951 | dock_device = | 947 | dock_device = |
| 952 | platform_device_register_simple("dock", | 948 | platform_device_register_data(NULL, "dock", |
| 953 | dock_station_count, NULL, 0); | 949 | id, &ds, sizeof(ds)); |
| 954 | if (IS_ERR(dock_device)) | 950 | if (IS_ERR(dock_device)) |
| 955 | return PTR_ERR(dock_device); | 951 | return PTR_ERR(dock_device); |
| 956 | 952 | ||
| 957 | /* allocate & initialize the dock_station private data */ | 953 | dock_station = dock_device->dev.platform_data; |
| 958 | dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL); | ||
| 959 | if (!dock_station) | ||
| 960 | return -ENOMEM; | ||
| 961 | dock_station->handle = handle; | 954 | dock_station->handle = handle; |
| 962 | dock_station->dock_device = dock_device; | 955 | dock_station->dock_device = dock_device; |
| 963 | dock_station->last_dock_time = jiffies - HZ; | 956 | dock_station->last_dock_time = jiffies - HZ; |
| @@ -968,9 +961,6 @@ static int dock_add(acpi_handle handle) | |||
| 968 | mutex_init(&dock_station->hp_lock); | 961 | mutex_init(&dock_station->hp_lock); |
| 969 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); | 962 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); |
| 970 | 963 | ||
| 971 | platform_device_add_data(dock_device, &dock_station, | ||
| 972 | sizeof(struct dock_station *)); | ||
| 973 | |||
| 974 | /* we want the dock device to send uevents */ | 964 | /* we want the dock device to send uevents */ |
| 975 | dev_set_uevent_suppress(&dock_device->dev, 0); | 965 | dev_set_uevent_suppress(&dock_device->dev, 0); |
| 976 | 966 | ||
| @@ -1003,9 +993,6 @@ err_rmgroup: | |||
| 1003 | sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group); | 993 | sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group); |
| 1004 | err_unregister: | 994 | err_unregister: |
| 1005 | platform_device_unregister(dock_device); | 995 | platform_device_unregister(dock_device); |
| 1006 | out: | ||
| 1007 | kfree(dock_station); | ||
| 1008 | dock_station = NULL; | ||
| 1009 | printk(KERN_ERR "%s encountered error %d\n", __func__, ret); | 996 | printk(KERN_ERR "%s encountered error %d\n", __func__, ret); |
| 1010 | return ret; | 997 | return ret; |
| 1011 | } | 998 | } |
| @@ -1026,13 +1013,12 @@ static int dock_remove(struct dock_station *dock_station) | |||
| 1026 | list) | 1013 | list) |
| 1027 | kfree(dd); | 1014 | kfree(dd); |
| 1028 | 1015 | ||
| 1016 | list_del(&dock_station->sibling); | ||
| 1017 | |||
| 1029 | /* cleanup sysfs */ | 1018 | /* cleanup sysfs */ |
| 1030 | sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group); | 1019 | sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group); |
| 1031 | platform_device_unregister(dock_device); | 1020 | platform_device_unregister(dock_device); |
| 1032 | 1021 | ||
| 1033 | /* free dock station memory */ | ||
| 1034 | kfree(dock_station); | ||
| 1035 | dock_station = NULL; | ||
| 1036 | return 0; | 1022 | return 0; |
| 1037 | } | 1023 | } |
| 1038 | 1024 | ||
