Implement apb_print_child().

Tested:

* AR9344, Atheros DB120 Reference board
This commit is contained in:
Adrian Chadd 2014-03-17 23:21:31 +00:00
parent 1416ef361e
commit 22d0785fde

View File

@ -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, device_t child)
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
};