mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH/RFC 2/4]ACPI helper routines
@ 2004-11-08  4:11 Li Shaohua
  0 siblings, 0 replies; only message in thread
From: Li Shaohua @ 2004-11-08  4:11 UTC (permalink / raw)
  To: ACPI-DEV, lkml; +Cc: Len Brown, Greg, Patrick Mochel

[-- Attachment #1: Type: text/plain, Size: 3819 bytes --]

Hi,
Add ACPI helper for binding physical devices with ACPI devices

Thanks,
Shaohua
---

 2.6-root/drivers/acpi/acpi_ksyms.c   |    1 +
 2.6-root/drivers/acpi/bus.c          |   35
+++++++++++++++++++++++++++++++++++
 2.6-root/drivers/acpi/pci_root.c     |   13 +++++++++++++
 2.6-root/include/acpi/acpi_bus.h     |    1 +
 2.6-root/include/acpi/acpi_drivers.h |    1 +
 5 files changed, 51 insertions(+)

diff -puN drivers/acpi/acpi_ksyms.c~acpihelper drivers/acpi/acpi_ksyms.c
--- 2.6/drivers/acpi/acpi_ksyms.c~acpihelper	2004-11-08
11:05:22.767953024 +0800
+++ 2.6-root/drivers/acpi/acpi_ksyms.c	2004-11-08 11:05:22.776951656
+0800
@@ -57,6 +57,7 @@ EXPORT_SYMBOL(acpi_ut_trace);
 
 EXPORT_SYMBOL(acpi_get_handle);
 EXPORT_SYMBOL(acpi_get_parent);
+EXPORT_SYMBOL(acpi_get_child);
 EXPORT_SYMBOL(acpi_get_type);
 EXPORT_SYMBOL(acpi_get_name);
 EXPORT_SYMBOL(acpi_get_object_info);
diff -puN drivers/acpi/bus.c~acpihelper drivers/acpi/bus.c
--- 2.6/drivers/acpi/bus.c~acpihelper	2004-11-08 11:05:22.768952872
+0800
+++ 2.6-root/drivers/acpi/bus.c	2004-11-08 11:05:22.776951656 +0800
@@ -271,7 +271,42 @@ end:
 	return_VALUE(result);
 }
 
+struct acpi_find_child {
+	acpi_handle     handle;
+	acpi_integer    address;
+};
 
+static acpi_status
+find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+	acpi_status	status;
+	struct acpi_device_info *info;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	struct acpi_find_child *find = (struct acpi_find_child*)context;
+
+	status = acpi_get_object_info(handle, &buffer);
+	if (ACPI_SUCCESS(status)) {
+		info = buffer.pointer;
+		if (info->address == find->address) {
+			find->handle = handle;
+			return AE_CTRL_TERMINATE;
+		}
+	}
+	return AE_OK;
+}
+
+/* Move it to ACPICA? */
+acpi_handle acpi_get_child(acpi_handle parent, acpi_integer address)
+{
+	struct acpi_find_child find = {NULL, address};
+
+	if (!parent)
+		return NULL;
+	acpi_walk_namespace(ACPI_TYPE_DEVICE, parent,
+		1, find_child,
+		&find, NULL);
+	return find.handle;
+}
 
 /*
--------------------------------------------------------------------------
                                 Event Management
diff -puN drivers/acpi/pci_root.c~acpihelper drivers/acpi/pci_root.c
--- 2.6/drivers/acpi/pci_root.c~acpihelper	2004-11-08 11:05:22.770952568
+0800
+++ 2.6-root/drivers/acpi/pci_root.c	2004-11-08 11:05:22.777951504 +0800
@@ -343,3 +343,16 @@ static int __init acpi_pci_root_init (vo
 
 subsys_initcall(acpi_pci_root_init);
 
+acpi_handle acpi_get_rootbridge_handle(u16 segment, u16 bus)
+{
+	struct list_head *entry;
+
+	list_for_each(entry, &acpi_pci_roots) {
+		struct acpi_pci_root *root;
+
+		root = list_entry(entry, struct acpi_pci_root, node);
+		if ((root->id.segment == segment) && (root->id.bus == bus))
+			return root->handle;
+	}
+	return NULL;
+}
diff -puN include/acpi/acpi_bus.h~acpihelper include/acpi/acpi_bus.h
--- 2.6/include/acpi/acpi_bus.h~acpihelper	2004-11-08 11:05:22.771952416
+0800
+++ 2.6-root/include/acpi/acpi_bus.h	2004-11-08 11:05:22.777951504 +0800
@@ -313,6 +313,7 @@ extern struct subsystem acpi_subsys;
  * External Functions
  */
 
+acpi_handle acpi_get_child(acpi_handle parent, acpi_integer address);
 int acpi_bus_get_device(acpi_handle, struct acpi_device **device);
 int acpi_bus_get_status (struct acpi_device *device);
 int acpi_bus_get_power (acpi_handle handle, int *state);
diff -puN include/acpi/acpi_drivers.h~acpihelper
include/acpi/acpi_drivers.h
--- 2.6/include/acpi/acpi_drivers.h~acpihelper	2004-11-08
11:05:22.773952112 +0800
+++ 2.6-root/include/acpi/acpi_drivers.h	2004-11-08 11:05:22.777951504
+0800
@@ -53,6 +53,7 @@
 
 #define ACPI_PCI_COMPONENT		0x00400000
 
+acpi_handle acpi_get_rootbridge_handle(u16 segment, u16 bus);
 /* ACPI PCI Interrupt Link (pci_link.c) */
 
 int acpi_irq_penalty_init (void);
_


[-- Attachment #2: p00002_acpihelper.patch --]
[-- Type: text/x-patch, Size: 3799 bytes --]


Add ACPI helper for binding physical devices with ACPI devices

---

 2.6-root/drivers/acpi/acpi_ksyms.c   |    1 +
 2.6-root/drivers/acpi/bus.c          |   35 +++++++++++++++++++++++++++++++++++
 2.6-root/drivers/acpi/pci_root.c     |   13 +++++++++++++
 2.6-root/include/acpi/acpi_bus.h     |    1 +
 2.6-root/include/acpi/acpi_drivers.h |    1 +
 5 files changed, 51 insertions(+)

diff -puN drivers/acpi/acpi_ksyms.c~acpihelper drivers/acpi/acpi_ksyms.c
--- 2.6/drivers/acpi/acpi_ksyms.c~acpihelper	2004-11-08 11:05:22.767953024 +0800
+++ 2.6-root/drivers/acpi/acpi_ksyms.c	2004-11-08 11:05:22.776951656 +0800
@@ -57,6 +57,7 @@ EXPORT_SYMBOL(acpi_ut_trace);
 
 EXPORT_SYMBOL(acpi_get_handle);
 EXPORT_SYMBOL(acpi_get_parent);
+EXPORT_SYMBOL(acpi_get_child);
 EXPORT_SYMBOL(acpi_get_type);
 EXPORT_SYMBOL(acpi_get_name);
 EXPORT_SYMBOL(acpi_get_object_info);
diff -puN drivers/acpi/bus.c~acpihelper drivers/acpi/bus.c
--- 2.6/drivers/acpi/bus.c~acpihelper	2004-11-08 11:05:22.768952872 +0800
+++ 2.6-root/drivers/acpi/bus.c	2004-11-08 11:05:22.776951656 +0800
@@ -271,7 +271,42 @@ end:
 	return_VALUE(result);
 }
 
+struct acpi_find_child {
+	acpi_handle     handle;
+	acpi_integer    address;
+};
 
+static acpi_status
+find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+	acpi_status	status;
+	struct acpi_device_info *info;
+	struct acpi_buffer	buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	struct acpi_find_child *find = (struct acpi_find_child*)context;
+
+	status = acpi_get_object_info(handle, &buffer);
+	if (ACPI_SUCCESS(status)) {
+		info = buffer.pointer;
+		if (info->address == find->address) {
+			find->handle = handle;
+			return AE_CTRL_TERMINATE;
+		}
+	}
+	return AE_OK;
+}
+
+/* Move it to ACPICA? */
+acpi_handle acpi_get_child(acpi_handle parent, acpi_integer address)
+{
+	struct acpi_find_child find = {NULL, address};
+
+	if (!parent)
+		return NULL;
+	acpi_walk_namespace(ACPI_TYPE_DEVICE, parent,
+		1, find_child,
+		&find, NULL);
+	return find.handle;
+}
 
 /* --------------------------------------------------------------------------
                                 Event Management
diff -puN drivers/acpi/pci_root.c~acpihelper drivers/acpi/pci_root.c
--- 2.6/drivers/acpi/pci_root.c~acpihelper	2004-11-08 11:05:22.770952568 +0800
+++ 2.6-root/drivers/acpi/pci_root.c	2004-11-08 11:05:22.777951504 +0800
@@ -343,3 +343,16 @@ static int __init acpi_pci_root_init (vo
 
 subsys_initcall(acpi_pci_root_init);
 
+acpi_handle acpi_get_rootbridge_handle(u16 segment, u16 bus)
+{
+	struct list_head *entry;
+
+	list_for_each(entry, &acpi_pci_roots) {
+		struct acpi_pci_root *root;
+
+		root = list_entry(entry, struct acpi_pci_root, node);
+		if ((root->id.segment == segment) && (root->id.bus == bus))
+			return root->handle;
+	}
+	return NULL;
+}
diff -puN include/acpi/acpi_bus.h~acpihelper include/acpi/acpi_bus.h
--- 2.6/include/acpi/acpi_bus.h~acpihelper	2004-11-08 11:05:22.771952416 +0800
+++ 2.6-root/include/acpi/acpi_bus.h	2004-11-08 11:05:22.777951504 +0800
@@ -313,6 +313,7 @@ extern struct subsystem acpi_subsys;
  * External Functions
  */
 
+acpi_handle acpi_get_child(acpi_handle parent, acpi_integer address);
 int acpi_bus_get_device(acpi_handle, struct acpi_device **device);
 int acpi_bus_get_status (struct acpi_device *device);
 int acpi_bus_get_power (acpi_handle handle, int *state);
diff -puN include/acpi/acpi_drivers.h~acpihelper include/acpi/acpi_drivers.h
--- 2.6/include/acpi/acpi_drivers.h~acpihelper	2004-11-08 11:05:22.773952112 +0800
+++ 2.6-root/include/acpi/acpi_drivers.h	2004-11-08 11:05:22.777951504 +0800
@@ -53,6 +53,7 @@
 
 #define ACPI_PCI_COMPONENT		0x00400000
 
+acpi_handle acpi_get_rootbridge_handle(u16 segment, u16 bus);
 /* ACPI PCI Interrupt Link (pci_link.c) */
 
 int acpi_irq_penalty_init (void);
_

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-08  4:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-08  4:11 [PATCH/RFC 2/4]ACPI helper routines Li Shaohua

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®