Subject: [PATCH] ACPI, PCI: Simplify handle_root_bridge_removal() Tang Chen found handle_root_bridge_removal is very similiar to acpi_bus_hot_remove_device(). Only difference is that it call trim two times. Change to handle_root_bridge_removal to call trim one time and then use acpi_bus_hot_remove_device. Signed-off-by: Yinghai Lu --- drivers/acpi/pci_root_hp.c | 51 +++++++-------------------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) Index: linux-2.6/drivers/acpi/pci_root_hp.c =================================================================== --- linux-2.6.orig/drivers/acpi/pci_root_hp.c +++ linux-2.6/drivers/acpi/pci_root_hp.c @@ -56,56 +56,23 @@ static void handle_root_bridge_insertion printk(KERN_ERR "cannot start bridge\n"); } -static int acpi_root_evaluate_object(acpi_handle handle, char *cmd, int val) -{ - acpi_status status; - struct acpi_object_list arg_list; - union acpi_object arg; - - arg_list.count = 1; - arg_list.pointer = &arg; - arg.type = ACPI_TYPE_INTEGER; - arg.integer.value = val; - - status = acpi_evaluate_object(handle, cmd, &arg_list, NULL); - if (ACPI_FAILURE(status)) { - pr_warn("%s: %s to %d failed\n", - __func__, cmd, val); - return -1; - } - - return 0; -} - static void handle_root_bridge_removal(struct acpi_device *device) { int ret_val; - u32 flags = 0; - acpi_handle dummy_handle; - acpi_handle handle = device->handle; - - if (ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &dummy_handle))) - flags |= ROOT_BRIDGE_HAS_EJ0; - if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &dummy_handle))) - flags |= ROOT_BRIDGE_HAS_PS3; + struct acpi_eject_event *ej_event; + + ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); + if (!ej_event) + return; + + ej_event->device = device; + ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; /* remove pci devices at first */ ret_val = acpi_bus_trim(device, 0); printk(KERN_DEBUG "acpi_bus_trim stop return %x\n", ret_val); - /* remove acpi devices */ - ret_val = acpi_bus_trim(device, 1); - printk(KERN_DEBUG "acpi_bus_trim remove return %x\n", ret_val); - - if (flags & ROOT_BRIDGE_HAS_PS3) { - acpi_status status; - - status = acpi_evaluate_object(handle, "_PS3", NULL, NULL); - if (ACPI_FAILURE(status)) - pr_warn("%s: _PS3 failed\n", __func__); - } - if (flags & ROOT_BRIDGE_HAS_EJ0) - acpi_root_evaluate_object(handle, "_EJ0", 1); + acpi_bus_hot_remove_device(ej_event); } static void _handle_hotplug_event_root(struct work_struct *work)