git: 9a6cf27583ff - main - sound: Retire channel refcount

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Fri, 25 Oct 2024 11:37:05 UTC
The branch main has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=9a6cf27583ffc13bb0a7c5be0704ba0d2f3b834d

commit 9a6cf27583ffc13bb0a7c5be0704ba0d2f3b834d
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-10-25 11:36:59 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-10-25 11:36:59 +0000

    sound: Retire channel refcount
    
    No longer used.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 days
    Reviewed by:    dev_submerge.ch
    Differential Revision:  https://reviews.freebsd.org/D47269
---
 sys/dev/sound/pcm/channel.c | 13 -------------
 sys/dev/sound/pcm/channel.h |  2 --
 sys/dev/sound/pcm/dsp.c     | 29 ++++-------------------------
 3 files changed, 4 insertions(+), 40 deletions(-)

diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index 7bcd841d541f..eb70e910f51d 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -1435,19 +1435,6 @@ chn_release(struct pcm_channel *c)
 	return (0);
 }
 
-int
-chn_ref(struct pcm_channel *c, int ref)
-{
-	PCM_BUSYASSERT(c->parentsnddev);
-	CHN_LOCKASSERT(c);
-	KASSERT((c->refcount + ref) >= 0,
-	    ("%s(): new refcount will be negative", __func__));
-
-	c->refcount += ref;
-
-	return (c->refcount);
-}
-
 int
 chn_setvolume_multi(struct pcm_channel *c, int vc, int left, int right,
     int center)
diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h
index 6c6692fa8bc2..0788fbe42a5a 100644
--- a/sys/dev/sound/pcm/channel.h
+++ b/sys/dev/sound/pcm/channel.h
@@ -84,7 +84,6 @@ struct pcm_channel {
 	kobj_t methods;
 
 	pid_t pid;
-	int refcount;
 	struct pcm_feeder *feeder;
 	u_int32_t align;
 
@@ -266,7 +265,6 @@ struct pcm_channel *chn_init(struct snddev_info *d, struct pcm_channel *parent,
 void chn_kill(struct pcm_channel *c);
 void chn_shutdown(struct pcm_channel *c);
 int chn_release(struct pcm_channel *c);
-int chn_ref(struct pcm_channel *c, int ref);
 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,
     int center);
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index 7d80a82d31c8..6a59bcfc1ade 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -168,9 +168,9 @@ static void
 dsp_close(void *data)
 {
 	struct dsp_cdevpriv *priv = data;
-	struct pcm_channel *rdch, *wrch, *volch;
+	struct pcm_channel *rdch, *wrch;
 	struct snddev_info *d;
-	int sg_ids, rdref, wdref;
+	int sg_ids;
 
 	if (priv == NULL)
 		return;
@@ -188,22 +188,6 @@ dsp_close(void *data)
 
 	rdch = priv->rdch;
 	wrch = priv->wrch;
-	volch = priv->volch;
-
-	rdref = -1;
-	wdref = -1;
-
-	if (volch != NULL) {
-		if (volch == rdch)
-			rdref--;
-		else if (volch == wrch)
-			wdref--;
-		else {
-			CHN_LOCK(volch);
-			chn_ref(volch, -1);
-			CHN_UNLOCK(volch);
-		}
-	}
 
 	if (rdch != NULL)
 		CHN_REMOVE(d, rdch, channels.pcm.opened);
@@ -231,7 +215,6 @@ dsp_close(void *data)
 				free_unr(pcmsg_unrhdr, sg_ids);
 
 			CHN_LOCK(rdch);
-			chn_ref(rdch, rdref);
 			chn_abort(rdch); /* won't sleep */
 			rdch->flags &= ~(CHN_F_RUNNING | CHN_F_MMAP |
 			    CHN_F_DEAD | CHN_F_EXCLUSIVE);
@@ -249,7 +232,6 @@ dsp_close(void *data)
 				free_unr(pcmsg_unrhdr, sg_ids);
 
 			CHN_LOCK(wrch);
-			chn_ref(wrch, wdref);
 			chn_flush(wrch); /* may sleep */
 			wrch->flags &= ~(CHN_F_RUNNING | CHN_F_MMAP |
 			    CHN_F_DEAD | CHN_F_EXCLUSIVE);
@@ -382,7 +364,6 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 				rdch->flags |= CHN_F_NBIO;
 			if (flags & O_EXCL)
 				rdch->flags |= CHN_F_EXCLUSIVE;
-			chn_ref(rdch, 1);
 			chn_vpc_reset(rdch, SND_VOL_C_PCM, 0);
 		 	CHN_UNLOCK(rdch);
 		}
@@ -402,11 +383,10 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 			if (!DSP_F_DUPLEX(flags)) {
 				if (rdch != NULL) {
 					/*
-					 * Lock, deref and release previously
-					 * created record channel
+					 * Lock, and release previously created
+					 * record channel
 					 */
 					CHN_LOCK(rdch);
-					chn_ref(rdch, -1);
 					chn_release(rdch);
 				}
 				PCM_RELEASE_QUICK(d);
@@ -419,7 +399,6 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
 				wrch->flags |= CHN_F_NBIO;
 			if (flags & O_EXCL)
 				wrch->flags |= CHN_F_EXCLUSIVE;
-			chn_ref(wrch, 1);
 			chn_vpc_reset(wrch, SND_VOL_C_PCM, 0);
 			CHN_UNLOCK(wrch);
 		}