diff mbox series

[031/113] ALSA: core: oss: use snd_pcm_is_playback/capture()

Message ID 87v80fztx3.wl-kuninori.morimoto.gx@renesas.com
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/core/oss/io.c         |  2 +-
 sound/core/oss/pcm_oss.c    | 20 ++++++++++----------
 sound/core/oss/pcm_plugin.c | 10 +++++-----
 3 files changed, 16 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/sound/core/oss/io.c b/sound/core/oss/io.c
index d870b2d93135d..86d25f2e01ea6 100644
--- a/sound/core/oss/io.c
+++ b/sound/core/oss/io.c
@@ -128,7 +128,7 @@  int snd_pcm_plugin_build_io(struct snd_pcm_substream *plug,
 	if (err < 0)
 		return err;
 	plugin->access = params_access(params);
-	if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(snd_pcm_plug_stream(plug))) {
 		plugin->transfer = io_playback_transfer;
 		if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED)
 			plugin->client_channels = io_src_channels;
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 7386982cf40ed..aeaf9c69e791f 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -986,7 +986,7 @@  static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
 					"snd_pcm_plugin_build_io failed: %i\n", err);
 				goto failure;
 			}
-			if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+			if (snd_pcm_is_playback(substream)) {
 				err = snd_pcm_plugin_append(plugin);
 			} else {
 				err = snd_pcm_plugin_insert(plugin);
@@ -1003,13 +1003,13 @@  static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
 		sw_params->start_threshold = runtime->boundary;
 	}
 	if (atomic_read(&substream->mmap_count) ||
-	    substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+	    snd_pcm_is_capture(substream))
 		sw_params->stop_threshold = runtime->boundary;
 	else
 		sw_params->stop_threshold = runtime->buffer_size;
 	sw_params->tstamp_mode = SNDRV_PCM_TSTAMP_NONE;
 	sw_params->period_step = 1;
-	sw_params->avail_min = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
+	sw_params->avail_min = snd_pcm_is_playback(substream) ?
 		1 : runtime->period_size;
 	if (atomic_read(&substream->mmap_count) ||
 	    substream->oss.setup.nosilence) {
@@ -2017,7 +2017,7 @@  static int snd_pcm_oss_get_caps1(struct snd_pcm_substream *substream, int res)
 		return res;
 	}
 #ifdef DSP_CAP_MULTI
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		if (substream->pstr->substream_count > 1)
 			res |= DSP_CAP_MULTI;
 #endif
@@ -2201,7 +2201,7 @@  static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream
 			return -EFAULT;
 		return 0;
 	}
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &delay);
 		if (err == -EPIPE || err == -ESTRPIPE || (! err && delay < 0)) {
 			err = 0;
@@ -2225,12 +2225,12 @@  static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream
 			n += runtime->boundary;
 		info.blocks = n / runtime->period_size;
 		runtime->oss.prev_hw_ptr_period = delay;
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(substream))
 			snd_pcm_oss_simulate_fill(substream, delay);
 		info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX;
 	} else {
 		delay = snd_pcm_oss_bytes(substream, delay);
-		if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(stream)) {
 			if (substream->oss.setup.buggyptr)
 				info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes;
 			else
@@ -2272,7 +2272,7 @@  static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre
 	info.fragsize = runtime->oss.period_bytes;
 	info.fragstotal = runtime->periods;
 	if (runtime->oss.prepare) {
-		if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(stream)) {
 			info.bytes = runtime->oss.period_bytes * runtime->oss.periods;
 			info.fragments = runtime->oss.periods;
 		} else {
@@ -2280,7 +2280,7 @@  static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre
 			info.fragments = 0;
 		}
 	} else {
-		if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(stream)) {
 			err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &avail);
 			if (err == -EPIPE || err == -ESTRPIPE || (! err && avail < 0)) {
 				avail = runtime->buffer_size;
@@ -2429,7 +2429,7 @@  static int snd_pcm_oss_open_file(struct file *file,
 			continue;
 		if (! pcm->streams[idx].substream_count)
 			continue; /* no matching substream */
-		if (idx == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(idx)) {
 			if (! (f_mode & FMODE_WRITE))
 				continue;
 		} else {
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index 82e180c776ae1..47168e175c966 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -54,7 +54,7 @@  static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
 	unsigned int channel;
 	struct snd_pcm_plugin_channel *c;
 
-	if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(plugin->stream)) {
 		format = &plugin->src_format;
 	} else {
 		format = &plugin->dst_format;
@@ -110,7 +110,7 @@  int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames)
 	int err;
 	if (snd_BUG_ON(!snd_pcm_plug_first(plug)))
 		return -ENXIO;
-	if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(snd_pcm_plug_stream(plug))) {
 		struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug);
 		while (plugin->next) {
 			if (plugin->dst_frames)
@@ -174,7 +174,7 @@  int snd_pcm_plugin_build(struct snd_pcm_substream *plug,
 	plugin->dst_format = *dst_format;
 	plugin->dst_width = snd_pcm_format_physical_width(dst_format->format);
 	snd_BUG_ON(plugin->dst_width <= 0);
-	if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(plugin->stream))
 		channels = src_format->channels;
 	else
 		channels = dst_format->channels;
@@ -567,7 +567,7 @@  snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu
 
 	if (snd_BUG_ON(!buf))
 		return -ENXIO;
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		plugin = snd_pcm_plug_first(plug);
 		format = &plugin->src_format;
 	} else {
@@ -586,7 +586,7 @@  snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu
 	for (channel = 0; channel < nchannels; channel++, v++) {
 		v->frames = count;
 		v->enabled = 1;
-		v->wanted = (stream == SNDRV_PCM_STREAM_CAPTURE);
+		v->wanted = snd_pcm_is_capture(stream);
 		v->area.addr = buf;
 		v->area.first = channel * width;
 		v->area.step = nchannels * width;