Make sure to mark the device as dying already in the (de)activate routine.

This avoids access to it before the detach routine has blown it away.
This commit is contained in:
augustss 1999-08-23 22:55:14 +00:00
parent 007da22e55
commit 1f2661798f
8 changed files with 93 additions and 11 deletions

View File

@ -24,3 +24,7 @@ memory allocator from an interrupt context.
Move memory allocation and copying to HC independent code.
Use a TD chain in ohci.c to allow transfers > 8K.
Document device driver API.
Document HC driver API.

View File

@ -1,4 +1,4 @@
/* $NetBSD: ugen.c,v 1.17 1999/08/22 20:12:39 augustss Exp $ */
/* $NetBSD: ugen.c,v 1.18 1999/08/23 22:55:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -589,6 +589,17 @@ ugen_activate(self, act)
struct device *self;
enum devact act;
{
struct ugen_softc *sc = (struct ugen_softc *)self;
switch (act) {
case DVACT_ACTIVATE:
return (EOPNOTSUPP);
break;
case DVACT_DEACTIVATE:
sc->sc_dying = 1;
break;
}
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uhid.c,v 1.20 1999/08/17 16:06:21 augustss Exp $ */
/* $NetBSD: uhid.c,v 1.21 1999/08/23 22:55:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -242,6 +242,17 @@ uhid_activate(self, act)
struct device *self;
enum devact act;
{
struct uhid_softc *sc = (struct uhid_softc *)self;
switch (act) {
case DVACT_ACTIVATE:
return (EOPNOTSUPP);
break;
case DVACT_DEACTIVATE:
sc->sc_dying = 1;
break;
}
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uhub.c,v 1.22 1999/08/22 20:12:39 augustss Exp $ */
/* $NetBSD: uhub.c,v 1.23 1999/08/23 22:55:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -490,6 +490,14 @@ uhub_activate(self, act)
struct device *self;
enum devact act;
{
switch (act) {
case DVACT_ACTIVATE:
return (EOPNOTSUPP);
break;
case DVACT_DEACTIVATE:
break;
}
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ukbd.c,v 1.39 1999/08/14 14:49:32 augustss Exp $ */
/* $NetBSD: ukbd.c,v 1.40 1999/08/23 22:55:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -194,6 +194,8 @@ struct ukbd_softc {
int sc_npollchar;
u_int16_t sc_pollchars[MAXKEYS];
#endif /* defined(__NetBSD__) */
u_char sc_dying;
};
#define UKBDUNIT(dev) (minor(dev))
@ -355,6 +357,9 @@ ukbd_enable(v, on)
struct ukbd_softc *sc = v;
usbd_status r;
if (on && sc->sc_dying)
return (EIO);
/* Should only be called to change state */
if (sc->sc_enabled == on) {
#ifdef DIAGNOSTIC
@ -388,6 +393,17 @@ ukbd_activate(self, act)
struct device *self;
enum devact act;
{
struct ukbd_softc *sc = (struct ukbd_softc *)self;
switch (act) {
case DVACT_ACTIVATE:
return (EOPNOTSUPP);
break;
case DVACT_DEACTIVATE:
sc->sc_dying = 1;
break;
}
return (0);
}
@ -555,6 +571,9 @@ ukbd_set_leds(v, leds)
DPRINTF(("ukbd_set_leds: sc=%p leds=%d\n", sc, leds));
if (sc->sc_dying)
return;
sc->sc_leds = leds;
res = 0;
if (leds & WSKBD_LED_SCROLL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulpt.c,v 1.16 1999/08/23 22:35:19 augustss Exp $ */
/* $NetBSD: ulpt.c,v 1.17 1999/08/23 22:55:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -224,6 +224,17 @@ ulpt_activate(self, act)
struct device *self;
enum devact act;
{
struct ulpt_softc *sc = (struct ulpt_softc *)self;
switch (act) {
case DVACT_ACTIVATE:
return (EOPNOTSUPP);
break;
case DVACT_DEACTIVATE:
sc->sc_dying = 1;
break;
}
return (0);
}
@ -461,12 +472,12 @@ ulptioctl(dev, cmd, data, flag, p)
error = ENODEV;
}
return error;
return (error);
}
/* XXX This does not belong here. */
/*
* Print secelect parts of a IEEE 1284 device ID.
* Print select parts of a IEEE 1284 device ID.
*/
void
ieee1284_print_id(str)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ums.c,v 1.27 1999/08/16 23:36:25 augustss Exp $ */
/* $NetBSD: ums.c,v 1.28 1999/08/23 22:55:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -107,6 +107,8 @@ struct ums_softc {
u_int32_t sc_buttons; /* mouse button status */
struct device *sc_wsmousedev;
char sc_dying;
};
#define MOUSE_FLAGS_MASK (HIO_CONST|HIO_RELATIVE)
@ -298,6 +300,17 @@ ums_activate(self, act)
struct device *self;
enum devact act;
{
struct ums_softc *sc = (struct ums_softc *)self;
switch (act) {
case DVACT_ACTIVATE:
return (EOPNOTSUPP);
break;
case DVACT_DEACTIVATE:
sc->sc_dying = 1;
break;
}
return (0);
}
@ -381,8 +394,12 @@ ums_enable(v)
usbd_status r;
DPRINTFN(1,("ums_enable: sc=%p\n", sc));
if (sc->sc_dying)
return (EIO);
if (sc->sc_enabled)
return EBUSY;
return (EBUSY);
sc->sc_enabled = 1;
sc->sc_buttons = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: usbdi.c,v 1.31 1999/08/22 20:12:39 augustss Exp $ */
/* $NetBSD: usbdi.c,v 1.32 1999/08/23 22:55:14 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -625,7 +625,8 @@ usb_transfer_complete(reqh)
usbd_pipe_handle pipe = reqh->pipe;
int polling;
DPRINTFN(5, ("usb_transfer_complete: pipe=%p reqh=%p\n", pipe, reqh));
DPRINTFN(5, ("usb_transfer_complete: pipe=%p reqh=%p actlen=%d\n",
pipe, reqh, reqh->actlen));
#ifdef DIAGNOSTIC
if (!pipe) {