lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1357944049-29620-16-git-send-email-yinghai@kernel.org>
Date:	Fri, 11 Jan 2013 14:40:42 -0800
From:	Yinghai Lu <yinghai@...nel.org>
To:	Bjorn Helgaas <bhelgaas@...gle.com>,
	"Rafael J. Wysocki" <rjw@...k.pl>, Len Brown <lenb@...nel.org>,
	Taku Izumi <izumi.taku@...fujitsu.com>,
	Jiang Liu <jiang.liu@...wei.com>
Cc:	linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-acpi@...r.kernel.org, Yinghai Lu <yinghai@...nel.org>
Subject: [PATCH v8 15/22] 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 <yinghai@...nel.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)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ