Date: Tue, 26 Dec 1995 13:36:59 +0500 (GMT+0500) From: "Serge A. Babkin" <babkin@hq.icb.chel.su> To: bde@zeta.org.au (Bruce Evans) Cc: hackers@freebsd.org Subject: Re: Digiboard patch Message-ID: <199512260836.NAA25821@hq.icb.chel.su> In-Reply-To: <199512221447.BAA14659@godzilla.zeta.org.au> from "Bruce Evans" at Dec 23, 95 01:47:02 am
next in thread | previous in thread | raw e-mail | index | archive | help
> This was slightly better before. The comment no longer matches the code.
> But to be correct, the state should be left at DC_UNCONFIGURED when the
> device is first registered, then set to DC_BUSY when a subdevice is
> attached (since you're not bothering to keep track of opens).
>
> Note that setting DC_* in kdc_dgb[0].kdc_state clobbers the template.
> In general you have to worry about all the fields in the template being
> changed as device 0 is attached, used and detached, so the template
> shouldn't be in kdc_xxx[0]. This bug has been copied into about 100
> drivers :-(.
This patch must fix these problems. Commit it please (if you think that
it is worth). Thank you!
----------------------------------- cut here ---------------------------
*** dgb.c 1995/12/22 11:09:12
--- dgb.c 1995/12/26 08:26:21
***************
*** 427,433 ****
return 4; /* we need I/O space of 4 ports */
}
! static struct kern_devconf kdc_dgb[NDGB] = { {
0, 0, 0, /* filled in by dev_attach */
"dgb", 0, { MDDT_ISA, 0, "tty" },
isa_generic_externalize, 0, 0, ISA_EXTERNALLEN,
--- 427,434 ----
return 4; /* we need I/O space of 4 ports */
}
! static struct kern_devconf kdc_dgb[NDGB];
! static struct kern_devconf kdc_dgb_init = {
0, 0, 0, /* filled in by dev_attach */
"dgb", 0, { MDDT_ISA, 0, "tty" },
isa_generic_externalize, 0, 0, ISA_EXTERNALLEN,
***************
*** 436,442 ****
DC_UNCONFIGURED,
"DigiBoard multiport card",
DC_CLS_SERIAL,
! } };
static void
dgbregisterdev(id)
--- 437,443 ----
DC_UNCONFIGURED,
"DigiBoard multiport card",
DC_CLS_SERIAL,
! };
static void
dgbregisterdev(id)
***************
*** 445,457 ****
int unit;
unit = id->id_unit;
! if (unit != 0)
! kdc_dgb[unit] = kdc_dgb[0];
kdc_dgb[unit].kdc_unit = unit;
kdc_dgb[unit].kdc_isa = id;
! /* now we assume that multiport is always 'open' for simplicity */
! kdc_dgb[unit].kdc_state = DC_UNKNOWN;
dev_attach(&kdc_dgb[unit]);
}
--- 446,457 ----
int unit;
unit = id->id_unit;
! kdc_dgb[unit] = kdc_dgb_init;
kdc_dgb[unit].kdc_unit = unit;
kdc_dgb[unit].kdc_isa = id;
! /* no ports are open yet */
! kdc_dgb[unit].kdc_state = DC_IDLE;
dev_attach(&kdc_dgb[unit]);
}
***************
*** 1037,1042 ****
--- 1037,1048 ----
port->active_out = TRUE;
port->used=1;
+
+ /* If any port is open (i.e. the open() call is completed for it)
+ * the device is busy
+ */
+
+ kdc_dgb[unit].kdc_state = DC_BUSY;
out:
splx(s);
***************
*** 1063,1068 ****
--- 1069,1075 ----
struct dgb_softc *sc;
struct dgb_p *port;
int s;
+ int i;
mynor=minor(dev);
unit=MINOR_TO_UNIT(mynor);
***************
*** 1086,1091 ****
--- 1093,1107 ----
ttyclose(tp);
port->closing=0; wakeup(&port->closing);
port->used=0;
+
+ /* mark the card idle when all ports are closed */
+
+ for(i=0; i<sc->numports; i++)
+ if(sc->ports[i].used)
+ break;
+
+ if(i>= sc->numports)
+ kdc_dgb[unit].kdc_state = DC_IDLE;
splx(s);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199512260836.NAA25821>
