From 32dee96c25c2d5c74b2ffa84cdad4f24d12b89a8 Mon Sep 17 00:00:00 2001 From: mycroft Date: Tue, 10 Aug 2004 23:09:38 +0000 Subject: [PATCH] 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. --- sys/dev/ata/ata.c | 7 +++++-- sys/dev/ic/wdc.c | 17 +++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c index 31cf1ad05ad8..fcb9c97f3b8d 100644 --- a/sys/dev/ata/ata.c +++ b/sys/dev/ata/ata.c @@ -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. @@ -30,7 +30,7 @@ */ #include -__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 #define WDCDEBUG @@ -237,6 +237,9 @@ atabus_attach(struct device *parent, struct device *self, void *aux) aprint_normal("\n"); aprint_naive("\n"); + if (wdc_addref(chp)) + return; + initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK); initq->atabus_sc = sc; TAILQ_INSERT_TAIL(&atabus_initq_head, initq, atabus_initq); diff --git a/sys/dev/ic/wdc.c b/sys/dev/ic/wdc.c index 18c2ee5d6ee9..63ecf3b11614 100644 --- a/sys/dev/ic/wdc.c +++ b/sys/dev/ic/wdc.c @@ -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. @@ -70,7 +70,7 @@ */ #include -__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 #define WDCDEBUG @@ -361,16 +361,9 @@ atabusconfig(struct atabus_softc *atabus_sc) { struct wdc_channel *chp = atabus_sc->sc_chan; struct wdc_softc *wdc = chp->ch_wdc; - int i, error, need_delref = 0; + int i; 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. */ (*wdc->drv_probe)(chp); @@ -480,8 +473,8 @@ atabusconfig(struct atabus_softc *atabus_sc) wakeup(&atabus_initq_head); config_pending_decr(); - if (need_delref) - wdc_delref(chp); + + wdc_delref(chp); } int