From: Li Shaohua <shaohua.li@intel.com>
To: ACPI-DEV <acpi-devel@lists.sourceforge.net>,
lkml <linux-kernel@vger.kernel.org>
Cc: Len Brown <len.brown@intel.com>, Greg <greg@kroah.com>,
Patrick Mochel <mochel@digitalimplant.org>,
Pavel Machek <pavel@suse.cz>
Subject: [PATCH 2/4]An implementation for binding PCI device with ACPI device
Date: Wed, 05 Jan 2005 10:50:55 +0800 [thread overview]
Message-ID: <1104893450.5550.131.camel@sli10-desk.sh.intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1672 bytes --]
Hi,
This is an implementation for binding ACPI devices with PCI devices.
Thanks,
Shaohua
Signed-off-by: Li Shaohua<shaohua.li@intel.com>
---
2.5-root/drivers/pci/pci-acpi.c | 46 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+)
diff -puN drivers/pci/pci-acpi.c~bind-acpi-pci drivers/pci/pci-acpi.c
--- 2.5/drivers/pci/pci-acpi.c~bind-acpi-pci 2005-01-05 09:57:26.863944152 +0800
+++ 2.5-root/drivers/pci/pci-acpi.c 2005-01-05 09:57:26.866943696 +0800
@@ -207,3 +207,49 @@ acpi_status pci_osc_control_set(u32 flag
return status;
}
EXPORT_SYMBOL(pci_osc_control_set);
+
+/* ACPI bus type */
+int pci_acpi_bind_device(struct device *dev, acpi_handle *handle)
+{
+ struct pci_dev * pci_dev;
+ acpi_integer addr;
+
+ pci_dev = to_pci_dev(dev);
+ /* Please ref to ACPI spec for the syntax of _ADR */
+ addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
+ *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr);
+ if (!*handle)
+ return -ENODEV;
+ return 0;
+}
+
+static int pci_acpi_bind_root_bridge(struct device *dev, acpi_handle *handle)
+{
+ int num;
+ unsigned int seg, bus;
+
+ num = sscanf(dev->bus_id, "pci%04x:%02x", &seg, &bus);
+ if (num != 2)
+ return -ENODEV;
+ *handle = acpi_get_pci_rootbridge_handle(seg, bus);
+ if (!*handle)
+ return -ENODEV;
+ return 0;
+}
+
+static struct acpi_bus_type pci_acpi_bus = {
+ .bus = &pci_bus_type,
+ .find_device = pci_acpi_bind_device,
+ .find_bridge = pci_acpi_bind_root_bridge,
+};
+
+static int __init pci_acpi_init(void)
+{
+ int ret;
+
+ ret = register_acpi_bus_type(&pci_acpi_bus);
+ if (ret)
+ return 0;
+ return 0;
+}
+arch_initcall(pci_acpi_init);
_
[-- Attachment #2: p00002_bind-acpi-pci.patch --]
[-- Type: text/x-patch, Size: 1595 bytes --]
An implementation for binding ACPI devices with PCI devices.
---
2.5-root/drivers/pci/pci-acpi.c | 46 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+)
diff -puN drivers/pci/pci-acpi.c~bind-acpi-pci drivers/pci/pci-acpi.c
--- 2.5/drivers/pci/pci-acpi.c~bind-acpi-pci 2005-01-05 09:57:26.863944152 +0800
+++ 2.5-root/drivers/pci/pci-acpi.c 2005-01-05 09:57:26.866943696 +0800
@@ -207,3 +207,49 @@ acpi_status pci_osc_control_set(u32 flag
return status;
}
EXPORT_SYMBOL(pci_osc_control_set);
+
+/* ACPI bus type */
+int pci_acpi_bind_device(struct device *dev, acpi_handle *handle)
+{
+ struct pci_dev * pci_dev;
+ acpi_integer addr;
+
+ pci_dev = to_pci_dev(dev);
+ /* Please ref to ACPI spec for the syntax of _ADR */
+ addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
+ *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr);
+ if (!*handle)
+ return -ENODEV;
+ return 0;
+}
+
+static int pci_acpi_bind_root_bridge(struct device *dev, acpi_handle *handle)
+{
+ int num;
+ unsigned int seg, bus;
+
+ num = sscanf(dev->bus_id, "pci%04x:%02x", &seg, &bus);
+ if (num != 2)
+ return -ENODEV;
+ *handle = acpi_get_pci_rootbridge_handle(seg, bus);
+ if (!*handle)
+ return -ENODEV;
+ return 0;
+}
+
+static struct acpi_bus_type pci_acpi_bus = {
+ .bus = &pci_bus_type,
+ .find_device = pci_acpi_bind_device,
+ .find_bridge = pci_acpi_bind_root_bridge,
+};
+
+static int __init pci_acpi_init(void)
+{
+ int ret;
+
+ ret = register_acpi_bus_type(&pci_acpi_bus);
+ if (ret)
+ return 0;
+ return 0;
+}
+arch_initcall(pci_acpi_init);
_
reply other threads:[~2005-01-05 2:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1104893450.5550.131.camel@sli10-desk.sh.intel.com \
--to=shaohua.li@intel.com \
--cc=acpi-devel@lists.sourceforge.net \
--cc=greg@kroah.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@digitalimplant.org \
--cc=pavel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).