From patchwork Fri Dec 19 13:55:27 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: 5519701 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 115A39F30B for ; Fri, 19 Dec 2014 14:01:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F3EAF20158 for ; Fri, 19 Dec 2014 14:01:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0576720131 for ; Fri, 19 Dec 2014 14:01:52 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6656E264F28; Fri, 19 Dec 2014 15:01:50 +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 DF5A9264F28; Fri, 19 Dec 2014 14:59:04 +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 87AAD264F8D; Fri, 19 Dec 2014 14:59:03 +0100 (CET) Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by alsa0.perex.cz (Postfix) with ESMTP id 83C90264F19 for ; Fri, 19 Dec 2014 14:58:03 +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 <0NGU002131GQHH40@mailout3.samsung.com> for alsa-devel@alsa-project.org; Fri, 19 Dec 2014 22:58:02 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-c9-54942eea7747 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 60.B6.09430.AEE24945; Fri, 19 Dec 2014 22:58:02 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NGU00HVQ1CREV30@mmp2.samsung.com>; Fri, 19 Dec 2014 22:58:02 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org, kgene@kernel.org, alsa-devel@alsa-project.org Date: Fri, 19 Dec 2014 14:55:27 +0100 Message-id: <1418997336-17777-8-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1418997336-17777-1-git-send-email-s.nawrocki@samsung.com> References: <1418997336-17777-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMLMWRmVeSWpSXmKPExsVy+t9jQd1XelNCDPZuEre4cvEQk8XUh0/Y LOYfOcdq8Wj+Y2aL/sevmS02Pb7GajHj/D4mi983v7NZHH7TzmpxccUXJgcujw2fm9g8Fn3P 8ti0qpPNY/OSeo++LasYPT5vkgtgi+KySUnNySxLLdK3S+DK2Lr0BHvBTNmKw33dzA2Mb8S7 GDk4JARMJBa98epi5AQyxSQu3FvP1sXIxSEkMJ1R4mP7FmYIp4NJomH7M3aQKjYBQ4neo32M ILaIgKvE4/83WUCKmAWuMUq8+DQFrEhYwF/i0bIVzCA2i4CqxLsD8xlBtvEKuEms3ioCsVhB Ys4kGxCTU8BdYtlSD5BiIaCC7Se2s01g5F3AyLCKUTS1ILmgOCk910ivODG3uDQvXS85P3cT IzjonknvYFzVYHGIUYCDUYmHt6NwcogQa2JZcWXuIUYJDmYlEd6PwlNChHhTEiurUovy44tK c1KLDzFKc7AoifMq2beFCAmkJ5akZqemFqQWwWSZODilGhiXHW3I1Xm174Fnx+YXVauXrXg2 8Ul/20b+jVzP7NhXLRZNLHX/VBdw0qFW4O2BdWxSPhwfHZ6v+3FV4K1w3DKZ7ydeiTJU/320 UeCF23mpg+cfqC2omSmy/X3tq3Dno8eq70QtPf4j/meSw3153ozLsZMskyLfGSQvrFbak8a2 ITvNiH/dMvljSizFGYmGWsxFxYkAcB7wFDYCAAA= Cc: devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, padma.v@samsung.com, sbkim73@samsung.com, drake@endlessm.com, Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH v2 07/16] 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 instead. 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 80b5362..c4d4ccc 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;