We can use snd_pcm_is_playback/capture(). Let's use it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx> --- sound/soc/bcm/bcm2835-i2s.c | 8 ++++---- sound/soc/bcm/bcm63xx-i2s-whistler.c | 4 ++-- sound/soc/bcm/bcm63xx-pcm-whistler.c | 4 ++-- sound/soc/bcm/cygnus-pcm.c | 18 +++++++++--------- sound/soc/bcm/cygnus-ssp.c | 12 ++++++------ 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c index 9bda6499e66e1..54fcf85a1158c 100644 --- a/sound/soc/bcm/bcm2835-i2s.c +++ b/sound/soc/bcm/bcm2835-i2s.c @@ -628,10 +628,10 @@ static int bcm2835_i2s_prepare(struct snd_pcm_substream *substream, */ regmap_read(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, &cs_reg); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK + if (snd_pcm_is_playback(substream) && !(cs_reg & BCM2835_I2S_TXE)) bcm2835_i2s_clear_fifos(dev, true, false); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE + else if (snd_pcm_is_capture(substream) && (cs_reg & BCM2835_I2S_RXD)) bcm2835_i2s_clear_fifos(dev, false, true); @@ -644,7 +644,7 @@ static void bcm2835_i2s_stop(struct bcm2835_i2s_dev *dev, { uint32_t mask; - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + if (snd_pcm_is_capture(substream)) mask = BCM2835_I2S_RXON; else mask = BCM2835_I2S_TXON; @@ -669,7 +669,7 @@ static int bcm2835_i2s_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: bcm2835_i2s_start_clock(dev); - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + if (snd_pcm_is_capture(substream)) mask = BCM2835_I2S_RXON; else mask = BCM2835_I2S_TXON; diff --git a/sound/soc/bcm/bcm63xx-i2s-whistler.c b/sound/soc/bcm/bcm63xx-i2s-whistler.c index c64609718738b..0980e35d12830 100644 --- a/sound/soc/bcm/bcm63xx-i2s-whistler.c +++ b/sound/soc/bcm/bcm63xx-i2s-whistler.c @@ -93,7 +93,7 @@ static int bcm63xx_i2s_startup(struct snd_pcm_substream *substream, struct bcm_i2s_priv *i2s_priv = snd_soc_dai_get_drvdata(dai); struct regmap *regmap_i2s = i2s_priv->regmap_i2s; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { regmap_update_bits(regmap_i2s, I2S_TX_CFG, I2S_TX_OUT_R | I2S_TX_DATA_ALIGNMENT | I2S_TX_DATA_ENABLE | I2S_TX_CLOCK_ENABLE, @@ -146,7 +146,7 @@ static void bcm63xx_i2s_shutdown(struct snd_pcm_substream *substream, struct bcm_i2s_priv *i2s_priv = snd_soc_dai_get_drvdata(dai); struct regmap *regmap_i2s = i2s_priv->regmap_i2s; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { regmap_update_bits(regmap_i2s, I2S_TX_CFG, I2S_TX_OUT_R | I2S_TX_DATA_ALIGNMENT | I2S_TX_DATA_ENABLE | I2S_TX_CLOCK_ENABLE, 0); diff --git a/sound/soc/bcm/bcm63xx-pcm-whistler.c b/sound/soc/bcm/bcm63xx-pcm-whistler.c index 018f2372e892c..e8542b2009f63 100644 --- a/sound/soc/bcm/bcm63xx-pcm-whistler.c +++ b/sound/soc/bcm/bcm63xx-pcm-whistler.c @@ -81,7 +81,7 @@ static int bcm63xx_pcm_trigger(struct snd_soc_component *component, i2s_priv = dev_get_drvdata(snd_soc_rtd_to_cpu(rtd, 0)->dev); regmap_i2s = i2s_priv->regmap_i2s; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { switch (cmd) { case SNDRV_PCM_TRIGGER_START: regmap_update_bits(regmap_i2s, @@ -153,7 +153,7 @@ static int bcm63xx_pcm_prepare(struct snd_soc_component *component, dma_desc->dma_addr = runtime->dma_addr; dma_desc->dma_area = runtime->dma_area; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { regaddr_desclen = I2S_TX_DESC_IFF_LEN; regaddr_descaddr = I2S_TX_DESC_IFF_ADDR; } else { diff --git a/sound/soc/bcm/cygnus-pcm.c b/sound/soc/bcm/cygnus-pcm.c index 2d1e241d83673..3dc204d0a34c6 100644 --- a/sound/soc/bcm/cygnus-pcm.c +++ b/sound/soc/bcm/cygnus-pcm.c @@ -252,7 +252,7 @@ static int configure_ringbuf_regs(struct snd_pcm_substream *substream) aio = cygnus_dai_get_dma_data(substream); /* Map the ssp portnum to a set of ring buffers. */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { p_rbuf = &aio->play_rb_regs; switch (aio->portnum) { @@ -299,7 +299,7 @@ static struct ringbuf_regs *get_ringbuf(struct snd_pcm_substream *substream) aio = cygnus_dai_get_dma_data(substream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) p_rbuf = &aio->play_rb_regs; else p_rbuf = &aio->capture_rb_regs; @@ -317,7 +317,7 @@ static void enable_intr(struct snd_pcm_substream *substream) /* The port number maps to the bit position to be cleared */ clear_mask = BIT(aio->portnum); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { /* Clear interrupt status before enabling them */ writel(clear_mask, aio->cygaud->audio + ESR0_STATUS_CLR_OFFSET); writel(clear_mask, aio->cygaud->audio + ESR1_STATUS_CLR_OFFSET); @@ -354,7 +354,7 @@ static void disable_intr(struct snd_pcm_substream *substream) /* The port number maps to the bit position to be set */ set_mask = BIT(aio->portnum); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { /* Mask the interrupts of the given port*/ writel(set_mask, aio->cygaud->audio + ESR0_MASK_SET_OFFSET); writel(set_mask, aio->cygaud->audio + ESR1_MASK_SET_OFFSET); @@ -404,7 +404,7 @@ static void cygnus_pcm_period_elapsed(struct snd_pcm_substream *substream) */ snd_pcm_period_elapsed(substream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { /* Set the ring buffer to full */ regval = readl(aio->cygaud->audio + p_rbuf->rdaddr); regval = regval ^ BIT(31); @@ -597,7 +597,7 @@ static int cygnus_pcm_open(struct snd_soc_component *component, * Keep track of which substream belongs to which port. * This info is needed by snd_pcm_period_elapsed() in irq_handler */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) aio->play_stream = substream; else aio->capture_stream = substream; @@ -615,7 +615,7 @@ static int cygnus_pcm_close(struct snd_soc_component *component, dev_dbg(snd_soc_rtd_to_cpu(rtd, 0)->dev, "%s port %d\n", __func__, aio->portnum); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) aio->play_stream = NULL; else aio->capture_stream = NULL; @@ -652,7 +652,7 @@ static int cygnus_pcm_prepare(struct snd_soc_component *component, start = runtime->dma_addr; - is_play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 1 : 0; + is_play = snd_pcm_is_playback(substream); ringbuf_set_initial(aio->cygaud->audio, p_rbuf, is_play, start, periodsize, bufsize); @@ -674,7 +674,7 @@ static snd_pcm_uframes_t cygnus_pcm_pointer(struct snd_soc_component *component, * index (for capture). Report this value back to the asoc framework. */ p_rbuf = get_ringbuf(substream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) cur = readl(aio->cygaud->audio + p_rbuf->rdaddr); else cur = readl(aio->cygaud->audio + p_rbuf->wraddr); diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index 90088516fed01..73c231f5c1ed8 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -642,7 +642,7 @@ static int cygnus_ssp_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { value = readl(aio->cygaud->audio + aio->regs.bf_sourcech_cfg); value &= ~BIT(BF_SRC_CFGX_BUFFER_PAIR_ENABLE); value &= ~BIT(BF_SRC_CFGX_SAMPLE_CH_MODE); @@ -736,7 +736,7 @@ static int cygnus_ssp_startup(struct snd_pcm_substream *substream, struct cygnus_aio_port *aio = cygnus_dai_get_portinfo(dai); snd_soc_dai_set_dma_data(dai, substream, aio); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) aio->clk_trace.play_en = true; else aio->clk_trace.cap_en = true; @@ -754,7 +754,7 @@ static void cygnus_ssp_shutdown(struct snd_pcm_substream *substream, { struct cygnus_aio_port *aio = cygnus_dai_get_portinfo(dai); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) aio->clk_trace.play_en = false; else aio->clk_trace.cap_en = false; @@ -770,7 +770,7 @@ static void cygnus_ssp_shutdown(struct snd_pcm_substream *substream, return; } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_pcm_is_playback(substream)) { if (aio->clk_trace.play_clk_en) { clk_disable_unprepare(aio->cygaud-> audio_clk[val]); @@ -932,7 +932,7 @@ static int cygnus_ssp_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) audio_ssp_out_enable(aio); else audio_ssp_in_enable(aio); @@ -943,7 +943,7 @@ static int cygnus_ssp_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_SUSPEND: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (snd_pcm_is_playback(substream)) audio_ssp_out_disable(aio); else audio_ssp_in_disable(aio); -- 2.43.0