Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Mar 2014 23:21:31 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r263279 - head/sys/mips/atheros
Message-ID:  <201403172321.s2HNLVSS011139@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Mon Mar 17 23:21:31 2014
New Revision: 263279
URL: http://svnweb.freebsd.org/changeset/base/263279

Log:
  Implement apb_print_child().
  
  Tested:
  
  * AR9344, Atheros DB120 Reference board

Modified:
  head/sys/mips/atheros/apb.c

Modified: head/sys/mips/atheros/apb.c
==============================================================================
--- head/sys/mips/atheros/apb.c	Mon Mar 17 22:37:17 2014	(r263278)
+++ head/sys/mips/atheros/apb.c	Mon Mar 17 23:21:31 2014	(r263279)
@@ -57,6 +57,8 @@ __FBSDID("$FreeBSD$");
 #define dprintf(x, arg...)
 #endif  /* APB_DEBUG */
 
+#define	DEVTOAPB(dev)	((struct apb_ivar *) device_get_ivars(dev))
+
 static int	apb_activate_resource(device_t, device_t, int, int,
 		    struct resource *);
 static device_t	apb_add_child(device_t, u_int, const char *, int);
@@ -477,6 +479,37 @@ apb_get_resource_list(device_t dev, devi
 	return (&(ivar->resources));
 }
 
+static int
+apb_print_all_resources(device_t dev)
+{
+	struct apb_ivar *ndev = DEVTOAPB(dev);
+	struct resource_list *rl = &ndev->resources;
+	int retval = 0;
+
+	if (STAILQ_FIRST(rl))
+		retval += printf(" at");
+
+	retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
+	retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
+
+	return (retval);
+}
+
+static int
+apb_print_child(device_t bus, device_t child)
+{
+	int retval = 0;
+
+	retval += bus_print_child_header(bus, child);
+	retval += apb_print_all_resources(child);
+	if (device_get_flags(child))
+		retval += printf(" flags %#x", device_get_flags(child));
+	retval += printf(" on %s\n", device_get_nameunit(bus));
+
+	return (retval);
+}
+
+
 static device_method_t apb_methods[] = {
 	DEVMETHOD(bus_activate_resource,	apb_activate_resource),
 	DEVMETHOD(bus_add_child,		apb_add_child),
@@ -491,6 +524,7 @@ static device_method_t apb_methods[] = {
 	DEVMETHOD(device_probe,			apb_probe),
 	DEVMETHOD(bus_get_resource,		bus_generic_rl_get_resource),
 	DEVMETHOD(bus_set_resource,		bus_generic_rl_set_resource),
+	DEVMETHOD(bus_print_child,		apb_print_child),
 
 	DEVMETHOD_END
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403172321.s2HNLVSS011139>