Message ID | 1357944049-29620-16-git-send-email-yinghai@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Bjorn Helgaas |
Headers | show |
On Friday, January 11, 2013 02:40:42 PM Yinghai Lu wrote: > 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. Please fold these changes into your previous patches instead of adding a new one to modify them. Thanks, Rafael > Signed-off-by: Yinghai Lu <yinghai@kernel.org> > --- > drivers/acpi/pci_root.c | 49 ++++++++--------------------------------------- > 1 file changed, 8 insertions(+), 41 deletions(-) > > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c > index 697ec65..8a0e2e2 100644 > --- a/drivers/acpi/pci_root.c > +++ b/drivers/acpi/pci_root.c > @@ -745,56 +745,23 @@ static void handle_root_bridge_insertion(acpi_handle handle) > printk(KERN_ERR "cannot add bridge to acpi list\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; > + struct acpi_eject_event *ej_event; > + > + ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); > + if (!ej_event) > + return; > > - 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; > + 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) >
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 697ec65..8a0e2e2 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -745,56 +745,23 @@ static void handle_root_bridge_insertion(acpi_handle handle) printk(KERN_ERR "cannot add bridge to acpi list\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; + struct acpi_eject_event *ej_event; + + ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); + if (!ej_event) + return; - 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; + 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)
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 <yinghai@kernel.org> --- drivers/acpi/pci_root.c | 49 ++++++++--------------------------------------- 1 file changed, 8 insertions(+), 41 deletions(-)