From nobody Sun Apr 28 19:49:04 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VSH8d4MS9z5JrDL; Sun, 28 Apr 2024 19:49:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VSH8c6xVHz42ML; Sun, 28 Apr 2024 19:49:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714333745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=czRFE5cxOKsI9xCga5Ky/F4v1RekTvnZnCdADPTSYjE=; b=N9GIsjIJHcy5dKj4V7Y0rMyAY8nFcPTxqpq+a/YzRtsgONVGtv9LWXOsIeUyJRYijbRohr /REdsVTMpF+XEdQUg5ExV6d4HJ6SOhaywb/qm6Up4Xp6SvoTT5qdhJvMeQiildgqn4z6G1 8U3+vdPQNTC8T78h01PsCSNkVG2L16kLS94pQrwEfuXUQFssFnhmtsgoxZDKLYVv2E9kPD 7iOEyDtVvHJ/lJlok01hiceLPTDdfyw5R7kMdKNitMdQ3bHmAgzJiT+StLaYZMgyPh88Hl vi9fXIYKiD3w/mImHSpCqaj52O35yMXkZq5UexJS+FtwWrzgc8OGzXGfY+C2/Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714333745; a=rsa-sha256; cv=none; b=ChX805RzZmuwmR+HOzeVEhCgFMC4meoTd651Q5wxMtmVvf6T2OjRHnV7WglwJNrv4/aWgc GCYuBYsOM7nya7xUOF0nhVsVIUc997smGIOuFgwEs+co9wsMPHItuCNjAzGHuChXzKVItW aSx9UlR//9KW2ObX1XBCLpPfAO08IVM1yhugeIppvCSMJZ6DcE6zPuW67/OWWKUg9Lj3kg UEYYINiQw6qIHZmM9Yk16HqO2kaBBeZUCJqkTnCSFVTbCyXs5tjOsFHgVWMRSxq4BNI0lZ O3uBvcEr5qV6i4+Z9DmGaZ6VTJxSMoqpOSJAdzTMsKQ55AzzOK5Vd/2tlCXxaA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714333745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=czRFE5cxOKsI9xCga5Ky/F4v1RekTvnZnCdADPTSYjE=; b=e9X6O8orAfrCb68w2vjMLW1f8sCCsrlwOyybzw9urSrVWbr0NaH0/pXcY+JL3vHo0LmN9m Su+y7mEcPQKmH0DerUGT+Wp0rHELfqTzP+sio3RIjYXcNFzW5ZYB6QCEucuiiYohPeHSJk uk2cUcT+J6Kf68B90ehNQmGlJLLiACN+SlDMY0FVbH8JFsEQMoNY5j0L721Ui6qr9oegjY VVf+Ou3D3/jamuCCXEnMhS1zNaJ5uXx73yqeFdOEgi/oaYZ0CymxD0FBSjaxpAEQi8r5Vi LZYEoQK6Q74wXTNKwAFaVtuexSAwkjUBN2OmfA4n2ElK8gyQwXcN+rmnH8NBHA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VSH8c6Yjxzf6F; Sun, 28 Apr 2024 19:49:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43SJn4bk063519; Sun, 28 Apr 2024 19:49:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43SJn4Ln063516; Sun, 28 Apr 2024 19:49:04 GMT (envelope-from git) Date: Sun, 28 Apr 2024 19:49:04 GMT Message-Id: <202404281949.43SJn4Ln063516@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: b3ea087c05d8 - main - sound: Merge pcm_chn_destroy() and chn_kill() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b3ea087c05d8c75978a302cbb3fa92ce1afa3e49 Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=b3ea087c05d8c75978a302cbb3fa92ce1afa3e49 commit b3ea087c05d8c75978a302cbb3fa92ce1afa3e49 Author: Christos Margiolis AuthorDate: 2024-04-28 19:46:08 +0000 Commit: Christos Margiolis CommitDate: 2024-04-28 19:48:24 +0000 sound: Merge pcm_chn_destroy() and chn_kill() pcm_chn_destroy() acts like a wrapper around chn_kill(), and additionally calls a few more functions that should in fact be part of chn_kill()'s logic. Merge pcm_chn_destroy()'s functionality in chn_kill() to improve readability, as well as code layering. While here, convert chn_kill() to void as it currently always returns 0. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44984 --- sys/dev/sound/pcm/channel.c | 12 +++++++----- sys/dev/sound/pcm/channel.h | 2 +- sys/dev/sound/pcm/sound.c | 26 ++------------------------ sys/dev/sound/pcm/sound.h | 1 - sys/dev/sound/pcm/vchan.c | 6 +++--- 5 files changed, 13 insertions(+), 34 deletions(-) diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 1527d5ea3d2c..21a91ff13186 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -1279,11 +1279,13 @@ out: return 0; } -int +void chn_kill(struct pcm_channel *c) { - struct snd_dbuf *b = c->bufhard; - struct snd_dbuf *bs = c->bufsoft; + struct snd_dbuf *b = c->bufhard; + struct snd_dbuf *bs = c->bufsoft; + + PCM_BUSYASSERT(c->parentsnddev); if (CHN_STARTED(c)) { CHN_LOCK(c); @@ -1299,8 +1301,8 @@ chn_kill(struct pcm_channel *c) CHN_LOCK(c); c->flags |= CHN_F_DEAD; chn_lockdestroy(c); - - return (0); + kobj_delete(c->methods, M_DEVBUF); + free(c, M_DEVBUF); } void diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h index d4f73275ed39..45381b907fa2 100644 --- a/sys/dev/sound/pcm/channel.h +++ b/sys/dev/sound/pcm/channel.h @@ -260,7 +260,7 @@ int chn_flush(struct pcm_channel *c); int chn_poll(struct pcm_channel *c, int ev, struct thread *td); int chn_init(struct pcm_channel *c, void *devinfo, int dir, int direction); -int chn_kill(struct pcm_channel *c); +void chn_kill(struct pcm_channel *c); void chn_shutdown(struct pcm_channel *c); int chn_reset(struct pcm_channel *c, u_int32_t fmt, u_int32_t spd); int chn_setvolume_multi(struct pcm_channel *c, int vc, int left, int right, diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index c32536a55960..b44a7344121c 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -515,28 +515,6 @@ pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t c return (ch); } -int -pcm_chn_destroy(struct pcm_channel *ch) -{ - struct snddev_info *d __diagused; - int err; - - d = ch->parentsnddev; - PCM_BUSYASSERT(d); - - err = chn_kill(ch); - if (err) { - device_printf(ch->dev, "chn_kill(%s) failed, err = %d\n", - ch->name, err); - return (err); - } - - kobj_delete(ch->methods, M_DEVBUF); - free(ch, M_DEVBUF); - - return (0); -} - int pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch) { @@ -630,7 +608,7 @@ pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo) if (err) { device_printf(d->dev, "pcm_chn_add(%s) failed, err=%d\n", ch->name, err); - pcm_chn_destroy(ch); + chn_kill(ch); } return (err); @@ -678,7 +656,7 @@ pcm_killchans(struct snddev_info *d) error = pcm_chn_remove(d, ch); PCM_UNLOCK(d); if (error == 0) - pcm_chn_destroy(ch); + chn_kill(ch); } while (!CHN_EMPTY(d, channels.pcm)); } diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index 1f2dda880742..70addf32bddd 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -300,7 +300,6 @@ int pcm_chnrelease(struct pcm_channel *c); int pcm_chnref(struct pcm_channel *c, int ref); struct pcm_channel *pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, int num, void *devinfo); -int pcm_chn_destroy(struct pcm_channel *ch); int pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch); int pcm_chn_remove(struct snddev_info *d, struct pcm_channel *ch); diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c index ac5a0535ddce..c3bc36d924bd 100644 --- a/sys/dev/sound/pcm/vchan.c +++ b/sys/dev/sound/pcm/vchan.c @@ -709,7 +709,7 @@ vchan_create(struct pcm_channel *parent, int num) ret = pcm_chn_add(d, ch); PCM_UNLOCK(d); if (ret != 0) { - pcm_chn_destroy(ch); + chn_kill(ch); CHN_LOCK(parent); return (ret); } @@ -837,7 +837,7 @@ vchan_create(struct pcm_channel *parent, int num) PCM_LOCK(d); if (pcm_chn_remove(d, ch) == 0) { PCM_UNLOCK(d); - pcm_chn_destroy(ch); + chn_kill(ch); } else PCM_UNLOCK(d); CHN_LOCK(parent); @@ -890,7 +890,7 @@ vchan_destroy(struct pcm_channel *c) /* destroy ourselves */ if (ret == 0) - ret = pcm_chn_destroy(c); + chn_kill(c); CHN_LOCK(parent);