Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Move the function that finds a device_t for the...
details: https://anonhg.NetBSD.org/src/rev/3ccdf468d935
branches: trunk
changeset: 760222:3ccdf468d935
user: jruoho <jruoho%NetBSD.org@localhost>
date: Fri Dec 31 10:23:44 2010 +0000
description:
Move the function that finds a device_t for the corresponding ACPI device
node from ACPIVERBOSE to the ACPI PCI code.
diffstat:
sys/dev/acpi/acpi_pci.c | 51 +++++++++++++++++++++++++++++++++++++++++++-
sys/dev/acpi/acpi_pci.h | 7 +++--
sys/dev/acpi/acpi_verbose.c | 47 +++++------------------------------------
3 files changed, 59 insertions(+), 46 deletions(-)
diffs (193 lines):
diff -r 470ac7d2bf21 -r 3ccdf468d935 sys/dev/acpi/acpi_pci.c
--- a/sys/dev/acpi/acpi_pci.c Fri Dec 31 09:50:14 2010 +0000
+++ b/sys/dev/acpi/acpi_pci.c Fri Dec 31 10:23:44 2010 +0000
@@ -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;
+}
diff -r 470ac7d2bf21 -r 3ccdf468d935 sys/dev/acpi/acpi_pci.h
--- a/sys/dev/acpi/acpi_pci.h Fri Dec 31 09:50:14 2010 +0000
+++ b/sys/dev/acpi/acpi_pci.h Fri Dec 31 10:23:44 2010 +0000
@@ -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 *);
+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);
-ACPI_STATUS acpi_pcidev_ppb_downbus(uint16_t, 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 */
diff -r 470ac7d2bf21 -r 3ccdf468d935 sys/dev/acpi/acpi_verbose.c
--- a/sys/dev/acpi/acpi_verbose.c Fri Dec 31 09:50:14 2010 +0000
+++ b/sys/dev/acpi/acpi_verbose.c Fri Dec 31 10:23:44 2010 +0000
@@ -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;
-}
Home |
Main Index |
Thread Index |
Old Index