Commit f69cfdd2 authored by Alex Chiang's avatar Alex Chiang Committed by Len Brown

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: default avatarAlex Chiang <achiang@hp.com>
Acked-by: default avatarShaohua Li <shaohua.li@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 5f46c2f2
...@@ -93,40 +93,30 @@ struct dock_dependent_device { ...@@ -93,40 +93,30 @@ struct dock_dependent_device {
* Dock Dependent device functions * * Dock Dependent device functions *
*****************************************************************************/ *****************************************************************************/
/** /**
* alloc_dock_dependent_device - allocate and init a dependent device * add_dock_dependent_device - associate a device with the dock station
* @handle: the acpi_handle of the dependent device * @ds: The dock station
* @handle: handle of the dependent device
* *
* Allocate memory for a dependent device structure for a device referenced * Add the dependent device to the dock's dependent device list.
* by the acpi handle
*/ */
static struct dock_dependent_device * static int
alloc_dock_dependent_device(acpi_handle handle) add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
{ {
struct dock_dependent_device *dd; struct dock_dependent_device *dd;
dd = kzalloc(sizeof(*dd), GFP_KERNEL); dd = kzalloc(sizeof(*dd), GFP_KERNEL);
if (dd) { if (!dd)
dd->handle = handle; return -ENOMEM;
INIT_LIST_HEAD(&dd->list);
INIT_LIST_HEAD(&dd->hotplug_list); dd->handle = handle;
} INIT_LIST_HEAD(&dd->list);
return dd; INIT_LIST_HEAD(&dd->hotplug_list);
}
/**
* add_dock_dependent_device - associate a device with the dock station
* @ds: The dock station
* @dd: The dependent device
*
* Add the dependent device to the dock's dependent device list.
*/
static void
add_dock_dependent_device(struct dock_station *ds,
struct dock_dependent_device *dd)
{
spin_lock(&ds->dd_lock); spin_lock(&ds->dd_lock);
list_add_tail(&dd->list, &ds->dependent_devices); list_add_tail(&dd->list, &ds->dependent_devices);
spin_unlock(&ds->dd_lock); spin_unlock(&ds->dd_lock);
return 0;
} }
/** /**
...@@ -826,7 +816,6 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -826,7 +816,6 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
acpi_status status; acpi_status status;
acpi_handle tmp, parent; acpi_handle tmp, parent;
struct dock_station *ds = context; struct dock_station *ds = context;
struct dock_dependent_device *dd;
status = acpi_bus_get_ejd(handle, &tmp); status = acpi_bus_get_ejd(handle, &tmp);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -840,11 +829,9 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -840,11 +829,9 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
goto fdd_out; goto fdd_out;
} }
if (tmp == ds->handle) { if (tmp == ds->handle)
dd = alloc_dock_dependent_device(handle); add_dock_dependent_device(ds, handle);
if (dd)
add_dock_dependent_device(ds, dd);
}
fdd_out: fdd_out:
return AE_OK; return AE_OK;
} }
...@@ -959,7 +946,6 @@ static struct attribute_group dock_attribute_group = { ...@@ -959,7 +946,6 @@ static struct attribute_group dock_attribute_group = {
static int dock_add(acpi_handle handle) static int dock_add(acpi_handle handle)
{ {
int ret; int ret;
struct dock_dependent_device *dd;
struct dock_station *dock_station; struct dock_station *dock_station;
struct platform_device *dock_device; struct platform_device *dock_device;
...@@ -1008,12 +994,9 @@ static int dock_add(acpi_handle handle) ...@@ -1008,12 +994,9 @@ static int dock_add(acpi_handle handle)
NULL); NULL);
/* add the dock station as a device dependent on itself */ /* add the dock station as a device dependent on itself */
dd = alloc_dock_dependent_device(handle); ret = add_dock_dependent_device(dock_station, handle);
if (!dd) { if (ret)
ret = -ENOMEM;
goto err_rmgroup; goto err_rmgroup;
}
add_dock_dependent_device(dock_station, dd);
dock_station_count++; dock_station_count++;
list_add(&dock_station->sibling, &dock_stations); list_add(&dock_station->sibling, &dock_stations);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment