KNF and cosmetics.

This commit is contained in:
tsutsui 2010-04-12 12:28:59 +00:00
parent f900625cc5
commit 09adc53649
1 changed files with 41 additions and 39 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dma.c,v 1.25 2010/04/10 18:02:05 tsutsui Exp $ */
/* $NetBSD: dma.c,v 1.26 2010/04/12 12:28:59 tsutsui Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman.
@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dma.c,v 1.25 2010/04/10 18:02:05 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: dma.c,v 1.26 2010/04/12 12:28:59 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -89,7 +89,7 @@ static void st_dma_init(void);
static void
st_dma_init(void)
{
int i;
int i;
TAILQ_INIT(&dma_free);
TAILQ_INIT(&dma_active);
@ -102,23 +102,24 @@ st_dma_init(void)
}
int
st_dmagrab(dma_farg int_func, dma_farg call_func, void *softc, int *lock_stat, int rcaller)
st_dmagrab(dma_farg int_func, dma_farg call_func, void *softc, int *lock_stat,
int rcaller)
{
int sps;
DMA_ENTRY *req;
int s;
DMA_ENTRY *req;
if(must_init) {
if (must_init) {
st_dma_init();
must_init = 0;
}
*lock_stat = DMA_LOCK_REQ;
sps = splhigh();
s = splhigh();
/*
* Create a request...
*/
if(dma_free.tqh_first == NULL)
if (dma_free.tqh_first == NULL)
panic("st_dmagrab: Too many outstanding requests");
req = dma_free.tqh_first;
TAILQ_REMOVE(&dma_free, dma_free.tqh_first, entries);
@ -128,50 +129,50 @@ st_dmagrab(dma_farg int_func, dma_farg call_func, void *softc, int *lock_stat, i
req->lock_stat = lock_stat;
TAILQ_INSERT_TAIL(&dma_active, req, entries);
if(dma_active.tqh_first != req) {
if (dma_active.tqh_first != req) {
if (call_func == NULL) {
do {
tsleep(&dma_active, PRIBIO, "dmalck", 0);
} while (*req->lock_stat != DMA_LOCK_GRANT);
splx(sps);
return(1);
splx(s);
return 1;
}
splx(sps);
return(0);
splx(s);
return 0;
}
splx(sps);
splx(s);
/*
* We're at the head of the queue, ergo: we got the lock.
*/
*lock_stat = DMA_LOCK_GRANT;
if(rcaller || (call_func == NULL)) {
if (rcaller || (call_func == NULL)) {
/*
* Just return to caller immediately without going
* through 'call_func' first.
*/
return(1);
return 1;
}
(*call_func)(softc); /* Call followup function */
return(0);
return 0;
}
void
st_dmafree(void *softc, int *lock_stat)
{
int sps;
DMA_ENTRY *req;
int s;
DMA_ENTRY *req;
sps = splhigh();
s = splhigh();
/*
* Some validity checks first.
*/
if((req = dma_active.tqh_first) == NULL)
if ((req = dma_active.tqh_first) == NULL)
panic("st_dmafree: empty active queue");
if(req->softc != softc)
if (req->softc != softc)
printf("Caller of st_dmafree is not lock-owner!\n");
/*
@ -181,37 +182,37 @@ st_dmafree(void *softc, int *lock_stat)
TAILQ_REMOVE(&dma_active, req, entries);
TAILQ_INSERT_HEAD(&dma_free, req, entries);
if((req = dma_active.tqh_first) != NULL) {
if ((req = dma_active.tqh_first) != NULL) {
*req->lock_stat = DMA_LOCK_GRANT;
if (req->call_func == NULL)
wakeup((void *)&dma_active);
else {
/*
* Call next request through softint handler. This avoids
* spl-conflicts.
*/
add_sicallback((si_farg)req->call_func, req->softc, 0);
/*
* Call next request through softint handler.
* This avoids spl-conflicts.
*/
add_sicallback((si_farg)req->call_func, req->softc, 0);
}
}
splx(sps);
return;
splx(s);
}
int
st_dmawanted(void)
{
return(dma_active.tqh_first->entries.tqe_next != NULL);
return dma_active.tqh_first->entries.tqe_next != NULL;
}
int
cdmaint(void *unused, int sr)
/* sr: sr at time of interrupt */
{
dma_farg int_func;
void *softc;
dma_farg int_func;
void *softc;
if(dma_active.tqh_first != NULL) {
if (dma_active.tqh_first != NULL) {
/*
* Due to the logic of the ST-DMA chip, it is not possible to
* check for stray interrupts here...
@ -229,9 +230,9 @@ cdmaint(void *unused, int sr)
* Note: The order _is_ important!
*/
void
st_dmaaddr_set(void * address)
st_dmaaddr_set(void *address)
{
register u_long ad = (u_long)address;
u_long ad = (u_long)address;
DMA->dma_addr[AD_LOW ] = (ad ) & 0xff;
DMA->dma_addr[AD_MID ] = (ad >> 8) & 0xff;
@ -244,12 +245,12 @@ st_dmaaddr_set(void * address)
u_long
st_dmaaddr_get(void)
{
register u_long ad = 0;
u_long ad = 0;
ad = (DMA->dma_addr[AD_LOW ] & 0xff);
ad |= (DMA->dma_addr[AD_MID ] & 0xff) << 8;
ad |= (DMA->dma_addr[AD_HIGH] & 0xff) <<16;
return(ad);
return ad;
}
/*
@ -259,6 +260,7 @@ st_dmaaddr_get(void)
void
st_dmacomm(int mode, int nblk)
{
DMA->dma_mode = mode;
DMA->dma_mode = mode ^ DMA_WRBIT;
DMA->dma_mode = mode;