aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-12-20 18:36:47 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-03 07:09:39 -0500
commit636458de36f1fb4cdd318387d2f45604e451b17a (patch)
tree484db3b8ea7d4d9cba63422654d790880908a1b6 /drivers/acpi
parent02f57c67a8677ae55dcdd256a2a7abaf41e4cc1f (diff)
ACPI: Remove the arguments of acpi_bus_add() that are not used
Notice that acpi_bus_add() uses only 2 of its 4 arguments and redefine its header to match the body. Update all of its callers as necessary and observe that this leads to quite a number of removed lines of code (Linus will like that). Add a kerneldoc comment documenting acpi_bus_add() and wonder how its callers make wrong assumptions about the second argument (make note to self to take care of that later). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Yinghai Lu <yinghai@kernel.org> Acked-by: Toshi Kani <toshi.kani@hp.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_memhotplug.c19
-rw-r--r--drivers/acpi/container.c16
-rw-r--r--drivers/acpi/dock.c13
-rw-r--r--drivers/acpi/processor_driver.c24
-rw-r--r--drivers/acpi/scan.c34
5 files changed, 26 insertions, 80 deletions
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index eb30e5ab4cab..d0a7da704d49 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -157,34 +157,17 @@ static int
157acpi_memory_get_device(acpi_handle handle, 157acpi_memory_get_device(acpi_handle handle,
158 struct acpi_memory_device **mem_device) 158 struct acpi_memory_device **mem_device)
159{ 159{
160 acpi_status status;
161 acpi_handle phandle;
162 struct acpi_device *device = NULL; 160 struct acpi_device *device = NULL;
163 struct acpi_device *pdevice = NULL;
164 int result; 161 int result;
165 162
166
167 if (!acpi_bus_get_device(handle, &device) && device) 163 if (!acpi_bus_get_device(handle, &device) && device)
168 goto end; 164 goto end;
169 165
170 status = acpi_get_parent(handle, &phandle);
171 if (ACPI_FAILURE(status)) {
172 ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent"));
173 return -EINVAL;
174 }
175
176 /* Get the parent device */
177 result = acpi_bus_get_device(phandle, &pdevice);
178 if (result) {
179 acpi_handle_warn(phandle, "Cannot get acpi bus device\n");
180 return -EINVAL;
181 }
182
183 /* 166 /*
184 * Now add the notified device. This creates the acpi_device 167 * Now add the notified device. This creates the acpi_device
185 * and invokes .add function 168 * and invokes .add function
186 */ 169 */
187 result = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); 170 result = acpi_bus_add(handle, &device);
188 if (result) { 171 if (result) {
189 acpi_handle_warn(handle, "Cannot add acpi bus\n"); 172 acpi_handle_warn(handle, "Cannot add acpi bus\n");
190 return -EINVAL; 173 return -EINVAL;
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 98b85e3e4781..0688f83bc436 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -135,20 +135,6 @@ static int acpi_container_remove(struct acpi_device *device, int type)
135 return status; 135 return status;
136} 136}
137 137
138static int container_device_add(struct acpi_device **device, acpi_handle handle)
139{
140 acpi_handle phandle;
141 struct acpi_device *pdev;
142
143 if (acpi_get_parent(handle, &phandle))
144 return -ENODEV;
145
146 if (acpi_bus_get_device(phandle, &pdev))
147 return -ENODEV;
148
149 return acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE);
150}
151
152static void container_notify_cb(acpi_handle handle, u32 type, void *context) 138static void container_notify_cb(acpi_handle handle, u32 type, void *context)
153{ 139{
154 struct acpi_device *device = NULL; 140 struct acpi_device *device = NULL;
@@ -180,7 +166,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
180 if (!ACPI_FAILURE(status) || device) 166 if (!ACPI_FAILURE(status) || device)
181 break; 167 break;
182 168
183 result = container_device_add(&device, handle); 169 result = acpi_bus_add(handle, &device);
184 if (result) { 170 if (result) {
185 acpi_handle_warn(handle, "Failed to add container\n"); 171 acpi_handle_warn(handle, "Failed to add container\n");
186 break; 172 break;
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index f32bd47b35e0..ff30582d2e1d 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -310,8 +310,6 @@ static int dock_present(struct dock_station *ds)
310static struct acpi_device * dock_create_acpi_device(acpi_handle handle) 310static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
311{ 311{
312 struct acpi_device *device; 312 struct acpi_device *device;
313 struct acpi_device *parent_device;
314 acpi_handle parent;
315 int ret; 313 int ret;
316 314
317 if (acpi_bus_get_device(handle, &device)) { 315 if (acpi_bus_get_device(handle, &device)) {
@@ -319,16 +317,9 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
319 * no device created for this object, 317 * no device created for this object,
320 * so we should create one. 318 * so we should create one.
321 */ 319 */
322 acpi_get_parent(handle, &parent); 320 ret = acpi_bus_add(handle, &device);
323 if (acpi_bus_get_device(parent, &parent_device)) 321 if (ret)
324 parent_device = NULL;
325
326 ret = acpi_bus_add(&device, parent_device, handle,
327 ACPI_BUS_TYPE_DEVICE);
328 if (ret) {
329 pr_debug("error adding bus, %x\n", -ret); 322 pr_debug("error adding bus, %x\n", -ret);
330 return NULL;
331 }
332 } 323 }
333 return device; 324 return device;
334} 325}
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index e83311bf1ebd..18b292e12b38 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -677,28 +677,6 @@ static int is_processor_present(acpi_handle handle)
677 return 0; 677 return 0;
678} 678}
679 679
680static
681int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
682{
683 acpi_handle phandle;
684 struct acpi_device *pdev;
685
686
687 if (acpi_get_parent(handle, &phandle)) {
688 return -ENODEV;
689 }
690
691 if (acpi_bus_get_device(phandle, &pdev)) {
692 return -ENODEV;
693 }
694
695 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
696 return -ENODEV;
697 }
698
699 return 0;
700}
701
702static void acpi_processor_hotplug_notify(acpi_handle handle, 680static void acpi_processor_hotplug_notify(acpi_handle handle,
703 u32 event, void *data) 681 u32 event, void *data)
704{ 682{
@@ -721,7 +699,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
721 if (!acpi_bus_get_device(handle, &device)) 699 if (!acpi_bus_get_device(handle, &device))
722 break; 700 break;
723 701
724 result = acpi_processor_device_add(handle, &device); 702 result = acpi_bus_add(handle, &device);
725 if (result) { 703 if (result) {
726 acpi_handle_err(handle, "Unable to add the device\n"); 704 acpi_handle_err(handle, "Unable to add the device\n");
727 break; 705 break;
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 6321cab4e5ff..25095bf57bba 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1650,25 +1650,33 @@ static int acpi_bus_scan(acpi_handle handle, bool start,
1650 return ret; 1650 return ret;
1651} 1651}
1652 1652
1653/* 1653/**
1654 * acpi_bus_add 1654 * acpi_bus_add - Add ACPI device node objects in a given namespace scope.
1655 * @handle: Root of the namespace scope to scan.
1656 * @ret: Location to store a return struct acpi_device pointer.
1657 *
1658 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
1659 * found devices.
1655 * 1660 *
1656 * scan a given ACPI tree and (probably recently hot-plugged) 1661 * If no devices were found, -ENODEV is returned, but it does not mean that
1657 * create and add found devices. 1662 * there has been a real error. There just have been no suitable ACPI objects
1663 * in the table trunk from which the kernel could create a device and add an
1664 * appropriate driver.
1658 * 1665 *
1659 * If no devices were found -ENODEV is returned which does not 1666 * If 0 is returned, the memory location pointed to by @ret will be populated
1660 * mean that this is a real error, there just have been no suitable 1667 * with a pointer to a struct acpi_device created while scanning the namespace.
1661 * ACPI objects in the table trunk from which the kernel could create 1668 * If @handle corresponds to a device node, that will be a pointer to the struct
1662 * a device and add an appropriate driver. 1669 * acpi_device object corresponding to @handle. Otherwise, it will be a pointer
1670 * to a struct acpi_device corresponding to one of its descendants.
1671 *
1672 * If an error code is returned, NULL will be stored in the memory location
1673 * pointed to by @ret.
1663 */ 1674 */
1664 1675int acpi_bus_add(acpi_handle handle, struct acpi_device **ret)
1665int
1666acpi_bus_add(struct acpi_device **child,
1667 struct acpi_device *parent, acpi_handle handle, int type)
1668{ 1676{
1669 int err; 1677 int err;
1670 1678
1671 err = acpi_bus_scan(handle, false, child); 1679 err = acpi_bus_scan(handle, false, ret);
1672 if (err) 1680 if (err)
1673 return err; 1681 return err;
1674 1682