Module Name:    src
Committed By:   jruoho
Date:           Fri Dec 31 10:23:44 UTC 2010

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

Log Message:
Move the function that finds a device_t for the corresponding ACPI device
node from ACPIVERBOSE to the ACPI PCI code.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/acpi/acpi_pci.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/acpi/acpi_pci.h
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/acpi/acpi_verbose.c

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.16 src/sys/dev/acpi/acpi_pci.c:1.17
--- src/sys/dev/acpi/acpi_pci.c:1.16	Tue Oct 26 22:27:44 2010
+++ src/sys/dev/acpi/acpi_pci.c	Fri Dec 31 10:23:44 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.16 2010/10/26 22:27:44 gsutre Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.17 2010/12/31 10:23:44 jruoho 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.16 2010/10/26 22:27:44 gsutre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.17 2010/12/31 10:23:44 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -37,6 +37,7 @@
 #include <sys/systm.h>
 
 #include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
 #include <dev/pci/pcidevs.h>
 #include <dev/pci/ppbreg.h>
 
@@ -44,6 +45,8 @@
 #include <dev/acpi/acpivar.h>
 #include <dev/acpi/acpi_pci.h>
 
+#include "locators.h"
+
 #define _COMPONENT	  ACPI_BUS_COMPONENT
 ACPI_MODULE_NAME	  ("acpi_pci")
 
@@ -385,3 +388,47 @@
 
 	return NULL;
 }
+
+
+/*
+ * acpi_pcidev_find_dev:
+ *
+ *	Returns the device corresponding to the given PCI info, or NULL
+ *	if it doesn't exist.
+ */
+device_t
+acpi_pcidev_find_dev(struct acpi_pci_info *ap)
+{
+	struct pci_softc *pci;
+	device_t dv, pr;
+	deviter_t di;
+
+	if (ap == NULL)
+		return NULL;
+
+	if (ap->ap_function == 0xFFFF)
+		return NULL;
+
+	for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST);
+	     dv != NULL; dv = deviter_next(&di)) {
+
+		pr = device_parent(dv);
+
+		if (pr == NULL || device_is_a(pr, "pci") != true)
+			continue;
+
+		if (dv->dv_locators == NULL)	/* This should not happen. */
+			continue;
+
+		pci = device_private(pr);
+
+		if (pci->sc_bus == ap->ap_bus &&
+		    device_locator(dv, PCICF_DEV) == ap->ap_device &&
+		    device_locator(dv, PCICF_FUNCTION) == ap->ap_function)
+			break;
+	}
+
+	deviter_release(&di);
+
+	return dv;
+}

Index: src/sys/dev/acpi/acpi_pci.h
diff -u src/sys/dev/acpi/acpi_pci.h:1.6 src/sys/dev/acpi/acpi_pci.h:1.7
--- src/sys/dev/acpi/acpi_pci.h:1.6	Fri Apr 23 15:46:59 2010
+++ src/sys/dev/acpi/acpi_pci.h	Fri Dec 31 10:23:44 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.h,v 1.6 2010/04/23 15:46:59 jruoho Exp $ */
+/* $NetBSD: acpi_pci.h,v 1.7 2010/12/31 10:23:44 jruoho Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -32,9 +32,10 @@
 #define _SYS_DEV_ACPI_ACPI_PCI_H
 
 ACPI_STATUS		 acpi_pcidev_scan(struct acpi_devnode *);
-struct acpi_devnode	*acpi_pcidev_find(uint16_t, uint16_t,
-					  uint16_t, uint16_t);
 ACPI_STATUS		 acpi_pcidev_ppb_downbus(uint16_t, uint16_t, uint16_t,
 						 uint16_t, uint16_t *);
+struct acpi_devnode	*acpi_pcidev_find(uint16_t, uint16_t,
+					  uint16_t, uint16_t);
+device_t		 acpi_pcidev_find_dev(struct acpi_pci_info *);
 
 #endif	/* !_SYS_DEV_ACPI_ACPI_PCI_H */

Index: src/sys/dev/acpi/acpi_verbose.c
diff -u src/sys/dev/acpi/acpi_verbose.c:1.12 src/sys/dev/acpi/acpi_verbose.c:1.13
--- src/sys/dev/acpi/acpi_verbose.c:1.12	Tue Oct 26 22:27:44 2010
+++ src/sys/dev/acpi/acpi_verbose.c	Fri Dec 31 10:23:44 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_verbose.c,v 1.12 2010/10/26 22:27:44 gsutre Exp $ */
+/*	$NetBSD: acpi_verbose.c,v 1.13 2010/12/31 10:23:44 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007, 2010 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_verbose.c,v 1.12 2010/10/26 22:27:44 gsutre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_verbose.c,v 1.13 2010/12/31 10:23:44 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -77,11 +77,10 @@
 #include <dev/acpi/acpivar.h>
 #include <dev/acpi/acpidevs_data.h>
 
-#include <dev/pci/pcivar.h>
-
 #include <prop/proplib.h>
 
-#include "locators.h"
+#define _COMPONENT ACPI_UTILITIES
+ACPI_MODULE_NAME   ("acpi_verbose")
 
 static bool	   acpiverbose_modcmd_prop(prop_dictionary_t);
 
@@ -92,7 +91,6 @@
 static void	   acpi_print_fadt(struct acpi_softc *);
 static void	   acpi_print_devnodes(struct acpi_softc *);
 static void	   acpi_print_tree(struct acpi_devnode *, uint32_t);
-static device_t	   device_find_by_acpi_pci_info(const struct acpi_pci_info *);
 
 extern ACPI_TABLE_HEADER *madt_header;
 
@@ -492,7 +490,8 @@
 			    ad->ad_pciinfo->ap_segment,
 			    ad->ad_pciinfo->ap_downbus);
 
-		pcidev = device_find_by_acpi_pci_info(ad->ad_pciinfo);
+		pcidev = acpi_pcidev_find_dev(ad->ad_pciinfo);
+
 		if (pcidev != NULL)
 			aprint_normal(" <%s>", device_xname(pcidev));
 	}
@@ -502,37 +501,3 @@
 	SIMPLEQ_FOREACH(child, &ad->ad_child_head, ad_child_list)
 	    acpi_print_tree(child, level + 1);
 }
-
-/*
- * device_find_by_acpi_pci_info:
- *
- *	Returns the device corresponding to the given PCI info, or NULL
- *	if it doesn't exist.
- */
-static device_t
-device_find_by_acpi_pci_info(const struct acpi_pci_info *ap)
-{
-	device_t dv, pr;
-	struct pci_softc *pci;
-	deviter_t di;
-
-	if (ap->ap_function == 0xFFFF)
-		return NULL;
-
-	for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL;
-	     dv = deviter_next(&di)) {
-		pr = device_parent(dv);
-		if ((pr == NULL) || !device_is_a(pr, "pci"))
-			continue;
-		if (dv->dv_locators == NULL)	/* This should not happen. */
-			continue;
-		pci = device_private(pr);
-		if (pci->sc_bus == ap->ap_bus &&
-		    device_locator(dv, PCICF_DEV) == ap->ap_device &&
-		    device_locator(dv, PCICF_FUNCTION) == ap->ap_function)
-			break;
-	}
-	deviter_release(&di);
-
-	return dv;
-}

Reply via email to