Date: Fri, 09 Jan 2026 23:27:47 +0000 From: Christos Margiolis <christos@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 8c005f3da817 - stable/15 - sound: Merge midi_destroy() with midi_uninit() Message-ID: <69618ef3.31e43.305b701c@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=8c005f3da817456de3fc2f7d186b4898fcdff704 commit 8c005f3da817456de3fc2f7d186b4898fcdff704 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2026-01-02 16:56:19 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2026-01-09 23:27:23 +0000 sound: Merge midi_destroy() with midi_uninit() Also always call MPU_UNINIT(). It does not make sense not to if we are deallocating everything. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D54192 (cherry picked from commit d912ea5879cd6b1042671ae3986d496c63be4d49) --- sys/dev/sound/midi/midi.c | 57 ++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c index 901e098d4883..2567f7412eb8 100644 --- a/sys/dev/sound/midi/midi.c +++ b/sys/dev/sound/midi/midi.c @@ -97,8 +97,6 @@ static struct cdevsw midi_cdevsw = { .d_name = "rmidi", }; -static int midi_destroy(struct snd_midi *, int); - struct unrhdr *dev_unr = NULL; struct unrhdr *chn_unr = NULL; @@ -186,21 +184,15 @@ err1: return NULL; } -/* - * midi_uninit does not call MIDI_UNINIT, as since this is the implementors - * entry point. midi_uninit if fact, does not send any methods. A call to - * midi_uninit is a defacto promise that you won't manipulate ch anymore - */ int midi_uninit(struct snd_midi *m) { - int err; - - err = EBUSY; mtx_lock(&m->lock); if (m->busy) { - if (!(m->rchan || m->wchan)) - goto err; + if (!(m->rchan || m->wchan)) { + mtx_unlock(&m->lock); + return (EBUSY); + } if (m->rchan) { wakeup(&m->rchan); @@ -211,14 +203,17 @@ midi_uninit(struct snd_midi *m) m->wchan = 0; } } - err = midi_destroy(m, 0); - if (!err) - goto exit; - -err: mtx_unlock(&m->lock); -exit: - return err; + MPU_UNINIT(m, m->cookie); + destroy_dev(m->dev); + free_unr(dev_unr, m->unit); + free_unr(chn_unr, m->channel); + free(MIDIQ_BUF(m->inq), M_MIDI); + free(MIDIQ_BUF(m->outq), M_MIDI); + mtx_destroy(&m->lock); + free(m, M_MIDI); + + return (0); } #ifdef notdef @@ -601,30 +596,6 @@ midi_poll(struct cdev *i_dev, int events, struct thread *td) return (revents); } -/* - * Single point of midi destructions. - */ -static int -midi_destroy(struct snd_midi *m, int midiuninit) -{ - mtx_assert(&m->lock, MA_OWNED); - - MIDI_DEBUG(3, printf("midi_destroy\n")); - m->dev->si_drv1 = NULL; - mtx_unlock(&m->lock); /* XXX */ - destroy_dev(m->dev); - /* XXX */ - if (midiuninit) - MPU_UNINIT(m, m->cookie); - free_unr(dev_unr, m->unit); - free_unr(chn_unr, m->channel); - free(MIDIQ_BUF(m->inq), M_MIDI); - free(MIDIQ_BUF(m->outq), M_MIDI); - mtx_destroy(&m->lock); - free(m, M_MIDI); - return 0; -} - static void midi_sysinit(void *data __unused) {home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69618ef3.31e43.305b701c>
