Hold a reference between atabus_attach() and atabusconfig() to avoid an extra

enable/disable cycle.  Now my CF card attaches a bit faster.

XXX This code is split strangely between files.
This commit is contained in:
mycroft 2004-08-10 23:09:38 +00:00
parent 8c50dac2a1
commit 32dee96c25
2 changed files with 10 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata.c,v 1.34 2004/08/04 22:44:04 bouyer Exp $ */ /* $NetBSD: ata.c,v 1.35 2004/08/10 23:09:38 mycroft Exp $ */
/* /*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.34 2004/08/04 22:44:04 bouyer Exp $"); __KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.35 2004/08/10 23:09:38 mycroft Exp $");
#ifndef WDCDEBUG #ifndef WDCDEBUG
#define WDCDEBUG #define WDCDEBUG
@ -237,6 +237,9 @@ atabus_attach(struct device *parent, struct device *self, void *aux)
aprint_normal("\n"); aprint_normal("\n");
aprint_naive("\n"); aprint_naive("\n");
if (wdc_addref(chp))
return;
initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK); initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK);
initq->atabus_sc = sc; initq->atabus_sc = sc;
TAILQ_INSERT_TAIL(&atabus_initq_head, initq, atabus_initq); TAILQ_INSERT_TAIL(&atabus_initq_head, initq, atabus_initq);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc.c,v 1.188 2004/08/10 02:40:51 mycroft Exp $ */ /* $NetBSD: wdc.c,v 1.189 2004/08/10 23:09:39 mycroft Exp $ */
/* /*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved.
@ -70,7 +70,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.188 2004/08/10 02:40:51 mycroft Exp $"); __KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.189 2004/08/10 23:09:39 mycroft Exp $");
#ifndef WDCDEBUG #ifndef WDCDEBUG
#define WDCDEBUG #define WDCDEBUG
@ -361,16 +361,9 @@ atabusconfig(struct atabus_softc *atabus_sc)
{ {
struct wdc_channel *chp = atabus_sc->sc_chan; struct wdc_channel *chp = atabus_sc->sc_chan;
struct wdc_softc *wdc = chp->ch_wdc; struct wdc_softc *wdc = chp->ch_wdc;
int i, error, need_delref = 0; int i;
struct atabus_initq *atabus_initq = NULL; struct atabus_initq *atabus_initq = NULL;
if ((error = wdc_addref(chp)) != 0) {
aprint_error("%s: unable to enable controller\n",
wdc->sc_dev.dv_xname);
goto out;
}
need_delref = 1;
/* Probe for the drives. */ /* Probe for the drives. */
(*wdc->drv_probe)(chp); (*wdc->drv_probe)(chp);
@ -480,8 +473,8 @@ atabusconfig(struct atabus_softc *atabus_sc)
wakeup(&atabus_initq_head); wakeup(&atabus_initq_head);
config_pending_decr(); config_pending_decr();
if (need_delref)
wdc_delref(chp); wdc_delref(chp);
} }
int int