All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	jarkko.nikula@bitmer.com
Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org
Subject: [PATCH v2 3/7] ASoC: omap-mcbsp: Simplify the mcbsp_start/_stop function parameters
Date: Wed, 7 Nov 2018 15:23:06 +0200	[thread overview]
Message-ID: <20181107132310.29597-4-peter.ujfalusi@ti.com> (raw)
In-Reply-To: <20181107132310.29597-1-peter.ujfalusi@ti.com>

We either start/stop TX or RX, never both. Move the tx/rx direction
selection within the functions.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/omap/mcbsp.c      | 8 ++++++--
 sound/soc/omap/mcbsp.h      | 4 ++--
 sound/soc/omap/omap-mcbsp.c | 9 ++++-----
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index fca0b0e9186b..7ff22561f00f 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -637,8 +637,10 @@ void omap_mcbsp_free(struct omap_mcbsp *mcbsp)
  * If no transmitter or receiver is active prior calling, then sample-rate
  * generator and frame sync are started.
  */
-void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int tx, int rx)
+void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int stream)
 {
+	int tx = (stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int rx = !tx;
 	int enable_srg = 0;
 	u16 w;
 
@@ -694,8 +696,10 @@ void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int tx, int rx)
 	omap_mcbsp_dump_reg(mcbsp);
 }
 
-void omap_mcbsp_stop(struct omap_mcbsp *mcbsp, int tx, int rx)
+void omap_mcbsp_stop(struct omap_mcbsp *mcbsp, int stream)
 {
+	int tx = (stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int rx = !tx;
 	int idle;
 	u16 w;
 
diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h
index 46ae1269a698..92472c6ef358 100644
--- a/sound/soc/omap/mcbsp.h
+++ b/sound/soc/omap/mcbsp.h
@@ -339,8 +339,8 @@ u16 omap_mcbsp_get_rx_delay(struct omap_mcbsp *mcbsp);
 int omap_mcbsp_get_dma_op_mode(struct omap_mcbsp *mcbsp);
 int omap_mcbsp_request(struct omap_mcbsp *mcbsp);
 void omap_mcbsp_free(struct omap_mcbsp *mcbsp);
-void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int tx, int rx);
-void omap_mcbsp_stop(struct omap_mcbsp *mcbsp, int tx, int rx);
+void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int stream);
+void omap_mcbsp_stop(struct omap_mcbsp *mcbsp, int stream);
 
 /* McBSP functional clock source changing function */
 int omap2_mcbsp_set_clks_src(struct omap_mcbsp *mcbsp, u8 fck_src_id);
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index caa24c463b3e..a18b7ecc3a2e 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -201,27 +201,26 @@ static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd,
 				  struct snd_soc_dai *cpu_dai)
 {
 	struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
-	int err = 0, play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_RESUME:
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
 		mcbsp->active++;
-		omap_mcbsp_start(mcbsp, play, !play);
+		omap_mcbsp_start(mcbsp, substream->stream);
 		break;
 
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		omap_mcbsp_stop(mcbsp, play, !play);
+		omap_mcbsp_stop(mcbsp, substream->stream);
 		mcbsp->active--;
 		break;
 	default:
-		err = -EINVAL;
+		return -EINVAL;
 	}
 
-	return err;
+	return 0;
 }
 
 static snd_pcm_sframes_t omap_mcbsp_dai_delay(
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  parent reply	other threads:[~2018-11-07 13:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07 13:23 [PATCH v2 0/7] ASoC: omap-mcbsp: Cleanup and split core/sidetone support Peter Ujfalusi
2018-11-07 13:23 ` [PATCH v2 1/7] ASoC: omap-mcbsp: Clean up dma_data addr initialization code Peter Ujfalusi
2018-11-07 13:23 ` [PATCH v2 2/7] ASoC: omap-mcbsp: Clean up the interrupt handlers Peter Ujfalusi
2018-11-07 13:23 ` Peter Ujfalusi [this message]
2018-11-07 13:23 ` [PATCH v2 4/7] ASoC: omap-mcbsp: Move out the FIFO check from set_threshold and get_delay Peter Ujfalusi
2018-11-07 13:23 ` [PATCH v2 5/7] ASoC: omap-mcbsp: Re-arrange files for core McBSP and Sidetone function split Peter Ujfalusi
2018-11-07 13:23 ` [PATCH v2 6/7] ASoC: omap-mcbsp: Remove redundant check for mcbsp->pdata Peter Ujfalusi
2018-11-07 13:23 ` [PATCH v2 7/7] ASoC: omap-mcbsp: No need to initialize max_xx_thres when it is not used Peter Ujfalusi
2018-11-07 18:57 ` [PATCH v2 0/7] ASoC: omap-mcbsp: Cleanup and split core/sidetone support Jarkko Nikula
2018-11-08  7:13   ` Peter Ujfalusi
2018-11-08 11:58     ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181107132310.29597-4-peter.ujfalusi@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jarkko.nikula@bitmer.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.