diff options
author | dgregor <dgregor@cvs.openbsd.org> | 1997-08-04 09:57:20 +0000 |
---|---|---|
committer | dgregor <dgregor@cvs.openbsd.org> | 1997-08-04 09:57:20 +0000 |
commit | e0e150bafa73a98e455b9e4ea6c69e30a8c47cad (patch) | |
tree | 2c623cb012c789e1a2913160ac25e04a6c78bf3c /sys/dev/ic/cy.c | |
parent | 6aa02c92996304dfbe4fc528b8c073de88c67758 (diff) |
Change disable_intr()/enable_intr() to splhigh()/splx().
Fix bug of 'tp' not being initialized in cyopen - patch from Theo de Raadt.
Thanks to Niklas Hallqvist and Theo de Raadt for finding this bug.
Diffstat (limited to 'sys/dev/ic/cy.c')
-rw-r--r-- | sys/dev/ic/cy.c | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/sys/dev/ic/cy.c b/sys/dev/ic/cy.c index c81a6ab0da3..9969c7a7603 100644 --- a/sys/dev/ic/cy.c +++ b/sys/dev/ic/cy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cy.c,v 1.7 1996/12/03 11:08:28 deraadt Exp $ */ +/* $OpenBSD: cy.c,v 1.8 1997/08/04 09:57:19 dgregor Exp $ */ /* * cy.c @@ -20,8 +20,6 @@ * * This version uses the bus_space/io_??() stuff * - * NOT TESTED !!! - * */ #undef CY_DEBUG @@ -62,11 +60,13 @@ #include <dev/ic/cd1400reg.h> #include <dev/ic/cyreg.h> + /* Macros to clear/set/test flags. */ #define SET(t, f) (t) |= (f) #define CLR(t, f) (t) &= ~(f) #define ISSET(t, f) ((t) & (f)) + void cyattach __P((struct device *, struct device *, void *)); int cy_probe_common __P((int, bus_space_tag_t, bus_space_handle_t, int)); int cyintr __P((void *)); @@ -88,6 +88,7 @@ static bus_space_handle_t cy_card_memh[NCY]; static int cy_open = 0; static int cy_events = 0; + /* * Common probe routine */ @@ -346,6 +347,7 @@ cyopen(dev, flag, mode, p) } splx(s); + tp = cy->cy_tty; tty_attach(tp); tp = cy->cy_tty; tp->t_oproc = cystart; @@ -993,23 +995,17 @@ cy_poll(arg) int did_something; #endif - /* XXX */ -#ifdef i386 - disable_intr(); -#endif + int s; + + s = splhigh(); + if(cy_events == 0 && ++counter < 200) { - /* XXX */ -#ifdef i386 - enable_intr(); -#endif + splx(s); goto out; } cy_events = 0; - /* XXX */ -#ifdef i386 - enable_intr(); -#endif + splx(s); for(card = 0; card < cy_cd.cd_ndevs; card++) { sc = cy_cd.cd_devs[card]; @@ -1054,16 +1050,10 @@ cy_poll(arg) (*linesw[tp->t_line].l_rint)(chr, tp); - /* XXX */ -#ifdef i386 - disable_intr(); /* really necessary? */ -#endif + s = splhigh(); /* really necessary? */ if((cy->cy_ibuf_rd_ptr += 2) == cy->cy_ibuf_end) cy->cy_ibuf_rd_ptr = cy->cy_ibuf; - /* XXX */ -#ifdef i386 - enable_intr(); -#endif + splx(s); #ifdef CY_DEBUG1 did_something = 1; @@ -1092,12 +1082,12 @@ cy_poll(arg) /* * handle carrier changes */ - disable_intr(); + s = splhigh(); if(ISSET(cy->cy_flags, CYF_CARRIER_CHANGED)) { int carrier; CLR(cy->cy_flags, CYF_CARRIER_CHANGED); - enable_intr(); + splx(s); carrier = ((cy->cy_carrier_stat & CD1400_MSVR2_CD) != 0); @@ -1114,13 +1104,13 @@ cy_poll(arg) did_something = 1; #endif } else { - enable_intr(); + splx(s); } - disable_intr(); + s = splhigh(); if(ISSET(cy->cy_flags, CYF_START)) { CLR(cy->cy_flags, CYF_START); - enable_intr(); + splx(s); (*linesw[tp->t_line].l_start)(tp); @@ -1128,7 +1118,7 @@ cy_poll(arg) did_something = 1; #endif } else { - enable_intr(); + splx(s); } /* could move this to even upper level... */ @@ -1411,11 +1401,12 @@ void cy_enable_transmitter(cy) struct cy_port *cy; { - disable_intr(); + int s; + s = splhigh(); cd_write_reg(cy, CD1400_CAR, cy->cy_port_num & CD1400_CAR_CHAN); cd_write_reg(cy, CD1400_SRER, cd_read_reg(cy, CD1400_SRER) | CD1400_SRER_TXRDY); - enable_intr(); + splx(s); } /* |