From patchwork Fri Jan 11 22:40:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 1967891 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A6DC0DF2A2 for ; Fri, 11 Jan 2013 22:43:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755219Ab3AKWnV (ORCPT ); Fri, 11 Jan 2013 17:43:21 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:38456 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756061Ab3AKWlV (ORCPT ); Fri, 11 Jan 2013 17:41:21 -0500 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id r0BMfBW8013564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Jan 2013 22:41:12 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r0BMfAtJ027345 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Jan 2013 22:41:11 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r0BMfAtx019230; Fri, 11 Jan 2013 16:41:10 -0600 Received: from linux-siqj.site (/10.132.126.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 11 Jan 2013 14:41:10 -0800 From: Yinghai Lu To: Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Taku Izumi , Jiang Liu Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Yinghai Lu Subject: [PATCH v8 15/22] ACPI, PCI: Simplify handle_root_bridge_removal() Date: Fri, 11 Jan 2013 14:40:42 -0800 Message-Id: <1357944049-29620-16-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1357944049-29620-1-git-send-email-yinghai@kernel.org> References: <1357944049-29620-1-git-send-email-yinghai@kernel.org> X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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.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)