git: abb5521bddc2 - main - sound: Retire SD_F_PRIO_*
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 25 Apr 2025 16:56:41 UTC
The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=abb5521bddc24581a1bcbe3e3f016504a4824c73 commit abb5521bddc24581a1bcbe3e3f016504a4824c73 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2025-04-25 16:55:51 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2025-04-25 16:55:51 +0000 sound: Retire SD_F_PRIO_* The SD_F_* flags are supposed to be softc flags, but SD_F_PRIO_RD and SD_F_PRIO_WR are just generic flags and are only used with dsp_lock_chans() and dsp_unlock_chans(). Since we already have the DSP_F_READ() and DSP_F_WRITE() macros, we can re-use them instead. I am aware the FREAD and FWRITE flags are meant to be used with open(), but I think their use here is clear enough to not cause confusion. No functional change intended. Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D49978 --- sys/dev/sound/pcm/dsp.c | 34 +++++++++++++++++----------------- sys/dev/sound/pcm/sound.h | 7 +------ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index c5caeea8a002..9b174f4592f3 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -67,6 +67,12 @@ SYSCTL_INT(_hw_snd, OID_AUTO, basename_clone, CTLFLAG_RWTUN, #define DSP_REGISTERED(x) (PCM_REGISTERED(x) && (x)->dsp_dev != NULL) +#define DSP_F_VALID(x) ((x) & (FREAD | FWRITE)) +#define DSP_F_DUPLEX(x) (((x) & (FREAD | FWRITE)) == (FREAD | FWRITE)) +#define DSP_F_SIMPLEX(x) (!DSP_F_DUPLEX(x)) +#define DSP_F_READ(x) ((x) & FREAD) +#define DSP_F_WRITE(x) ((x) & FWRITE) + #define OLDPCM_IOCTL static d_open_t dsp_open; @@ -144,18 +150,18 @@ dsp_destroy_dev(device_t dev) static void dsp_lock_chans(struct dsp_cdevpriv *priv, uint32_t prio) { - if (priv->rdch != NULL && (prio & SD_F_PRIO_RD)) + if (priv->rdch != NULL && DSP_F_READ(prio)) CHN_LOCK(priv->rdch); - if (priv->wrch != NULL && (prio & SD_F_PRIO_WR)) + if (priv->wrch != NULL && DSP_F_WRITE(prio)) CHN_LOCK(priv->wrch); } static void dsp_unlock_chans(struct dsp_cdevpriv *priv, uint32_t prio) { - if (priv->rdch != NULL && (prio & SD_F_PRIO_RD)) + if (priv->rdch != NULL && DSP_F_READ(prio)) CHN_UNLOCK(priv->rdch); - if (priv->wrch != NULL && (prio & SD_F_PRIO_WR)) + if (priv->wrch != NULL && DSP_F_WRITE(prio)) CHN_UNLOCK(priv->wrch); } @@ -234,12 +240,6 @@ dsp_chn_alloc(struct snddev_info *d, struct pcm_channel **ch, int direction, return (0); } -#define DSP_F_VALID(x) ((x) & (FREAD | FWRITE)) -#define DSP_F_DUPLEX(x) (((x) & (FREAD | FWRITE)) == (FREAD | FWRITE)) -#define DSP_F_SIMPLEX(x) (!DSP_F_DUPLEX(x)) -#define DSP_F_READ(x) ((x) & FREAD) -#define DSP_F_WRITE(x) ((x) & FWRITE) - static void dsp_close(void *data) { @@ -475,12 +475,12 @@ dsp_io_ops(struct dsp_cdevpriv *priv, struct uio *buf) switch (buf->uio_rw) { case UIO_READ: - prio = SD_F_PRIO_RD; + prio = FREAD; ch = &priv->rdch; chn_io = chn_read; break; case UIO_WRITE: - prio = SD_F_PRIO_WR; + prio = FWRITE; ch = &priv->wrch; chn_io = chn_write; break; @@ -1793,7 +1793,7 @@ dsp_poll(struct cdev *i_dev, int events, struct thread *td) ret = 0; - dsp_lock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_lock_chans(priv, FREAD | FWRITE); wrch = priv->wrch; rdch = priv->rdch; @@ -1809,7 +1809,7 @@ dsp_poll(struct cdev *i_dev, int events, struct thread *td) ret |= chn_poll(rdch, e, td); } - dsp_unlock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_unlock_chans(priv, FREAD | FWRITE); PCM_GIANT_LEAVE(d); @@ -1871,7 +1871,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset, PCM_GIANT_ENTER(d); - dsp_lock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_lock_chans(priv, FREAD | FWRITE); wrch = priv->wrch; rdch = priv->rdch; @@ -1880,7 +1880,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset, (*offset + size) > sndbuf_getallocsize(c->bufsoft) || (wrch != NULL && (wrch->flags & CHN_F_MMAP_INVALID)) || (rdch != NULL && (rdch->flags & CHN_F_MMAP_INVALID))) { - dsp_unlock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_unlock_chans(priv, FREAD | FWRITE); PCM_GIANT_EXIT(d); return (EINVAL); } @@ -1891,7 +1891,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset, rdch->flags |= CHN_F_MMAP; *offset = (uintptr_t)sndbuf_getbufofs(c->bufsoft, *offset); - dsp_unlock_chans(priv, SD_F_PRIO_RD | SD_F_PRIO_WR); + dsp_unlock_chans(priv, FREAD | FWRITE); *object = vm_pager_allocate(OBJT_DEVICE, i_dev, size, nprot, *offset, curthread->td_ucred); diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index a1370180f350..315452e294d1 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -121,9 +121,6 @@ struct snd_mixer; #define SD_F_EQ_MASK (SD_F_EQ | SD_F_EQ_ENABLED | \ SD_F_EQ_BYPASSED | SD_F_EQ_PC) -#define SD_F_PRIO_RD 0x10000000 -#define SD_F_PRIO_WR 0x20000000 - #define SD_F_BITS "\020" \ "\001SIMPLEX" \ /* "\002 */ \ @@ -138,9 +135,7 @@ struct snd_mixer; "\013EQ_BYPASSED" \ "\014EQ_PC" \ "\015PVCHANS" \ - "\016RVCHANS" \ - "\035PRIO_RD" \ - "\036PRIO_WR" + "\016RVCHANS" #define PCM_ALIVE(x) ((x) != NULL && (x)->lock != NULL) #define PCM_REGISTERED(x) (PCM_ALIVE(x) && ((x)->flags & SD_F_REGISTERED))