diff mbox series

[034/113] ALSA: drivers: use snd_pcm_is_playback/capture()

Message ID 87r0b3ztwi.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New
Headers show
Series ALSA: add snd_pcm_is_playback/capture() macro | expand

Commit Message

Kuninori Morimoto Aug. 5, 2024, 12:37 a.m. UTC
We can use snd_pcm_is_playback/capture(). Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/drivers/aloop.c   | 18 +++++++++---------
 sound/drivers/dummy.c   |  2 +-
 sound/drivers/pcmtest.c |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 439d12ad87879..9d33aef59e95b 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -193,7 +193,7 @@  static inline struct loopback_setup *get_setup(struct loopback_pcm *dpcm)
 {
 	int device = dpcm->substream->pstr->pcm->device;
 	
-	if (dpcm->substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(dpcm->substream))
 		device ^= 1;
 	return &dpcm->loopback->setup[dpcm->substream->number][device];
 }
@@ -341,7 +341,7 @@  static int loopback_check_format(struct loopback_cable *cable, int stream)
 	int check;
 
 	if (cable->valid != CABLE_VALID_BOTH) {
-		if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(stream))
 			goto __notify;
 		return 0;
 	}
@@ -356,7 +356,7 @@  static int loopback_check_format(struct loopback_cable *cable, int stream)
 		is_access_interleaved(cruntime->access);
 	if (!check)
 		return 0;
-	if (stream == SNDRV_PCM_STREAM_CAPTURE) {
+	if (snd_pcm_is_capture(stream)) {
 		return -EIO;
 	} else {
 		snd_pcm_stop(cable->streams[SNDRV_PCM_STREAM_CAPTURE]->
@@ -418,7 +418,7 @@  static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 		cable->pause &= ~stream;
 		err = cable->ops->start(dpcm);
 		spin_unlock(&cable->lock);
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(substream))
 			loopback_active_notify(dpcm);
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
@@ -427,7 +427,7 @@  static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 		cable->pause &= ~stream;
 		err = cable->ops->stop(dpcm);
 		spin_unlock(&cable->lock);
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(substream))
 			loopback_active_notify(dpcm);
 		break;
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
@@ -436,7 +436,7 @@  static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 		cable->pause |= stream;
 		err = cable->ops->stop(dpcm);
 		spin_unlock(&cable->lock);
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(substream))
 			loopback_active_notify(dpcm);
 		break;
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
@@ -446,7 +446,7 @@  static int loopback_trigger(struct snd_pcm_substream *substream, int cmd)
 		cable->pause &= ~stream;
 		err = cable->ops->start(dpcm);
 		spin_unlock(&cable->lock);
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(substream))
 			loopback_active_notify(dpcm);
 		break;
 	default:
@@ -497,7 +497,7 @@  static int loopback_prepare(struct snd_pcm_substream *substream)
 	dpcm->buf_pos = 0;
 	dpcm->pcm_buffer_size = frames_to_bytes(runtime, runtime->buffer_size);
 	dpcm->channel_buf_n = dpcm->pcm_buffer_size / runtime->channels;
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+	if (snd_pcm_is_capture(substream)) {
 		/* clear capture buffer */
 		dpcm->silent_size = dpcm->pcm_buffer_size;
 		snd_pcm_format_set_silence(runtime->format, runtime->dma_area,
@@ -513,7 +513,7 @@  static int loopback_prepare(struct snd_pcm_substream *substream)
 	mutex_lock(&dpcm->loopback->cable_lock);
 	if (!(cable->valid & ~(1 << substream->stream)) ||
             (get_setup(dpcm)->notify &&
-	     substream->stream == SNDRV_PCM_STREAM_PLAYBACK))
+	     snd_pcm_is_playback(substream)))
 		params_change(substream);
 	cable->valid |= 1 << substream->stream;
 	mutex_unlock(&dpcm->loopback->cable_lock);
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index 52ff6ac3f7435..5e440f952449e 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -570,7 +570,7 @@  static int dummy_pcm_open(struct snd_pcm_substream *substream)
 	if (model == NULL)
 		return 0;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		if (model->playback_constraints)
 			err = model->playback_constraints(substream->runtime);
 	} else {
diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c
index 21cefaf5419aa..ae308ede80929 100644
--- a/sound/drivers/pcmtest.c
+++ b/sound/drivers/pcmtest.c
@@ -351,9 +351,9 @@  static void timer_timeout(struct timer_list *data)
 	if (v_iter->suspend)
 		return;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && !v_iter->is_buf_corrupted)
+	if (snd_pcm_is_playback(substream) && !v_iter->is_buf_corrupted)
 		check_buf_block(v_iter, substream->runtime);
-	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+	else if (snd_pcm_is_capture(substream))
 		fill_block(v_iter, substream->runtime);
 	else
 		inc_buf_pos(v_iter, v_iter->b_rw, substream->runtime->dma_bytes);