git: 3af2beb8b24b - main - sound: Remove unused "num" argument from chn_init() and related callers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 May 2024 18:36:42 UTC
The branch main has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=3af2beb8b24ba21fb7e7fbd165a79b8eeff37712
commit 3af2beb8b24ba21fb7e7fbd165a79b8eeff37712
Author: Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-05-06 18:33:11 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-05-06 18:35:55 +0000
sound: Remove unused "num" argument from chn_init() and related callers
It is always -1 (i.e unused).
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Reviewed by: dev_submerge.ch
Differential Revision: https://reviews.freebsd.org/D45095
---
sys/dev/sound/pcm/channel.c | 11 ++---------
sys/dev/sound/pcm/channel.h | 2 +-
sys/dev/sound/pcm/sound.c | 4 ++--
sys/dev/sound/pcm/vchan.c | 27 ++++++++++++---------------
sys/dev/sound/pcm/vchan.h | 4 ++--
5 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index 996cb0cb04f7..846885b9d729 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -1159,7 +1159,7 @@ chn_reset(struct pcm_channel *c, uint32_t fmt, uint32_t spd)
struct pcm_channel *
chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls,
- int dir, int num, void *devinfo)
+ int dir, void *devinfo)
{
struct pcm_channel *c;
struct feeder_class *fc;
@@ -1169,7 +1169,6 @@ chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls,
PCM_BUSYASSERT(d);
PCM_LOCKASSERT(d);
- KASSERT(num >= -1, ("invalid num=%d", num));
switch (dir) {
case PCMDIR_PLAY:
@@ -1207,7 +1206,7 @@ chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls,
goto out1;
}
- unit = (num == -1) ? 0 : num;
+ unit = 0;
if (*pnum >= max || unit >= max) {
device_printf(d->dev, "%s(): unit=%d or pnum=%d >= than "
@@ -1220,12 +1219,6 @@ chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls,
CHN_FOREACH(c, d, channels.pcm) {
if (c->type != type)
continue;
- if (unit == c->unit && num != -1) {
- device_printf(d->dev,
- "%s(): channel num=%d already allocated\n",
- __func__, unit);
- goto out1;
- }
unit++;
if (unit >= max) {
device_printf(d->dev,
diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h
index 6aca089a7c4d..445882a62f0a 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);
struct pcm_channel *chn_init(struct snddev_info *d, struct pcm_channel *parent,
- kobj_class_t cls, int dir, int num, void *devinfo);
+ kobj_class_t cls, int dir, void *devinfo);
void chn_kill(struct pcm_channel *c);
void chn_shutdown(struct pcm_channel *c);
int chn_release(struct pcm_channel *c);
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index 971054261030..17a7138519ac 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -165,7 +165,7 @@ vchan_alloc:
/* no channel available */
if (!(vchancount > 0 && vchancount < snd_maxautovchans))
return (err);
- err = vchan_setnew(d, direction, vchancount + 1, -1);
+ err = vchan_setnew(d, direction, vchancount + 1);
if (err == 0) {
retry = true;
goto retry_chnalloc;
@@ -274,7 +274,7 @@ pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo)
PCM_BUSYASSERT(d);
PCM_LOCK(d);
- ch = chn_init(d, NULL, cls, dir, -1, devinfo);
+ ch = chn_init(d, NULL, cls, dir, devinfo);
if (!ch) {
device_printf(d->dev, "chn_init(%s, %d, %p) failed\n",
cls->name, dir, devinfo);
diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c
index 904ce6661675..8ba8138e55f1 100644
--- a/sys/dev/sound/pcm/vchan.c
+++ b/sys/dev/sound/pcm/vchan.c
@@ -339,7 +339,7 @@ sysctl_dev_pcm_vchans(SYSCTL_HANDLER_ARGS)
cnt = 0;
if (cnt > SND_MAXVCHANS)
cnt = SND_MAXVCHANS;
- err = vchan_setnew(d, direction, cnt, -1);
+ err = vchan_setnew(d, direction, cnt);
}
PCM_RELEASE_QUICK(d);
@@ -664,7 +664,7 @@ sysctl_dev_pcm_vchanformat(SYSCTL_HANDLER_ARGS)
"play.vchanrate" : "rec.vchanrate"
int
-vchan_create(struct pcm_channel *parent, int num)
+vchan_create(struct pcm_channel *parent)
{
struct snddev_info *d;
struct pcm_channel *ch;
@@ -700,7 +700,7 @@ vchan_create(struct pcm_channel *parent, int num)
}
/* create a new playback channel */
- ch = chn_init(d, parent, &vchan_class, direction, num, parent);
+ ch = chn_init(d, parent, &vchan_class, direction, parent);
if (ch == NULL) {
PCM_UNLOCK(d);
CHN_LOCK(parent);
@@ -933,7 +933,7 @@ vchan_sync(struct pcm_channel *c)
}
int
-vchan_setnew(struct snddev_info *d, int direction, int newcnt, int num)
+vchan_setnew(struct snddev_info *d, int direction, int newcnt)
{
struct pcm_channel *c, *ch, *nch;
struct pcmchan_caps *caps;
@@ -959,10 +959,9 @@ vchan_setnew(struct snddev_info *d, int direction, int newcnt, int num)
return (EINVAL);
if (newcnt > vcnt) {
- KASSERT(num == -1 ||
- (num >= 0 && num < SND_MAXVCHANS && (newcnt - 1) == vcnt),
- ("bogus vchan_create() request num=%d newcnt=%d vcnt=%d",
- num, newcnt, vcnt));
+ KASSERT((newcnt - 1) == vcnt,
+ ("bogus vchan_create() request newcnt=%d vcnt=%d",
+ newcnt, vcnt));
/* add new vchans - find a parent channel first */
ch = NULL;
CHN_FOREACH(c, d, channels.pcm) {
@@ -1004,7 +1003,7 @@ vchan_setnew(struct snddev_info *d, int direction, int newcnt, int num)
ch->flags |= CHN_F_BUSY;
err = 0;
while (err == 0 && newcnt > vcnt) {
- err = vchan_create(ch, num);
+ err = vchan_create(ch);
if (err == 0)
vcnt++;
else if (err == E2BIG && newcnt > vcnt)
@@ -1018,8 +1017,6 @@ vchan_setnew(struct snddev_info *d, int direction, int newcnt, int num)
if (err != 0)
return (err);
} else if (newcnt < vcnt) {
- KASSERT(num == -1,
- ("bogus vchan_destroy() request num=%d", num));
CHN_FOREACH(c, d, channels.pcm) {
CHN_LOCK(c);
if (c->direction != direction ||
@@ -1061,14 +1058,14 @@ vchan_setmaxauto(struct snddev_info *d, int num)
return;
if (num >= 0 && d->pvchancount > num)
- (void)vchan_setnew(d, PCMDIR_PLAY, num, -1);
+ (void)vchan_setnew(d, PCMDIR_PLAY, num);
else if (num > 0 && d->pvchancount == 0)
- (void)vchan_setnew(d, PCMDIR_PLAY, 1, -1);
+ (void)vchan_setnew(d, PCMDIR_PLAY, 1);
if (num >= 0 && d->rvchancount > num)
- (void)vchan_setnew(d, PCMDIR_REC, num, -1);
+ (void)vchan_setnew(d, PCMDIR_REC, num);
else if (num > 0 && d->rvchancount == 0)
- (void)vchan_setnew(d, PCMDIR_REC, 1, -1);
+ (void)vchan_setnew(d, PCMDIR_REC, 1);
}
static int
diff --git a/sys/dev/sound/pcm/vchan.h b/sys/dev/sound/pcm/vchan.h
index dcc1d6e9ff32..1f0fa058cf71 100644
--- a/sys/dev/sound/pcm/vchan.h
+++ b/sys/dev/sound/pcm/vchan.h
@@ -32,7 +32,7 @@
extern int snd_maxautovchans;
-int vchan_create(struct pcm_channel *, int);
+int vchan_create(struct pcm_channel *);
int vchan_destroy(struct pcm_channel *);
#ifdef SND_DEBUG
@@ -47,7 +47,7 @@ int vchan_sync(struct pcm_channel *);
sndbuf_getfmt((c)->bufhard) != (c)->parentchannel->format || \
sndbuf_getspd((c)->bufhard) != (c)->parentchannel->speed))
-int vchan_setnew(struct snddev_info *, int, int, int);
+int vchan_setnew(struct snddev_info *, int, int);
void vchan_setmaxauto(struct snddev_info *, int);
void vchan_initsys(device_t);