diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h --- a/sys/dev/sound/pcm/channel.h +++ b/sys/dev/sound/pcm/channel.h @@ -260,7 +260,7 @@ 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/channel.c b/sys/dev/sound/pcm/channel.c --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -1279,11 +1279,13 @@ 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_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/sound.h b/sys/dev/sound/pcm/sound.h --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -300,7 +300,6 @@ 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/sound.c b/sys/dev/sound/pcm/sound.c --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -515,28 +515,6 @@ 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 @@ 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 @@ 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/vchan.c b/sys/dev/sound/pcm/vchan.c --- a/sys/dev/sound/pcm/vchan.c +++ b/sys/dev/sound/pcm/vchan.c @@ -709,7 +709,7 @@ 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 @@ 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 @@ /* destroy ourselves */ if (ret == 0) - ret = pcm_chn_destroy(c); + chn_kill(c); CHN_LOCK(parent);