From patchwork Thu Dec 11 17:45:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 5476991 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 14083BEEA8 for ; Thu, 11 Dec 2014 17:51:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E200201BB for ; Thu, 11 Dec 2014 17:51:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id B739120160 for ; Thu, 11 Dec 2014 17:51:47 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A93962652F1; Thu, 11 Dec 2014 18:51:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id CDB442654BB; Thu, 11 Dec 2014 18:48:47 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4F286265701; Thu, 11 Dec 2014 18:48:46 +0100 (CET) Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by alsa0.perex.cz (Postfix) with ESMTP id AC3272652F5 for ; Thu, 11 Dec 2014 18:46:44 +0100 (CET) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGF00GHIIPV7060@mailout3.samsung.com> for alsa-devel@alsa-project.org; Fri, 12 Dec 2014 02:46:43 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-08-5489d8833f75 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B9.4C.09430.388D9845; Fri, 12 Dec 2014 02:46:43 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NGF00MHSIP1T280@mmp1.samsung.com>; Fri, 12 Dec 2014 02:46:43 +0900 (KST) From: Sylwester Nawrocki To: alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org Date: Thu, 11 Dec 2014 18:45:45 +0100 Message-id: <1418319952-10163-8-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1418319952-10163-1-git-send-email-s.nawrocki@samsung.com> References: <1418319952-10163-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t9jAd3mG50hBp3rlS2uXDzEZDH14RM2 i0fzHzNbzDi/j8ni983vbBaH37SzWlxc8YXJgd1jw+cmNo9F37M8Nq3qZPPo27KK0ePzJrkA 1igum5TUnMyy1CJ9uwSujObZsxgLNshWTOl7xtLA+Fe8i5GTQ0LAROL5/I0sELaYxIV769m6 GLk4hAQWMUq8/tjACOF0MEl8274XrIpNwFCi92gfI4gtIuAkMXPOe7AOZoFmRonzv24wgSSE BQIk1vZNZQWxWQRUJb5+OwRm8wq4SexonsrcxcgBtE5BYs4kG5Awp4C7xPpf58DmCwGVPNrY wDqBkXcBI8MqRtHUguSC4qT0XCO94sTc4tK8dL3k/NxNjOCgeia9g3FVg8UhRgEORiUe3oz4 zhAh1sSy4srcQ4wSHMxKIrx7LgOFeFMSK6tSi/Lji0pzUosPMUpzsCiJ8yrZt4UICaQnlqRm p6YWpBbBZJk4OKUaGEsk2dzU0t40h3PzdQSbLNXXNX7cscbtjE37xfvJZxQP1y/2jDAT697H 6L3LcNmU4ylXdhUXNqtsnPw0gbnmm/TffYpBB5zvtt56dU7o+uWfLPVyF5KjDvLduBrK5f3o 6MKHzEHFQpP/TbHRtg9aZnv45sKqzrRb1/hesczyi1qX0ddv0LrgkhJLcUaioRZzUXEiAGZc 1UMmAgAA Cc: sbkim73@samsung.com, broonie@kernel.org, drake@endlessm.com, Sylwester Nawrocki , padma.v@samsung.com Subject: [alsa-devel] [PATCH/RFC 07/14] ASoC: samsung: i2s: Add get_other_dai helper function X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The code to get pointer to the other DAI is repeated multiple times. Add a helper function and use it to simplify the code a little. Signed-off-by: Sylwester Nawrocki --- sound/soc/samsung/i2s.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 871925b..6501c40 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -130,10 +130,16 @@ static inline bool tx_active(struct i2s_dai *i2s) return active ? true : false; } +/* Return pointer to the other DAI */ +static inline struct i2s_dai *get_other_dai(struct i2s_dai *i2s) +{ + return i2s->pri_dai ? : i2s->sec_dai; +} + /* If the other interface of the controller is transmitting data */ static inline bool other_tx_active(struct i2s_dai *i2s) { - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); return tx_active(other); } @@ -160,7 +166,7 @@ static inline bool rx_active(struct i2s_dai *i2s) /* If the other interface of the controller is receiving data */ static inline bool other_rx_active(struct i2s_dai *i2s) { - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); return rx_active(other); } @@ -461,7 +467,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int rfs, int dir) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); u32 mod = readl(i2s->addr + I2SMOD); const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs; unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off; @@ -733,7 +739,7 @@ static int i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); unsigned long flags; spin_lock_irqsave(&lock, flags); @@ -760,7 +766,7 @@ static void i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); unsigned long flags; const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs; @@ -791,7 +797,7 @@ static void i2s_shutdown(struct snd_pcm_substream *substream, static int config_setup(struct i2s_dai *i2s) { - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); unsigned rfs, bfs, blc; u32 psr; @@ -899,7 +905,7 @@ static int i2s_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); switch (div_id) { case SAMSUNG_I2S_DIV_BCLK: @@ -968,7 +974,7 @@ static int i2s_resume(struct snd_soc_dai *dai) static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) { struct i2s_dai *i2s = to_info(dai); - struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; + struct i2s_dai *other = get_other_dai(i2s); if (is_secondary(i2s)) { /* If this is probe on the secondary DAI */ samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback, @@ -1271,7 +1277,7 @@ static int samsung_i2s_remove(struct platform_device *pdev) struct i2s_dai *i2s, *other; i2s = dev_get_drvdata(&pdev->dev); - other = i2s->pri_dai ? : i2s->sec_dai; + other = get_other_dai(i2s); if (other) { other->pri_dai = NULL;