From 9c3efb4d4bed206378ecbb58e39b567a2d821d10 Mon Sep 17 00:00:00 2001 From: raj Date: Thu, 11 Sep 2008 12:39:54 +0000 Subject: ARM nexus style(9) improvements. --- sys/arm/arm/nexus.c | 65 +++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 34 deletions(-) (limited to 'sys/arm') diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c index ca9c587..b78a7f2 100644 --- a/sys/arm/arm/nexus.c +++ b/sys/arm/arm/nexus.c @@ -12,7 +12,7 @@ * no representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied * warranty. - * + * * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF @@ -76,14 +76,12 @@ static int nexus_attach(device_t); static int nexus_print_child(device_t, device_t); static device_t nexus_add_child(device_t, int, const char *, int); static struct resource *nexus_alloc_resource(device_t, device_t, int, int *, - u_long, u_long, u_long, u_int); + u_long, u_long, u_long, u_int); static int nexus_activate_resource(device_t, device_t, int, int, - struct resource *); -static int -nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, - driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep); -static int -nexus_teardown_intr(device_t, device_t, struct resource *, void *); + struct resource *); +static int nexus_setup_intr(device_t dev, device_t child, struct resource *res, + int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep); +static int nexus_teardown_intr(device_t, device_t, struct resource *, void *); static device_method_t nexus_methods[] = { /* Device interface */ @@ -110,15 +108,14 @@ static int nexus_probe(device_t dev) { device_quiet(dev); /* suppress attach message for neatness */ - + mem_rman.rm_start = 0; mem_rman.rm_end = ~0u; mem_rman.rm_type = RMAN_ARRAY; mem_rman.rm_descr = "I/O memory addresses"; - if (rman_init(&mem_rman) - || rman_manage_region(&mem_rman, 0, ~0u)) + if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0u)) panic("nexus_probe mem_rman"); - + return (0); } @@ -145,13 +142,14 @@ nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih) static int nexus_attach(device_t dev) { + /* * First, deal with the children we know about already */ bus_generic_probe(dev); bus_generic_attach(dev); - - return 0; + + return (0); } @@ -159,31 +157,30 @@ static int nexus_print_child(device_t bus, device_t child) { int retval = 0; - + retval += bus_print_child_header(bus, child); retval += printf(" on motherboard\n"); /* XXX "motherboard", ick */ - + return (retval); } - static device_t nexus_add_child(device_t bus, int order, const char *name, int unit) { - device_t child; + device_t child; struct nexus_device *ndev; - + ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT|M_ZERO); if (!ndev) - return(0); + return (0); resource_list_init(&ndev->nx_resources); child = device_add_child_ordered(bus, order, name, unit); - + /* should we free this in nexus_child_detached? */ device_set_ivars(child, ndev); - - return(child); + + return (child); } @@ -195,7 +192,7 @@ nexus_add_child(device_t bus, int order, const char *name, int unit) #define ARM_BUS_SPACE_MEM 1 static struct resource * nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) + u_long start, u_long end, u_long count, u_int flags) { struct resource *rv; struct rman *rm; @@ -205,33 +202,33 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, case SYS_RES_MEMORY: rm = &mem_rman; break; - + default: - return 0; + return (0); } rv = rman_reserve_resource(rm, start, end, count, flags, child); if (rv == 0) - return 0; + return (0); rman_set_rid(rv, *rid); rman_set_bustag(rv, (void*)ARM_BUS_SPACE_MEM); - rman_set_bushandle(rv, rman_get_start(rv)); - + rman_set_bushandle(rv, rman_get_start(rv)); + if (needactivate) { if (bus_activate_resource(child, type, *rid, rv)) { rman_release_resource(rv); - return 0; + return (0); } } - - return rv; + + return (rv); } static int nexus_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) + struct resource *r) { /* * If this is a memory resource, map it into the kernel. @@ -241,7 +238,7 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid, u_int32_t paddr; u_int32_t psize; u_int32_t poffs; - + paddr = rman_get_start(r); psize = rman_get_size(r); poffs = paddr - trunc_page(paddr); -- cgit v1.1