Module Name:    src
Committed By:   jmcneill
Date:           Mon Oct 15 10:00:30 UTC 2018

Modified Files:
        src/sys/dev/acpi: acpi_pci.c acpi_pci.h

Log Message:
Add a function to find a PCI root bridge by segment and bus number.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/acpi/acpi_pci.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/acpi/acpi_pci.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/acpi_pci.c
diff -u src/sys/dev/acpi/acpi_pci.c:1.22 src/sys/dev/acpi/acpi_pci.c:1.23
--- src/sys/dev/acpi/acpi_pci.c:1.22	Sat May  5 17:16:23 2018
+++ src/sys/dev/acpi/acpi_pci.c	Mon Oct 15 10:00:30 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.22 2018/05/05 17:16:23 christos Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.23 2018/10/15 10:00:30 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.22 2018/05/05 17:16:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.23 2018/10/15 10:00:30 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -383,6 +383,33 @@ acpi_pcidev_find(uint16_t segment, uint1
 	return NULL;
 }
 
+/*
+ * acpi_pciroot_find:
+ *
+ *	Finds a PCI root bridge in the ACPI name space.
+ *
+ *	Returns an ACPI device node on success and NULL on failure.
+ */
+struct acpi_devnode *
+acpi_pciroot_find(uint16_t segment, uint16_t bus)
+{
+	struct acpi_softc *sc = acpi_softc;
+	struct acpi_devnode *ad;
+
+	if (sc == NULL)
+		return NULL;
+
+	SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) {
+
+		if (ad->ad_pciinfo != NULL &&
+		    (ad->ad_pciinfo->ap_flags & ACPI_PCI_INFO_BRIDGE) &&
+		    ad->ad_pciinfo->ap_segment == segment &&
+		    ad->ad_pciinfo->ap_bus == bus)
+			return ad;
+	}
+
+	return NULL;
+}
 
 /*
  * acpi_pcidev_find_dev:

Index: src/sys/dev/acpi/acpi_pci.h
diff -u src/sys/dev/acpi/acpi_pci.h:1.8 src/sys/dev/acpi/acpi_pci.h:1.9
--- src/sys/dev/acpi/acpi_pci.h:1.8	Fri Dec 31 10:56:39 2010
+++ src/sys/dev/acpi/acpi_pci.h	Mon Oct 15 10:00:30 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.h,v 1.8 2010/12/31 10:56:39 jruoho Exp $ */
+/* $NetBSD: acpi_pci.h,v 1.9 2018/10/15 10:00:30 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -37,5 +37,6 @@ ACPI_STATUS		 acpi_pcidev_ppb_downbus(ui
 struct acpi_devnode	*acpi_pcidev_find(uint16_t, uint16_t,
 					  uint16_t, uint16_t);
 device_t		 acpi_pcidev_find_dev(struct acpi_devnode *);
+struct acpi_devnode	*acpi_pciroot_find(uint16_t, uint16_t);
 
 #endif	/* !_SYS_DEV_ACPI_ACPI_PCI_H */

Reply via email to