Commit e3b87f8a authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Len Brown

ACPI: handle re-enumeration, when acpi_devices might already exist

acpi_bus_scan() traverses the namespace to enumerate devices and uses
acpi_add_single_object() to create acpi_devices.  When the platform
notifies us of a hot-plug event, we need to traverse part of the namespace
again to figure out what appeared or disappeared.  (We don't yet call
acpi_bus_scan() during hot-plug, but I plan to do that in the future.)

This patch makes acpi_add_single_object() notice when we already have
an acpi_device, so we don't need to make a new one.
Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 778cbc1d
...@@ -1400,10 +1400,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, ...@@ -1400,10 +1400,10 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
void *context, void **return_value) void *context, void **return_value)
{ {
struct acpi_bus_ops *ops = context; struct acpi_bus_ops *ops = context;
struct acpi_device *device = NULL;
acpi_status status;
int type; int type;
unsigned long long sta; unsigned long long sta;
struct acpi_device *device;
acpi_status status;
int result; int result;
result = acpi_bus_type_and_status(handle, &type, &sta); result = acpi_bus_type_and_status(handle, &type, &sta);
...@@ -1414,13 +1414,16 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, ...@@ -1414,13 +1414,16 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
!(sta & ACPI_STA_DEVICE_FUNCTIONING)) !(sta & ACPI_STA_DEVICE_FUNCTIONING))
return AE_CTRL_DEPTH; return AE_CTRL_DEPTH;
if (ops->acpi_op_add) /*
status = acpi_add_single_object(&device, handle, type, sta, * We may already have an acpi_device from a previous enumeration. If
ops); * so, we needn't add it again, but we may still have to start it.
else */
status = acpi_bus_get_device(handle, &device); device = NULL;
acpi_bus_get_device(handle, &device);
if (ops->acpi_op_add && !device)
acpi_add_single_object(&device, handle, type, sta, ops);
if (ACPI_FAILURE(status)) if (!device)
return AE_CTRL_DEPTH; return AE_CTRL_DEPTH;
if (ops->acpi_op_start && !(ops->acpi_op_add)) { if (ops->acpi_op_start && !(ops->acpi_op_add)) {
......
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