Commit a2766602 authored by Bjorn Helgaas's avatar Bjorn Helgaas

Merge branch 'acpi-scan' of...

Merge branch 'acpi-scan' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm into pci/acpi-scan2

* 'acpi-scan' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  ACPI / scan: Drop acpi_bus_add() and use acpi_bus_scan() instead
  ACPI: update ej_event interface to take acpi_device
  ACPI / scan: Add second pass to acpi_bus_trim()
  ACPI / scan: Change the implementation of acpi_bus_trim()
  ACPI / scan: Drop the second argument of acpi_bus_trim()
  ACPI / scan: Drop the second argument of acpi_device_unregister()
  ACPI: Remove the ops field from struct acpi_device
  ACPI: remove unused acpi_op_bind and acpi_op_unbind
  ACPI / scan: Fix check of device_attach() return value.
parents 295a7f62 b8bd759a
...@@ -167,7 +167,7 @@ acpi_memory_get_device(acpi_handle handle, ...@@ -167,7 +167,7 @@ acpi_memory_get_device(acpi_handle handle,
* Now add the notified device. This creates the acpi_device * Now add the notified device. This creates the acpi_device
* and invokes .add function * and invokes .add function
*/ */
result = acpi_bus_add(handle); result = acpi_bus_scan(handle);
if (result) { if (result) {
acpi_handle_warn(handle, "Cannot add acpi bus\n"); acpi_handle_warn(handle, "Cannot add acpi bus\n");
return -EINVAL; return -EINVAL;
...@@ -361,7 +361,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) ...@@ -361,7 +361,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
break; break;
} }
ej_event->handle = handle; ej_event->device = device;
ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
acpi_os_hotplug_execute(acpi_bus_hot_remove_device, acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
(void *)ej_event); (void *)ej_event);
......
...@@ -166,7 +166,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) ...@@ -166,7 +166,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
if (!ACPI_FAILURE(status) || device) if (!ACPI_FAILURE(status) || device)
break; break;
result = acpi_bus_add(handle); result = acpi_bus_scan(handle);
if (result) { if (result) {
acpi_handle_warn(handle, "Failed to add container\n"); acpi_handle_warn(handle, "Failed to add container\n");
break; break;
......
...@@ -317,7 +317,7 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle) ...@@ -317,7 +317,7 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
* no device created for this object, * no device created for this object,
* so we should create one. * so we should create one.
*/ */
ret = acpi_bus_add(handle); ret = acpi_bus_scan(handle);
if (ret) if (ret)
pr_debug("error adding bus, %x\n", -ret); pr_debug("error adding bus, %x\n", -ret);
...@@ -339,7 +339,7 @@ static void dock_remove_acpi_device(acpi_handle handle) ...@@ -339,7 +339,7 @@ static void dock_remove_acpi_device(acpi_handle handle)
int ret; int ret;
if (!acpi_bus_get_device(handle, &device)) { if (!acpi_bus_get_device(handle, &device)) {
ret = acpi_bus_trim(device, 1); ret = acpi_bus_trim(device);
if (ret) if (ret)
pr_debug("error removing bus, %x\n", -ret); pr_debug("error removing bus, %x\n", -ret);
} }
......
...@@ -699,7 +699,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle, ...@@ -699,7 +699,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
if (!acpi_bus_get_device(handle, &device)) if (!acpi_bus_get_device(handle, &device))
break; break;
result = acpi_bus_add(handle); result = acpi_bus_scan(handle);
if (result) { if (result) {
acpi_handle_err(handle, "Unable to add the device\n"); acpi_handle_err(handle, "Unable to add the device\n");
break; break;
...@@ -733,7 +733,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle, ...@@ -733,7 +733,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
break; break;
} }
ej_event->handle = handle; ej_event->device = device;
ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
acpi_os_hotplug_execute(acpi_bus_hot_remove_device, acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
(void *)ej_event); (void *)ej_event);
......
...@@ -116,24 +116,18 @@ static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); ...@@ -116,24 +116,18 @@ static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
void acpi_bus_hot_remove_device(void *context) void acpi_bus_hot_remove_device(void *context)
{ {
struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context; struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context;
struct acpi_device *device; struct acpi_device *device = ej_event->device;
acpi_handle handle = ej_event->handle; acpi_handle handle = device->handle;
acpi_handle temp; acpi_handle temp;
struct acpi_object_list arg_list; struct acpi_object_list arg_list;
union acpi_object arg; union acpi_object arg;
acpi_status status = AE_OK; acpi_status status = AE_OK;
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
if (acpi_bus_get_device(handle, &device))
goto err_out;
if (!device)
goto err_out;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Hot-removing device %s...\n", dev_name(&device->dev))); "Hot-removing device %s...\n", dev_name(&device->dev)));
if (acpi_bus_trim(device, 1)) { if (acpi_bus_trim(device)) {
printk(KERN_ERR PREFIX printk(KERN_ERR PREFIX
"Removing device failed\n"); "Removing device failed\n");
goto err_out; goto err_out;
...@@ -215,7 +209,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr, ...@@ -215,7 +209,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
goto err; goto err;
} }
ej_event->handle = acpi_device->handle; ej_event->device = acpi_device;
if (acpi_device->flags.eject_pending) { if (acpi_device->flags.eject_pending) {
/* event originated from ACPI eject notification */ /* event originated from ACPI eject notification */
ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
...@@ -223,7 +217,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr, ...@@ -223,7 +217,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
} else { } else {
/* event originated from user */ /* event originated from user */
ej_event->event = ACPI_OST_EC_OSPM_EJECT; ej_event->event = ACPI_OST_EC_OSPM_EJECT;
(void) acpi_evaluate_hotplug_ost(ej_event->handle, (void) acpi_evaluate_hotplug_ost(acpi_device->handle,
ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
} }
...@@ -701,7 +695,7 @@ static int acpi_device_register(struct acpi_device *device) ...@@ -701,7 +695,7 @@ static int acpi_device_register(struct acpi_device *device)
return result; return result;
} }
static void acpi_device_unregister(struct acpi_device *device, int type) static void acpi_device_unregister(struct acpi_device *device)
{ {
mutex_lock(&acpi_device_lock); mutex_lock(&acpi_device_lock);
if (device->parent) if (device->parent)
...@@ -1374,22 +1368,6 @@ static int acpi_device_set_context(struct acpi_device *device) ...@@ -1374,22 +1368,6 @@ static int acpi_device_set_context(struct acpi_device *device)
return -ENODEV; return -ENODEV;
} }
static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
{
if (!dev)
return -EINVAL;
dev->removal_type = ACPI_BUS_REMOVAL_EJECT;
device_release_driver(&dev->dev);
if (!rmdevice)
return 0;
acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
return 0;
}
static int acpi_add_single_object(struct acpi_device **child, static int acpi_add_single_object(struct acpi_device **child,
acpi_handle handle, int type, acpi_handle handle, int type,
unsigned long long sta, bool match_driver) unsigned long long sta, bool match_driver)
...@@ -1593,13 +1571,25 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, ...@@ -1593,13 +1571,25 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
if (!acpi_match_device_ids(device, acpi_platform_device_ids)) { if (!acpi_match_device_ids(device, acpi_platform_device_ids)) {
/* This is a known good platform device. */ /* This is a known good platform device. */
acpi_create_platform_device(device); acpi_create_platform_device(device);
} else if (device_attach(&device->dev)) { } else if (device_attach(&device->dev) < 0) {
status = AE_CTRL_DEPTH; status = AE_CTRL_DEPTH;
} }
return status; return status;
} }
static int acpi_bus_scan(acpi_handle handle) /**
* acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
* @handle: Root of the namespace scope to scan.
*
* Scan a given ACPI tree (probably recently hot-plugged) and create and add
* found devices.
*
* If no devices were found, -ENODEV is returned, but it does not mean that
* there has been a real error. There just have been no suitable ACPI objects
* in the table trunk from which the kernel could create a device and add an
* appropriate driver.
*/
int acpi_bus_scan(acpi_handle handle)
{ {
void *device = NULL; void *device = NULL;
...@@ -1616,84 +1606,48 @@ static int acpi_bus_scan(acpi_handle handle) ...@@ -1616,84 +1606,48 @@ static int acpi_bus_scan(acpi_handle handle)
return 0; return 0;
} }
EXPORT_SYMBOL(acpi_bus_scan);
/** static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
* acpi_bus_add - Add ACPI device node objects in a given namespace scope. void *not_used, void **ret_not_used)
* @handle: Root of the namespace scope to scan.
*
* Scan a given ACPI tree (probably recently hot-plugged) and create and add
* found devices.
*
* If no devices were found, -ENODEV is returned, but it does not mean that
* there has been a real error. There just have been no suitable ACPI objects
* in the table trunk from which the kernel could create a device and add an
* appropriate driver.
*/
int acpi_bus_add(acpi_handle handle)
{ {
int err; struct acpi_device *device = NULL;
err = acpi_bus_scan(handle);
if (err)
return err;
acpi_update_all_gpes(); if (!acpi_bus_get_device(handle, &device)) {
return 0; device->removal_type = ACPI_BUS_REMOVAL_EJECT;
device_release_driver(&device->dev);
}
return AE_OK;
} }
EXPORT_SYMBOL(acpi_bus_add);
int acpi_bus_trim(struct acpi_device *start, int rmdevice) static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
void *not_used, void **ret_not_used)
{ {
acpi_status status; struct acpi_device *device = NULL;
struct acpi_device *parent, *child;
acpi_handle phandle, chandle;
acpi_object_type type;
u32 level = 1;
int err = 0;
parent = start;
phandle = start->handle;
child = chandle = NULL;
while ((level > 0) && parent && (!err)) {
status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
chandle, &chandle);
/* if (!acpi_bus_get_device(handle, &device))
* If this scope is exhausted then move our way back up. acpi_device_unregister(device);
*/
if (ACPI_FAILURE(status)) {
level--;
chandle = phandle;
acpi_get_parent(phandle, &phandle);
child = parent;
parent = parent->parent;
if (level == 0)
err = acpi_bus_remove(child, rmdevice);
else
err = acpi_bus_remove(child, 1);
continue; return AE_OK;
} }
status = acpi_get_type(chandle, &type); int acpi_bus_trim(struct acpi_device *start)
if (ACPI_FAILURE(status)) { {
continue; /*
} * Execute acpi_bus_device_detach() as a post-order callback to detach
/* * all ACPI drivers from the device nodes being removed.
* If there is a device corresponding to chandle then */
* parse it (depth-first). acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
*/ acpi_bus_device_detach, NULL, NULL);
if (acpi_bus_get_device(chandle, &child) == 0) { acpi_bus_device_detach(start->handle, 0, NULL, NULL);
level++; /*
phandle = chandle; * Execute acpi_bus_remove() as a post-order callback to remove device
chandle = NULL; * nodes in the given namespace scope.
parent = child; */
} acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
continue; acpi_bus_remove, NULL, NULL);
} acpi_bus_remove(start->handle, 0, NULL, NULL);
return err; return 0;
} }
EXPORT_SYMBOL_GPL(acpi_bus_trim); EXPORT_SYMBOL_GPL(acpi_bus_trim);
...@@ -1742,13 +1696,15 @@ int __init acpi_scan_init(void) ...@@ -1742,13 +1696,15 @@ int __init acpi_scan_init(void)
return result; return result;
result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root); result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
if (!result)
result = acpi_bus_scan_fixed();
if (result) if (result)
acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); return result;
else
acpi_update_all_gpes();
return result; result = acpi_bus_scan_fixed();
if (result) {
acpi_device_unregister(acpi_root);
return result;
}
acpi_update_all_gpes();
return 0;
} }
...@@ -742,11 +742,11 @@ static int acpiphp_bus_add(struct acpiphp_func *func) ...@@ -742,11 +742,11 @@ static int acpiphp_bus_add(struct acpiphp_func *func)
/* this shouldn't be in here, so remove /* this shouldn't be in here, so remove
* the bus then re-add it... * the bus then re-add it...
*/ */
ret_val = acpi_bus_trim(device, 1); ret_val = acpi_bus_trim(device);
dbg("acpi_bus_trim return %x\n", ret_val); dbg("acpi_bus_trim return %x\n", ret_val);
} }
ret_val = acpi_bus_add(func->handle); ret_val = acpi_bus_scan(func->handle);
if (!ret_val) if (!ret_val)
ret_val = acpi_bus_get_device(func->handle, &device); ret_val = acpi_bus_get_device(func->handle, &device);
...@@ -772,7 +772,7 @@ static int acpiphp_bus_trim(acpi_handle handle) ...@@ -772,7 +772,7 @@ static int acpiphp_bus_trim(acpi_handle handle)
return retval; return retval;
} }
retval = acpi_bus_trim(device, 1); retval = acpi_bus_trim(device);
if (retval) if (retval)
err("cannot remove from acpi list\n"); err("cannot remove from acpi list\n");
...@@ -1129,7 +1129,7 @@ static void handle_bridge_insertion(acpi_handle handle, u32 type) ...@@ -1129,7 +1129,7 @@ static void handle_bridge_insertion(acpi_handle handle, u32 type)
return; return;
} }
if (acpi_bus_add(handle)) { if (acpi_bus_scan(handle)) {
err("cannot add bridge to acpi list\n"); err("cannot add bridge to acpi list\n");
return; return;
} }
......
...@@ -447,9 +447,9 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot) ...@@ -447,9 +447,9 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
if (ACPI_SUCCESS(ret) && if (ACPI_SUCCESS(ret) &&
(adr>>16) == (slot->device_num + 1)) { (adr>>16) == (slot->device_num + 1)) {
ret = acpi_bus_add(chandle); ret = acpi_bus_scan(chandle);
if (ACPI_FAILURE(ret)) { if (ACPI_FAILURE(ret)) {
printk(KERN_ERR "%s: acpi_bus_add " printk(KERN_ERR "%s: acpi_bus_scan "
"failed (0x%x) for slot %d " "failed (0x%x) for slot %d "
"func %d\n", __func__, "func %d\n", __func__,
ret, (int)(adr>>16), ret, (int)(adr>>16),
...@@ -535,7 +535,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot) ...@@ -535,7 +535,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
ret = acpi_bus_get_device(chandle, ret = acpi_bus_get_device(chandle,
&device); &device);
if (ACPI_SUCCESS(ret)) if (ACPI_SUCCESS(ret))
acpi_bus_trim(device, 1); acpi_bus_trim(device);
} }
} }
......
...@@ -91,8 +91,6 @@ struct acpi_device; ...@@ -91,8 +91,6 @@ struct acpi_device;
typedef int (*acpi_op_add) (struct acpi_device * device); typedef int (*acpi_op_add) (struct acpi_device * device);
typedef int (*acpi_op_remove) (struct acpi_device * device, int type); typedef int (*acpi_op_remove) (struct acpi_device * device, int type);
typedef int (*acpi_op_start) (struct acpi_device * device); typedef int (*acpi_op_start) (struct acpi_device * device);
typedef int (*acpi_op_bind) (struct acpi_device * device);
typedef int (*acpi_op_unbind) (struct acpi_device * device);
typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event); typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event);
struct acpi_device_ops { struct acpi_device_ops {
...@@ -273,7 +271,6 @@ struct acpi_device { ...@@ -273,7 +271,6 @@ struct acpi_device {
struct acpi_device_wakeup wakeup; struct acpi_device_wakeup wakeup;
struct acpi_device_perf performance; struct acpi_device_perf performance;
struct acpi_device_dir dir; struct acpi_device_dir dir;
struct acpi_device_ops ops;
struct acpi_driver *driver; struct acpi_driver *driver;
void *driver_data; void *driver_data;
struct device dev; struct device dev;
...@@ -309,7 +306,7 @@ struct acpi_bus_event { ...@@ -309,7 +306,7 @@ struct acpi_bus_event {
}; };
struct acpi_eject_event { struct acpi_eject_event {
acpi_handle handle; struct acpi_device *device;
u32 event; u32 event;
}; };
...@@ -349,9 +346,9 @@ static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 ty ...@@ -349,9 +346,9 @@ static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 ty
#endif #endif
int acpi_bus_register_driver(struct acpi_driver *driver); int acpi_bus_register_driver(struct acpi_driver *driver);
void acpi_bus_unregister_driver(struct acpi_driver *driver); void acpi_bus_unregister_driver(struct acpi_driver *driver);
int acpi_bus_add(acpi_handle handle); int acpi_bus_scan(acpi_handle handle);
void acpi_bus_hot_remove_device(void *context); void acpi_bus_hot_remove_device(void *context);
int acpi_bus_trim(struct acpi_device *start, int rmdevice); int acpi_bus_trim(struct acpi_device *start);
acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd); acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
int acpi_match_device_ids(struct acpi_device *device, int acpi_match_device_ids(struct acpi_device *device,
const struct acpi_device_id *ids); const struct acpi_device_id *ids);
......
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