From 3f199cc5e429abc4d955302d3a4ef3fb72cfdcd4 Mon Sep 17 00:00:00 2001 From: enami Date: Sat, 30 Oct 1999 00:58:32 +0000 Subject: [PATCH] Add and delete a reference to an adapter at aicattach(), to make sure that the adapter is disabled even if it wasn't enabled/disabled during configuring its children. This fixes the bug that if an aic pcmcia card is inserted in a slot during boot, further attaching of any card on the slot fails once the card is removed. --- sys/dev/ic/aic6360.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/dev/ic/aic6360.c b/sys/dev/ic/aic6360.c index 491f24dbbbf4..2dbb9560e390 100644 --- a/sys/dev/ic/aic6360.c +++ b/sys/dev/ic/aic6360.c @@ -1,4 +1,4 @@ -/* $NetBSD: aic6360.c,v 1.64 1999/10/20 15:22:26 enami Exp $ */ +/* $NetBSD: aic6360.c,v 1.65 1999/10/30 00:58:32 enami Exp $ */ #include "opt_ddb.h" #ifdef DDB @@ -269,8 +269,6 @@ aicattach(sc) sc->sc_minsync = (2 * 250) / sc->sc_freq; sc->sc_maxsync = (9 * 250) / sc->sc_freq; - aic_init(sc, 1); /* Init chip and driver */ - /* * Fill in the adapter. */ @@ -291,9 +289,22 @@ aicattach(sc) sc->sc_link.type = BUS_SCSI; /* - * ask the adapter what subunits are present + * Add reference to adapter so that we drop the reference after + * config_found() to make sure the adatper is disabled. + */ + if (scsipi_adapter_addref(&sc->sc_link) != 0) { + printf("%s: unable to enable controller\n", + sc->sc_dev.dv_xname); + return; + } + + aic_init(sc, 1); /* Init chip and driver */ + + /* + * Ask the adapter what subunits are present */ sc->sc_child = config_found(&sc->sc_dev, &sc->sc_link, scsiprint); + scsipi_adapter_delref(&sc->sc_link); } int