* [PATCH 4/7] ACPI: Introduce acpi_get_physical_pci_device
@ 2008-04-16 18:59 Thomas Renninger
2008-04-16 19:14 ` Matthew Garrett
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Renninger @ 2008-04-16 18:59 UTC (permalink / raw)
To: Len Brown
Cc: linux-acpi, Jonathan Woithe, Carlos Corbacho, Corentin CHARY,
Henrique de Moraes Holschuh, Mattia Dongili
ACPI: Introduce acpi_get_physical_pci_device
This is the same as acpi_get_physical_pci_device, but checks whether
the ACPI device's HID has a valid PCI value. This one should get
enhanced (later or if accepted), so that the returned struct *device
PCI device is further evaluated if it's a PCI bridge and the device
behind that bridge should be returned then.
Sanity checks were taken over from Matthew Garrett.
Signed-off-by: Thomas Renninger <trenn@suse.de>
---
drivers/acpi/glue.c | 35 +++++++++++++++++++++++++++++++++++
drivers/acpi/video.c | 7 ++++++-
include/acpi/acpi_bus.h | 2 ++
3 files changed, 43 insertions(+), 1 deletion(-)
Index: linux-acpi-2.6_video_native_vs_vendor/drivers/acpi/glue.c
===================================================================
--- linux-acpi-2.6_video_native_vs_vendor.orig/drivers/acpi/glue.c
+++ linux-acpi-2.6_video_native_vs_vendor/drivers/acpi/glue.c
@@ -140,6 +140,41 @@ struct device *acpi_get_physical_device(
EXPORT_SYMBOL(acpi_get_physical_device);
+/* ToDo: When a PCI bridge is found, return the PCI device behind the bridge */
+/* Note: a success call will increase reference count by one */
+struct device *acpi_get_physical_pci_device(acpi_handle handle)
+{
+ struct device *dev;
+ long device_id;
+ acpi_status status;
+
+ status =
+ acpi_evaluate_integer(handle, "_ADR", NULL, &device_id);
+
+ if (ACPI_FAILURE(status))
+ return NULL;
+
+ /* We need to attempt to determine whether the _ADR refers to a
+ PCI device or not. There's no terribly good way to do this,
+ so the best we can hope for is to assume that there'll never
+ be a video device in the host bridge */
+ if (device_id >= 0x10000) {
+ /* It looks like a PCI device. Does it exist? */
+ dev = acpi_get_physical_device(handle);
+ } else {
+ /* It doesn't look like a PCI device. Does its parent
+ exist? */
+ acpi_handle phandle;
+ if (acpi_get_parent(handle, &phandle))
+ return NULL;
+ dev = acpi_get_physical_device(phandle);
+ }
+ if (!dev)
+ return NULL;
+ return dev;
+}
+EXPORT_SYMBOL(acpi_get_physical_pci_device);
+
static int acpi_bind_one(struct device *dev, acpi_handle handle)
{
acpi_status status;
Index: linux-acpi-2.6_video_native_vs_vendor/drivers/acpi/video.c
===================================================================
--- linux-acpi-2.6_video_native_vs_vendor.orig/drivers/acpi/video.c
+++ linux-acpi-2.6_video_native_vs_vendor/drivers/acpi/video.c
@@ -805,11 +805,16 @@ static void acpi_video_bus_find_cap(stru
static int acpi_video_bus_check(struct acpi_video_bus *video)
{
acpi_status status = -ENOENT;
-
+ struct device *dev;
if (!video)
return -EINVAL;
+ dev = acpi_get_physical_pci_device(video->device->handle);
+ if (!dev)
+ return -ENODEV;
+ put_device(dev);
+
/* Since there is no HID, CID and so on for VGA driver, we have
* to check well known required nodes.
*/
Index: linux-acpi-2.6_video_native_vs_vendor/include/acpi/acpi_bus.h
===================================================================
--- linux-acpi-2.6_video_native_vs_vendor.orig/include/acpi/acpi_bus.h
+++ linux-acpi-2.6_video_native_vs_vendor/include/acpi/acpi_bus.h
@@ -370,6 +370,8 @@ struct acpi_bus_type {
int register_acpi_bus_type(struct acpi_bus_type *);
int unregister_acpi_bus_type(struct acpi_bus_type *);
struct device *acpi_get_physical_device(acpi_handle);
+struct device *acpi_get_physical_pci_device(acpi_handle);
+
/* helper */
acpi_handle acpi_get_child(acpi_handle, acpi_integer);
acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 4/7] ACPI: Introduce acpi_get_physical_pci_device
2008-04-16 18:59 [PATCH 4/7] ACPI: Introduce acpi_get_physical_pci_device Thomas Renninger
@ 2008-04-16 19:14 ` Matthew Garrett
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Garrett @ 2008-04-16 19:14 UTC (permalink / raw)
To: Thomas Renninger
Cc: Len Brown, linux-acpi, Jonathan Woithe, Carlos Corbacho,
Corentin CHARY, Henrique de Moraes Holschuh, Mattia Dongili
On Wed, Apr 16, 2008 at 08:59:58PM +0200, Thomas Renninger wrote:
> ACPI: Introduce acpi_get_physical_pci_device
>
> This is the same as acpi_get_physical_pci_device, but checks whether
> the ACPI device's HID has a valid PCI value. This one should get
> enhanced (later or if accepted), so that the returned struct *device
> PCI device is further evaluated if it's a PCI bridge and the device
> behind that bridge should be returned then.
> Sanity checks were taken over from Matthew Garrett.
The comment isn't quite right. It checks whether the ADR is a likely PCI
value, not a valid one.
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-16 20:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-16 18:59 [PATCH 4/7] ACPI: Introduce acpi_get_physical_pci_device Thomas Renninger
2008-04-16 19:14 ` Matthew Garrett
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox