diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2011-06-23 23:04:29 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2011-06-23 23:04:29 +0000 |
commit | ffe17033706247b43690419b2085e595b68ac844 (patch) | |
tree | a768b40793afd2a492c9a069208e32b9c85ee284 /sys | |
parent | d62a13f3ce3bc5e6d4de1f14a0ec12f8b24605d3 (diff) |
Back out inadvertently commited change.
This one wanted some more comments before commit.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/umidi.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/sys/dev/usb/umidi.c b/sys/dev/usb/umidi.c index 58a8d5712e3..eaebdf36ec3 100644 --- a/sys/dev/usb/umidi.c +++ b/sys/dev/usb/umidi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umidi.c,v 1.30 2011/06/23 22:03:43 oga Exp $ */ +/* $OpenBSD: umidi.c,v 1.31 2011/06/23 23:04:28 oga Exp $ */ /* $NetBSD: umidi.c,v 1.16 2002/07/11 21:14:32 augustss Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -84,6 +84,7 @@ static usbd_status bind_jacks_to_mididev(struct umidi_softc *, struct umidi_jack *, struct umidi_mididev *); static void unbind_jacks_from_mididev(struct umidi_mididev *); +static void unbind_all_jacks(struct umidi_softc *); static usbd_status assign_all_jacks_automatically(struct umidi_softc *); static usbd_status open_out_jack(struct umidi_jack *, void *, void (*)(void *)); @@ -193,7 +194,8 @@ umidi_attach(struct device *parent, struct device *self, void *aux) } err = alloc_all_jacks(sc); if (err!=USBD_NORMAL_COMPLETION) { - goto free_ends; + free_all_endpoints(sc); + goto error; } printf("%s: out=%d, in=%d\n", sc->sc_dev.dv_xname, @@ -201,12 +203,15 @@ umidi_attach(struct device *parent, struct device *self, void *aux) err = assign_all_jacks_automatically(sc); if (err!=USBD_NORMAL_COMPLETION) { - goto free_jacks; + unbind_all_jacks(sc); + free_all_jacks(sc); + free_all_endpoints(sc); + goto error; } err = attach_all_mididevs(sc); if (err!=USBD_NORMAL_COMPLETION) { - /* XXX what about the mididevs that attached? */ - goto free_mididevs; + free_all_jacks(sc); + free_all_endpoints(sc); } #ifdef UMIDI_DEBUG @@ -218,13 +223,6 @@ umidi_attach(struct device *parent, struct device *self, void *aux) } return; - -free_mididevs: - free_all_mididevs(sc); -free_jacks: - free_all_jacks(sc); -free_ends: - free_all_endpoints(sc); error: printf("%s: disabled.\n", sc->sc_dev.dv_xname); sc->sc_dying = 1; @@ -410,7 +408,7 @@ alloc_all_endpoints(struct umidi_softc *sc) err = alloc_all_endpoints_genuine(sc); } if (err!=USBD_NORMAL_COMPLETION) - free(sc->sc_endpoints, M_USBDEV); + return err; ep = sc->sc_endpoints; for (i=sc->sc_out_num_endpoints+sc->sc_in_num_endpoints; i>0; i--) { @@ -844,6 +842,17 @@ unbind_jacks_from_mididev(struct umidi_mididev *mididev) mididev->out_jack = mididev->in_jack = NULL; } +static void +unbind_all_jacks(struct umidi_softc *sc) +{ + int i; + + if (sc->sc_mididevs) + for (i=0; i<sc->sc_num_mididevs; i++) { + unbind_jacks_from_mididev(&sc->sc_mididevs[i]); + } +} + static usbd_status assign_all_jacks_automatically(struct umidi_softc *sc) { @@ -985,21 +994,16 @@ static usbd_status attach_all_mididevs(struct umidi_softc *sc) { usbd_status err; - int i, j; + int i; if (sc->sc_mididevs) for (i=0; i<sc->sc_num_mididevs; i++) { err = attach_mididev(sc, &sc->sc_mididevs[i]); if (err!=USBD_NORMAL_COMPLETION) - goto detach; + return err; } return USBD_NORMAL_COMPLETION; -detach: - - for (j = 0; j < i; j++) - (void)detach_mididev(&sc->sc_mididevs[i], DETACH_QUIET); - return err; } static usbd_status |