aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorAlex Chiang <achiang@hp.com>2009-10-19 17:14:29 -0400
committerLen Brown <len.brown@intel.com>2009-12-16 03:02:10 -0500
commitf69cfdd24ac40ab7bbd00d6ad85e003da755e3a0 (patch)
tree87e35e597e293d67e1ec0f4209b78b69a87cd33e /drivers/acpi
parent5f46c2f25cfbb5faca7550738ac42c4d1491ddc8 (diff)
ACPI: dock: combine add|alloc_dock_dependent_device (v2)
There's no real need to have a separate allocation step when adding a dock dependent device. Combining the two functions is both logical and helps with legibility. Signed-off-by: Alex Chiang <achiang@hp.com> Acked-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/dock.c55
1 files changed, 19 insertions, 36 deletions
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 4f2aa98e2cee..ee9829b47e20 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -93,40 +93,30 @@ struct dock_dependent_device {
93 * Dock Dependent device functions * 93 * Dock Dependent device functions *
94 *****************************************************************************/ 94 *****************************************************************************/
95/** 95/**
96 * alloc_dock_dependent_device - allocate and init a dependent device 96 * add_dock_dependent_device - associate a device with the dock station
97 * @handle: the acpi_handle of the dependent device 97 * @ds: The dock station
98 * @handle: handle of the dependent device
98 * 99 *
99 * Allocate memory for a dependent device structure for a device referenced 100 * Add the dependent device to the dock's dependent device list.
100 * by the acpi handle
101 */ 101 */
102static struct dock_dependent_device * 102static int
103alloc_dock_dependent_device(acpi_handle handle) 103add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
104{ 104{
105 struct dock_dependent_device *dd; 105 struct dock_dependent_device *dd;
106 106
107 dd = kzalloc(sizeof(*dd), GFP_KERNEL); 107 dd = kzalloc(sizeof(*dd), GFP_KERNEL);
108 if (dd) { 108 if (!dd)
109 dd->handle = handle; 109 return -ENOMEM;
110 INIT_LIST_HEAD(&dd->list); 110
111 INIT_LIST_HEAD(&dd->hotplug_list); 111 dd->handle = handle;
112 } 112 INIT_LIST_HEAD(&dd->list);
113 return dd; 113 INIT_LIST_HEAD(&dd->hotplug_list);
114}
115 114
116/**
117 * add_dock_dependent_device - associate a device with the dock station
118 * @ds: The dock station
119 * @dd: The dependent device
120 *
121 * Add the dependent device to the dock's dependent device list.
122 */
123static void
124add_dock_dependent_device(struct dock_station *ds,
125 struct dock_dependent_device *dd)
126{
127 spin_lock(&ds->dd_lock); 115 spin_lock(&ds->dd_lock);
128 list_add_tail(&dd->list, &ds->dependent_devices); 116 list_add_tail(&dd->list, &ds->dependent_devices);
129 spin_unlock(&ds->dd_lock); 117 spin_unlock(&ds->dd_lock);
118
119 return 0;
130} 120}
131 121
132/** 122/**
@@ -826,7 +816,6 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
826 acpi_status status; 816 acpi_status status;
827 acpi_handle tmp, parent; 817 acpi_handle tmp, parent;
828 struct dock_station *ds = context; 818 struct dock_station *ds = context;
829 struct dock_dependent_device *dd;
830 819
831 status = acpi_bus_get_ejd(handle, &tmp); 820 status = acpi_bus_get_ejd(handle, &tmp);
832 if (ACPI_FAILURE(status)) { 821 if (ACPI_FAILURE(status)) {
@@ -840,11 +829,9 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
840 goto fdd_out; 829 goto fdd_out;
841 } 830 }
842 831
843 if (tmp == ds->handle) { 832 if (tmp == ds->handle)
844 dd = alloc_dock_dependent_device(handle); 833 add_dock_dependent_device(ds, handle);
845 if (dd) 834
846 add_dock_dependent_device(ds, dd);
847 }
848fdd_out: 835fdd_out:
849 return AE_OK; 836 return AE_OK;
850} 837}
@@ -959,7 +946,6 @@ static struct attribute_group dock_attribute_group = {
959static int dock_add(acpi_handle handle) 946static int dock_add(acpi_handle handle)
960{ 947{
961 int ret; 948 int ret;
962 struct dock_dependent_device *dd;
963 struct dock_station *dock_station; 949 struct dock_station *dock_station;
964 struct platform_device *dock_device; 950 struct platform_device *dock_device;
965 951
@@ -1008,12 +994,9 @@ static int dock_add(acpi_handle handle)
1008 NULL); 994 NULL);
1009 995
1010 /* add the dock station as a device dependent on itself */ 996 /* add the dock station as a device dependent on itself */
1011 dd = alloc_dock_dependent_device(handle); 997 ret = add_dock_dependent_device(dock_station, handle);
1012 if (!dd) { 998 if (ret)
1013 ret = -ENOMEM;
1014 goto err_rmgroup; 999 goto err_rmgroup;
1015 }
1016 add_dock_dependent_device(dock_station, dd);
1017 1000
1018 dock_station_count++; 1001 dock_station_count++;
1019 list_add(&dock_station->sibling, &dock_stations); 1002 list_add(&dock_station->sibling, &dock_stations);