From owner-svn-src-head@FreeBSD.ORG Tue Mar 10 19:15:36 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31F83106564A; Tue, 10 Mar 2009 19:15:36 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1F02D8FC1A; Tue, 10 Mar 2009 19:15:36 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2AJFagC071208; Tue, 10 Mar 2009 19:15:36 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2AJFam9071207; Tue, 10 Mar 2009 19:15:36 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200903101915.n2AJFam9071207@svn.freebsd.org> From: Sam Leffler Date: Tue, 10 Mar 2009 19:15:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189641 - head/sys/arm/xscale/ixp425 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2009 19:15:36 -0000 Author: sam Date: Tue Mar 10 19:15:35 2009 New Revision: 189641 URL: http://svn.freebsd.org/changeset/base/189641 Log: o add missing bus_release_resource and bus_deactivate_resource that just operate on the resource (we have no local resources to manage); this fixes drivers that alloc/release resources in their probe method and then do it again in attach o while here add some prints to catch failures and massage style a bit Modified: head/sys/arm/xscale/ixp425/ixp425.c Modified: head/sys/arm/xscale/ixp425/ixp425.c ============================================================================== --- head/sys/arm/xscale/ixp425/ixp425.c Tue Mar 10 18:57:10 2009 (r189640) +++ head/sys/arm/xscale/ixp425/ixp425.c Tue Mar 10 19:15:35 2009 (r189641) @@ -440,7 +440,6 @@ ixp425_alloc_resource(device_t dev, devi { struct ixp425_softc *sc = device_get_softc(dev); const struct hwvtrans *vtrans; - struct rman *rmanp; struct resource *rv; uint32_t addr; int needactivate = flags & RF_ACTIVE; @@ -449,18 +448,16 @@ ixp425_alloc_resource(device_t dev, devi flags &= ~RF_ACTIVE; switch (type) { case SYS_RES_IRQ: - rmanp = &sc->sc_irq_rman; /* override per hints */ if (BUS_READ_IVAR(dev, child, IXP425_IVAR_IRQ, &irq) == 0) start = end = irq; - rv = rman_reserve_resource(rmanp, start, end, count, - flags, child); + rv = rman_reserve_resource(&sc->sc_irq_rman, start, end, count, + flags, child); if (rv != NULL) rman_set_rid(rv, *rid); break; case SYS_RES_MEMORY: - rmanp = &sc->sc_mem_rman; /* override per hints */ if (BUS_READ_IVAR(dev, child, IXP425_IVAR_ADDR, &addr) == 0) { start = addr; @@ -485,13 +482,17 @@ ixp425_alloc_resource(device_t dev, devi if (vtrans == NULL) { /* likely means above table needs to be updated */ device_printf(child, "%s: no mapping for 0x%lx:0x%lx\n", - __func__, start, end-start); + __func__, start, end - start); return NULL; } - rv = rman_reserve_resource(rmanp, start, end, end - start, - flags, child); - if (rv != NULL) - rman_set_rid(rv, *rid); + rv = rman_reserve_resource(&sc->sc_mem_rman, start, end, + end - start, flags, child); + if (rv == NULL) { + device_printf(child, "%s: cannot reserve 0x%lx:0x%lx\n", + __func__, start, end - start); + return NULL; + } + rman_set_rid(rv, *rid); break; default: rv = NULL; @@ -507,6 +508,14 @@ ixp425_alloc_resource(device_t dev, devi } static int +ixp425_release_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + /* NB: no private resources, just release */ + return rman_release_resource(r); +} + +static int ixp425_activate_resource(device_t dev, device_t child, int type, int rid, struct resource *r) { @@ -515,8 +524,11 @@ ixp425_activate_resource(device_t dev, d if (type == SYS_RES_MEMORY) { vtrans = gethwvtrans(rman_get_start(r), rman_get_size(r)); - if (vtrans == NULL) /* NB: should not happen */ + if (vtrans == NULL) { /* NB: should not happen */ + device_printf(child, "%s: no mapping for 0x%lx:0x%lx\n", + __func__, rman_get_start(r), rman_get_size(r)); return (ENOENT); + } if (vtrans->isa4x) rman_set_bustag(r, &ixp425_a4x_bs_tag); else @@ -526,6 +538,14 @@ ixp425_activate_resource(device_t dev, d return (rman_activate_resource(r)); } +static int +ixp425_deactivate_resource(device_t bus, device_t child, int type, int rid, + struct resource *r) +{ + /* NB: no private resources, just deactive */ + return (rman_deactivate_resource(r)); +} + static __inline void get_masks(struct resource *res, uint32_t *mask, uint32_t *mask2) { @@ -581,19 +601,21 @@ ixp425_teardown_intr(device_t dev, devic static device_method_t ixp425_methods[] = { /* Device interface */ - DEVMETHOD(device_probe, ixp425_probe), - DEVMETHOD(device_attach, ixp425_attach), - DEVMETHOD(device_identify, ixp425_identify), + DEVMETHOD(device_probe, ixp425_probe), + DEVMETHOD(device_attach, ixp425_attach), + DEVMETHOD(device_identify, ixp425_identify), /* Bus interface */ - DEVMETHOD(bus_add_child, ixp425_add_child), - DEVMETHOD(bus_hinted_child, ixp425_hinted_child), - DEVMETHOD(bus_read_ivar, ixp425_read_ivar), - - DEVMETHOD(bus_alloc_resource, ixp425_alloc_resource), - DEVMETHOD(bus_activate_resource, ixp425_activate_resource), - DEVMETHOD(bus_setup_intr, ixp425_setup_intr), - DEVMETHOD(bus_teardown_intr, ixp425_teardown_intr), + DEVMETHOD(bus_add_child, ixp425_add_child), + DEVMETHOD(bus_hinted_child, ixp425_hinted_child), + DEVMETHOD(bus_read_ivar, ixp425_read_ivar), + + DEVMETHOD(bus_alloc_resource, ixp425_alloc_resource), + DEVMETHOD(bus_release_resource, ixp425_release_resource), + DEVMETHOD(bus_activate_resource, ixp425_activate_resource), + DEVMETHOD(bus_deactivate_resource, ixp425_deactivate_resource), + DEVMETHOD(bus_setup_intr, ixp425_setup_intr), + DEVMETHOD(bus_teardown_intr, ixp425_teardown_intr), {0, 0}, };