Implement a flag to indicate that the driver attached correctly.
This is useful in the case where an attachment's probe routine verifies that there is indeed hardware present but something goes "wrong" in the attach causing the device to be unusable. (Without keeping track of this, in that case incorrect ports could be accessed or uninitted pointers could be deferenced on open or at other times.)
This commit is contained in:
parent
f41c5d7661
commit
c2f42b2213
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: com.c,v 1.131 1998/02/01 23:33:01 marc Exp $ */
|
||||
/* $NetBSD: com.c,v 1.132 1998/02/02 22:54:55 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
||||
@ -513,6 +513,8 @@ com_attach_subr(sc)
|
||||
sc->enabled = 1;
|
||||
|
||||
com_config(sc);
|
||||
|
||||
SET(sc->sc_hwflags, COM_HW_DEV_OK);
|
||||
}
|
||||
|
||||
void
|
||||
@ -590,7 +592,7 @@ comopen(dev, flag, mode, p)
|
||||
if (unit >= com_cd.cd_ndevs)
|
||||
return (ENXIO);
|
||||
sc = com_cd.cd_devs[unit];
|
||||
if (!sc)
|
||||
if (!sc || !ISSET(sc->sc_hwflags, COM_HW_DEV_OK))
|
||||
return (ENXIO);
|
||||
|
||||
#ifdef KGDB
|
||||
@ -1590,7 +1592,7 @@ comsoft(arg)
|
||||
|
||||
for (unit = 0; unit < com_cd.cd_ndevs; unit++) {
|
||||
sc = com_cd.cd_devs[unit];
|
||||
if (sc == NULL)
|
||||
if (sc == NULL || !ISSET(sc->sc_hwflags, COM_HW_DEV_OK))
|
||||
continue;
|
||||
|
||||
if (!sc->enabled)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: comvar.h,v 1.20 1998/02/01 23:30:49 marc Exp $ */
|
||||
/* $NetBSD: comvar.h,v 1.21 1998/02/02 22:55:00 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
|
||||
@ -48,6 +48,7 @@ int com_is_console __P((bus_space_tag_t, int, bus_space_handle_t *));
|
||||
#define COM_HW_FIFO 0x02
|
||||
#define COM_HW_HAYESP 0x04
|
||||
#define COM_HW_FLOW 0x08
|
||||
#define COM_HW_DEV_OK 0x20
|
||||
#define COM_HW_CONSOLE 0x40
|
||||
#define COM_HW_KGDB 0x80
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lpt.c,v 1.48 1998/01/12 09:23:29 thorpej Exp $ */
|
||||
/* $NetBSD: lpt.c,v 1.49 1998/02/02 22:55:03 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Charles Hannum.
|
||||
@ -107,6 +107,8 @@ lpt_attach_subr(sc)
|
||||
ioh = sc->sc_ioh;
|
||||
|
||||
bus_space_write_1(iot, ioh, lpt_control, LPC_NINIT);
|
||||
|
||||
sc->sc_dev_ok = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -131,7 +133,7 @@ lptopen(dev, flag, mode, p)
|
||||
if (unit >= lpt_cd.cd_ndevs)
|
||||
return ENXIO;
|
||||
sc = lpt_cd.cd_devs[unit];
|
||||
if (!sc)
|
||||
if (!sc || !sc->sc_dev_ok)
|
||||
return ENXIO;
|
||||
|
||||
#if 0 /* XXX what to do? */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lptvar.h,v 1.47 1997/12/07 16:09:37 thorpej Exp $ */
|
||||
/* $NetBSD: lptvar.h,v 1.48 1998/02/02 22:55:06 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994 Charles Hannum.
|
||||
@ -65,6 +65,7 @@ struct lpt_softc {
|
||||
int sc_spinmax;
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
u_char sc_dev_ok; /* device attached correctly */
|
||||
u_char sc_state;
|
||||
#define LPT_OPEN 0x01 /* device is open */
|
||||
#define LPT_OBUSY 0x02 /* printer is busy doing output */
|
||||
|
Loading…
Reference in New Issue
Block a user