Add a reference count to avoid detaching while the attach is still
waiting.
This commit is contained in:
parent
117844eb75
commit
50e312d584
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: umass.c,v 1.94 2003/01/06 12:46:11 wiz Exp $ */
|
||||
/* $NetBSD: umass.c,v 1.95 2003/02/16 23:14:06 augustss Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>,
|
||||
* Nick Hibma <n_hibma@freebsd.org>
|
||||
|
@ -94,7 +94,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.94 2003/01/06 12:46:11 wiz Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.95 2003/02/16 23:14:06 augustss Exp $");
|
||||
|
||||
#include "atapibus.h"
|
||||
#include "scsibus.h"
|
||||
|
@ -107,7 +107,6 @@ __KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.94 2003/01/06 12:46:11 wiz Exp $");
|
|||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/buf.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/malloc.h>
|
||||
#undef KASSERT
|
||||
#define KASSERT(cond, msg)
|
||||
|
@ -603,7 +602,7 @@ USB_DETACH(umass)
|
|||
{
|
||||
USB_DETACH_START(umass, sc);
|
||||
struct umassbus_softc *scbus = sc->bus;
|
||||
int rv = 0, i;
|
||||
int rv = 0, i, s;
|
||||
|
||||
DPRINTF(UDMASS_USB, ("%s: detached\n", USBDEVNAME(sc->sc_dev)));
|
||||
|
||||
|
@ -613,15 +612,16 @@ USB_DETACH(umass)
|
|||
usbd_abort_pipe(sc->sc_pipe[i]);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Do we really need reference counting? Perhaps in ioctl() */
|
||||
s = splusb();
|
||||
if (--sc->sc_refcnt >= 0) {
|
||||
#ifdef DIAGNOSTIC
|
||||
printf("%s: waiting for refcnt\n", USBDEVNAME(sc->sc_dev));
|
||||
#endif
|
||||
/* Wait for processes to go away. */
|
||||
usb_detach_wait(USBDEV(sc->sc_dev));
|
||||
}
|
||||
splx(s);
|
||||
#endif
|
||||
|
||||
if (scbus != NULL) {
|
||||
if (scbus->sc_child != NULL)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: umass_scsipi.c,v 1.8 2003/01/21 20:56:57 augustss Exp $ */
|
||||
/* $NetBSD: umass_scsipi.c,v 1.9 2003/02/16 23:14:08 augustss Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.8 2003/01/21 20:56:57 augustss Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.9 2003/02/16 23:14:08 augustss Exp $");
|
||||
|
||||
#include "atapibus.h"
|
||||
#include "scsibus.h"
|
||||
|
@ -140,8 +140,12 @@ umass_scsi_attach(struct umass_softc *sc)
|
|||
scbus->sc_channel.chan_id = UMASS_SCSIID_HOST;
|
||||
DPRINTF(UDMASS_USB, ("%s: umass_attach_bus: SCSI\n",
|
||||
USBDEVNAME(sc->sc_dev)));
|
||||
|
||||
sc->sc_refcnt++;
|
||||
scbus->base.sc_child =
|
||||
config_found(&sc->sc_dev, &scbus->sc_channel, scsipiprint);
|
||||
if (--sc->sc_refcnt < 0)
|
||||
usb_detach_wakeup(USBDEV(sc->sc_dev));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -163,8 +167,12 @@ umass_atapi_attach(struct umass_softc *sc)
|
|||
scbus->sc_channel.chan_defquirks |= sc->sc_busquirks;
|
||||
DPRINTF(UDMASS_USB, ("%s: umass_attach_bus: ATAPI\n",
|
||||
USBDEVNAME(sc->sc_dev)));
|
||||
|
||||
sc->sc_refcnt++;
|
||||
scbus->base.sc_child =
|
||||
config_found(&sc->sc_dev, &scbus->sc_channel, scsipiprint);
|
||||
if (--sc->sc_refcnt < 0)
|
||||
usb_detach_wakeup(USBDEV(sc->sc_dev));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: umassvar.h,v 1.17 2002/12/06 03:57:51 erh Exp $ */
|
||||
/* $NetBSD: umassvar.h,v 1.18 2003/02/16 23:14:08 augustss Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>,
|
||||
* Nick Hibma <n_hibma@freebsd.org>
|
||||
|
@ -265,6 +265,7 @@ struct umass_softc {
|
|||
|
||||
int sc_xfer_flags;
|
||||
char sc_dying;
|
||||
int sc_refcnt;
|
||||
|
||||
struct umassbus_softc *bus; /* bus dependent data */
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue