From: ratchov Date: Tue, 12 May 2015 18:39:30 +0000 (+0000) Subject: remove the sc->isopen flag, as sc->flags already hold the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c8d03e3ab40c78998909f362d425655e2588b41d;p=openbsd remove the sc->isopen flag, as sc->flags already hold the same information. --- diff --git a/sys/dev/midi.c b/sys/dev/midi.c index 001a8ea0389..e83997e014b 100644 --- a/sys/dev/midi.c +++ b/sys/dev/midi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.37 2015/05/12 18:32:49 ratchov Exp $ */ +/* $OpenBSD: midi.c,v 1.38 2015/05/12 18:39:30 ratchov Exp $ */ /* * Copyright (c) 2003, 2004 Alexandre Ratchov @@ -84,7 +84,7 @@ midi_iintr(void *addr, int data) struct midi_softc *sc = (struct midi_softc *)addr; struct midi_buffer *mb = &sc->inbuf; - if (sc->isdying || !sc->isopen || !(sc->flags & FREAD)) + if (sc->isdying || !(sc->flags & FREAD)) return; if (MIDIBUF_ISFULL(mb)) @@ -159,7 +159,7 @@ midi_ointr(void *addr) struct midi_buffer *mb; MUTEX_ASSERT_LOCKED(&audio_lock); - if (sc->isopen && !sc->isdying) { + if (!(sc->flags & FWRITE) && !sc->isdying) { mb = &sc->outbuf; if (mb->used > 0) { #ifdef MIDI_DEBUG @@ -433,7 +433,7 @@ midiopen(dev_t dev, int flags, int mode, struct proc *p) return ENXIO; if (sc->isdying) return EIO; - if (sc->isopen) + if (sc->flags) return EBUSY; MIDIBUF_INIT(&sc->inbuf); @@ -442,11 +442,11 @@ midiopen(dev_t dev, int flags, int mode, struct proc *p) sc->rchan = sc->wchan = 0; sc->async = 0; sc->flags = flags; - err = sc->hw_if->open(sc->hw_hdl, flags, midi_iintr, midi_ointr, sc); - if (err) + if (err) { + sc->flags = 0; return err; - sc->isopen = 1; + } return 0; } @@ -482,7 +482,7 @@ midiclose(dev_t dev, int fflag, int devtype, struct proc *p) */ tsleep(&sc->wchan, PWAIT, "mid_cl", hz * MIDI_MAXWRITE / MIDI_RATE); sc->hw_if->close(sc->hw_hdl); - sc->isopen = 0; + sc->flags = 0; return 0; } @@ -518,7 +518,7 @@ midiattach(struct device *parent, struct device *self, void *aux) sc->isdying = 0; sc->hw_if->getinfo(sc->hw_hdl, &mi); sc->props = mi.props; - sc->isopen = 0; + sc->flags = 0; timeout_set(&sc->timeo, midi_timeout, sc); printf(": <%s>\n", mi.name); } diff --git a/sys/dev/midivar.h b/sys/dev/midivar.h index bbdad7b1622..48e61bdae4f 100644 --- a/sys/dev/midivar.h +++ b/sys/dev/midivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: midivar.h,v 1.7 2013/03/15 09:10:52 ratchov Exp $ */ +/* $OpenBSD: midivar.h,v 1.8 2015/05/12 18:39:30 ratchov Exp $ */ /* * Copyright (c) 2003, 2004 Alexandre Ratchov @@ -72,7 +72,6 @@ struct midi_softc { struct device dev; struct midi_hw_if *hw_if; void *hw_hdl; - int isopen; int isbusy; /* concerns only the output */ int isdying; int flags; /* open flags */