diff options
| author | Warner Losh <imp@FreeBSD.org> | 2002-02-20 16:20:27 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2002-02-20 16:20:27 +0000 |
| commit | 4d8f4de40ef531af1874e3b5aa222076a9e92300 (patch) | |
| tree | dbf6be1c0d6dd5373a793de0a6995c7a3b01c794 /sys/dev | |
| parent | b65420f96831884f52ba4f6a39563f48e6bf746e (diff) | |
Notes
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/pccbb/pccbb.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c index 54b7fd41eb78..8b50aa9c12fe 100644 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -848,20 +848,16 @@ pccbb_event_thread(void *arg) /* * We take out Giant here because we drop it in tsleep - * and need it for kthread_exit, which drops it + * and need it for kthread_exit, which drops it. */ mtx_lock(&Giant); sc->flags |= PCCBB_KTHREAD_RUNNING; - for(;;) { + while (1) { /* - * Wait until it has been 1s since the last time we - * get an interrupt. + * Check to see if we have anything first so that + * if there's a card already inserted, we do the + * right thing. */ - tsleep (sc, PWAIT, "pccbbev", 0); - do { - err = tsleep (sc, PWAIT, "pccbbev", 1 * hz); - } while (err != EWOULDBLOCK && - (sc->flags & PCCBB_KTHREAD_DONE) == 0); mtx_lock(&sc->mtx); if (sc->flags & PCCBB_KTHREAD_DONE) break; @@ -872,10 +868,19 @@ pccbb_event_thread(void *arg) else pccbb_removal(sc); mtx_unlock(&sc->mtx); + /* + * Wait until it has been 1s since the last time we + * get an interrupt. We handle the rest of the interrupt + * at the top of the loop. + */ + tsleep (sc, PWAIT, "pccbbev", 0); + do { + err = tsleep (sc, PWAIT, "pccbbev", 1 * hz); + } while (err != EWOULDBLOCK && + (sc->flags & PCCBB_KTHREAD_DONE) == 0); } mtx_unlock(&sc->mtx); sc->flags &= ~PCCBB_KTHREAD_RUNNING; - wakeup(sc); /* * XXX I think there's a race here. If we wakeup in the other * thread before kthread_exit is called and this routine returns, @@ -883,6 +888,7 @@ pccbb_event_thread(void *arg) * ourselves up for a panic. Make sure that I check out * jhb's crash.c for a fix. */ + wakeup(sc); kthread_exit(0); } |
