From nobody Fri May 17 19:30:56 2024 X-Original-To: dev-commits-src-all@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 4Vgxrx29HPz5Lfn7; Fri, 17 May 2024 19:30:57 +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 4Vgxrw4w7cz4trT; Fri, 17 May 2024 19:30:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715974256; 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=JLdRCd7pLN6JWK2PeDqKhnHxQdO6ReLpeQ24Xf/Xn9w=; b=MqFdIjB6dMK4CRHy1Hsj6isL56pSpHH/ghVheS53Dr5puTrAG1bmkvxD4hzNnfeM4YzSmk 0gRBUt3QZ1L/7ZBgHlWyV1VAR9qk8+cyiRwLemZVb+cB/2uuCyVUCNi7iuF0qGUSs+ltEM 2XHIw45hITKcWaZoZY6qRlNFCqAcAE/263PhRxb2hIOC9LlGA5uPJQNlV24zKR4I3Q5qh9 YrOFw/nbH41MIK74RUlLWXsMAE2YLhkQn5S8qAcYXq7SyuEBqmTlgW1kRsnzIO9E6dtea1 cATEkFnHtwkjquhpfeLdZAiFbOsh2U9tARtE1BzondS0l5Vh9+smlvXOQLwKjg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715974256; a=rsa-sha256; cv=none; b=BluCo6KpB49v9AsJZFNefq1pfRmNIQi8ouDFiFFTuPoNHGH4pBniMnV2GKMkY2EWUifDFg 3NqudcKYBv4WUTjhv+/GoPQcen5Vd6t6yT+G3oVv5JOS1O5HuL8//tsIpw9IX+tZSlcU3/ d/Xak6EEwpWXpnt97GvB3QYRrj1ZENFf5p9dIpZGfMpWUMEB9FNsk+Ntpe/XjudQ4WQe6e FDFN/lhEcIJMvLPsOHvD/sPeB5TdQj4m/dFGG7dY+P8eGX+0hW+7ll5cF3YJZb6HUgf3N0 kYspd4yxeErkVqSezhM9lJF+QLHrMw7yqH/W8gdJfY2lSSz1fshdHsLSAg2N9A== 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=1715974256; 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=JLdRCd7pLN6JWK2PeDqKhnHxQdO6ReLpeQ24Xf/Xn9w=; b=fWleP90tJGJLUoZmOtbX1fO2/eiFr1o+F1mKALaUZhAPeig13UZX5bEehXWPWuvmLYE3QF Ondw1hYFJlegxuaxZba74zBVZJ7dM0xncicXVVKF49qP18FqozJRpM+0viDAD9Par49SPW QsbvqkocVM4VJcPwdgbfieYh7MgJZLlelxLfuGka3H8KUkjPM+fwFZK7fg2b7+mTdpjesg dBHyFG16k6czcVDT67ou/3I9qLgAOJBdkId5bmnLLL3on8snedBS+QO0cWMLs4susBho9u sTDB/rV0DUU0Bg1Bwce43iG8DFK0CxQFdycVweIuDnSWtTjBAIi0KrbmGKgzMg== 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 4Vgxrw4FB7zvr1; Fri, 17 May 2024 19:30:56 +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 44HJUuFS099420; Fri, 17 May 2024 19:30:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44HJUusi099417; Fri, 17 May 2024 19:30:56 GMT (envelope-from git) Date: Fri, 17 May 2024 19:30:56 GMT Message-Id: <202405171930.44HJUusi099417@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 532b1efd2d2e - stable/14 - sound: Merge pcm_chn_destroy() and chn_kill() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 532b1efd2d2e659a488bf147ca817ceabb5d8997 Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=532b1efd2d2e659a488bf147ca817ceabb5d8997 commit 532b1efd2d2e659a488bf147ca817ceabb5d8997 Author: Christos Margiolis AuthorDate: 2024-04-28 19:46:08 +0000 Commit: Christos Margiolis CommitDate: 2024-05-17 19:30:34 +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 (cherry picked from commit b3ea087c05d8c75978a302cbb3fa92ce1afa3e49) --- 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 652f59494697..b3ae93b77a5d 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);