diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 2004-09-15 12:09:50 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2004-09-15 12:09:50 +0000 |
commit | 7ce1979be60a3be2a6a9232ca0548066c15d1205 (patch) | |
tree | 56e89a43c4b2e1186b0edeeb3e43382456e0543e /sys/i386/isa | |
parent | 5757a0b9856c8a74383d360027753adeccc382bb (diff) | |
download | src-7ce1979be60a3be2a6a9232ca0548066c15d1205.tar.gz src-7ce1979be60a3be2a6a9232ca0548066c15d1205.zip |
Add new a function isa_dma_init() which returns an errno when it fails
and which takes a M_WAITOK/M_NOWAIT flag argument.
Add compatibility isa_dmainit() macro which whines loudly if
isa_dma_init() fails.
Problem uncovered by: tegge
Notes
Notes:
svn path=/head/; revision=135262
Diffstat (limited to 'sys/i386/isa')
-rw-r--r-- | sys/i386/isa/isa_dma.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/sys/i386/isa/isa_dma.c b/sys/i386/isa/isa_dma.c index 23dc07de0978..1739871ecc34 100644 --- a/sys/i386/isa/isa_dma.c +++ b/sys/i386/isa/isa_dma.c @@ -94,15 +94,13 @@ static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a }; /* * Setup a DMA channel's bounce buffer. */ -void -isa_dmainit(chan, bouncebufsize) - int chan; - u_int bouncebufsize; +int +isa_dma_init(int chan, u_int bouncebufsize, int flag) { void *buf; /* - * If a DMA channel is shared, both drivers have to call isa_dmainit + * If a DMA channel is shared, both drivers have to call isa_dma_init * since they don't know that the other driver will do it. * Just return if we're already set up good. * XXX: this only works if they agree on the bouncebuf size. This @@ -110,30 +108,30 @@ isa_dmainit(chan, bouncebufsize) * XXX: the same driver. */ if (dma_bouncebuf[chan] != NULL) - return; + return (0); #ifdef DIAGNOSTIC if (chan & ~VALID_DMA_MASK) - panic("isa_dmainit: channel out of range"); + panic("isa_dma_init: channel out of range"); #endif dma_bouncebufsize[chan] = bouncebufsize; /* Try malloc() first. It works better if it works. */ - buf = malloc(bouncebufsize, M_DEVBUF, M_NOWAIT); + buf = malloc(bouncebufsize, M_DEVBUF, flag); if (buf != NULL) { if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) { dma_bouncebuf[chan] = buf; - return; + return (0); } free(buf, M_DEVBUF); } - buf = contigmalloc(bouncebufsize, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful, + buf = contigmalloc(bouncebufsize, M_DEVBUF, flag, 0ul, 0xfffffful, 1ul, chan & 4 ? 0x20000ul : 0x10000ul); if (buf == NULL) - printf("isa_dmainit(%d, %d) failed\n", chan, bouncebufsize); - else - dma_bouncebuf[chan] = buf; + return (ENOMEM); + dma_bouncebuf[chan] = buf; + return (0); } /* |