diff options
author | jhb <jhb@FreeBSD.org> | 2007-03-23 17:15:07 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2007-03-23 17:15:07 +0000 |
commit | 55f67dd8da67ce2dfbeef5af920c854ef0469b87 (patch) | |
tree | 4616a45caf09b3c2ace3dac22be5fc989d0c825f /sys/dev | |
parent | 508d98cfce8ae9e8371c7d93822a996cb5ef72bd (diff) | |
download | FreeBSD-src-55f67dd8da67ce2dfbeef5af920c854ef0469b87.zip FreeBSD-src-55f67dd8da67ce2dfbeef5af920c854ef0469b87.tar.gz |
- Fix exca_(io|mem)_map() to return proper errno values.
- Change exca_activate_resource() to call BUS_ACTIVATE_RESOURCE() before
calling exca_(io|mem)_map() since the latter use rman_get_bus(tag|handle)
and the recent changes to nexus(4) mean that you need to activate a
resource before reading the bus tag and handle. This was true before,
but now the nexus(4) drivers on x86 and ia64 are more forceful about it.
Reviewed by: imp
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/exca/exca.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/sys/dev/exca/exca.c b/sys/dev/exca/exca.c index a7ff956..6edae38 100644 --- a/sys/dev/exca/exca.c +++ b/sys/dev/exca/exca.c @@ -259,11 +259,11 @@ exca_mem_map(struct exca_softc *sc, int kind, struct resource *res) } } if (win >= EXCA_MEM_WINS) - return (1); + return (ENOSPC); if (((rman_get_start(res) >> EXCA_MEMREG_WIN_SHIFT) & 0xff) != 0 && (sc->flags & EXCA_HAS_MEMREG_WIN) == 0) { device_printf(sc->dev, "Does not support mapping above 24M."); - return (1); + return (EINVAL); } sc->mem[win].cardaddr = 0; @@ -301,7 +301,7 @@ exca_mem_unmap(struct exca_softc *sc, int window) } /* - * Find the map that we're using to hold the resoruce. This works well + * Find the map that we're using to hold the resource. This works well * so long as the client drivers don't do silly things like map the same * area mutliple times, or map both common and attribute memory at the * same time. This latter restriction is a bug. We likely should just @@ -477,7 +477,7 @@ exca_io_map(struct exca_softc *sc, int width, struct resource *r) } } if (win >= EXCA_IO_WINS) - return (1); + return (ENOSPC); sc->io[win].iot = rman_get_bustag(r); sc->io[win].ioh = rman_get_bushandle(r); @@ -789,24 +789,25 @@ exca_activate_resource(struct exca_softc *exca, device_t child, int type, int rid, struct resource *res) { int err; - if (!(rman_get_flags(res) & RF_ACTIVE)) { /* not already activated */ - switch (type) { - case SYS_RES_IOPORT: - err = exca_io_map(exca, PCCARD_WIDTH_AUTO, res); - break; - case SYS_RES_MEMORY: - err = exca_mem_map(exca, PCCARD_A_MEM_COM, res); - break; - default: - err = 0; - break; - } - if (err) - return (err); + if (rman_get_flags(res) & RF_ACTIVE) + return (0); + err = BUS_ACTIVATE_RESOURCE(device_get_parent(exca->dev), child, + type, rid, res); + if (err) + return (err); + switch (type) { + case SYS_RES_IOPORT: + err = exca_io_map(exca, PCCARD_WIDTH_AUTO, res); + break; + case SYS_RES_MEMORY: + err = exca_mem_map(exca, PCCARD_A_MEM_COM, res); + break; } - return (BUS_ACTIVATE_RESOURCE(device_get_parent(exca->dev), child, - type, rid, res)); + if (err) + BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child, + type, rid, res); + return (err); } int |