aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2015-01-14 13:42:33 -0500
committerMark Brown <broonie@kernel.org>2015-01-14 14:46:54 -0500
commitdcd60fc3445329d738a23ab7997717491c2f4cec (patch)
tree0359d50544616efd303a39cca0ec2b8115ad697e /sound
parentc92f1d0e7c8431f8b3bf1d42e951ead07b22078e (diff)
ASoC: samsung: i2s: Add get_other_dai helper function
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 <s.nawrocki@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/samsung/i2s.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index f75c19e5b5c3..cab2a2abc89b 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)
130 return active ? true : false; 130 return active ? true : false;
131} 131}
132 132
133/* Return pointer to the other DAI */
134static inline struct i2s_dai *get_other_dai(struct i2s_dai *i2s)
135{
136 return i2s->pri_dai ? : i2s->sec_dai;
137}
138
133/* If the other interface of the controller is transmitting data */ 139/* If the other interface of the controller is transmitting data */
134static inline bool other_tx_active(struct i2s_dai *i2s) 140static inline bool other_tx_active(struct i2s_dai *i2s)
135{ 141{
136 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 142 struct i2s_dai *other = get_other_dai(i2s);
137 143
138 return tx_active(other); 144 return tx_active(other);
139} 145}
@@ -160,7 +166,7 @@ static inline bool rx_active(struct i2s_dai *i2s)
160/* If the other interface of the controller is receiving data */ 166/* If the other interface of the controller is receiving data */
161static inline bool other_rx_active(struct i2s_dai *i2s) 167static inline bool other_rx_active(struct i2s_dai *i2s)
162{ 168{
163 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 169 struct i2s_dai *other = get_other_dai(i2s);
164 170
165 return rx_active(other); 171 return rx_active(other);
166} 172}
@@ -461,7 +467,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai,
461 int clk_id, unsigned int rfs, int dir) 467 int clk_id, unsigned int rfs, int dir)
462{ 468{
463 struct i2s_dai *i2s = to_info(dai); 469 struct i2s_dai *i2s = to_info(dai);
464 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 470 struct i2s_dai *other = get_other_dai(i2s);
465 u32 mod = readl(i2s->addr + I2SMOD); 471 u32 mod = readl(i2s->addr + I2SMOD);
466 const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs; 472 const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs;
467 unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off; 473 unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off;
@@ -733,7 +739,7 @@ static int i2s_startup(struct snd_pcm_substream *substream,
733 struct snd_soc_dai *dai) 739 struct snd_soc_dai *dai)
734{ 740{
735 struct i2s_dai *i2s = to_info(dai); 741 struct i2s_dai *i2s = to_info(dai);
736 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 742 struct i2s_dai *other = get_other_dai(i2s);
737 unsigned long flags; 743 unsigned long flags;
738 744
739 spin_lock_irqsave(&lock, flags); 745 spin_lock_irqsave(&lock, flags);
@@ -760,7 +766,7 @@ static void i2s_shutdown(struct snd_pcm_substream *substream,
760 struct snd_soc_dai *dai) 766 struct snd_soc_dai *dai)
761{ 767{
762 struct i2s_dai *i2s = to_info(dai); 768 struct i2s_dai *i2s = to_info(dai);
763 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 769 struct i2s_dai *other = get_other_dai(i2s);
764 unsigned long flags; 770 unsigned long flags;
765 const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs; 771 const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs;
766 772
@@ -791,7 +797,7 @@ static void i2s_shutdown(struct snd_pcm_substream *substream,
791 797
792static int config_setup(struct i2s_dai *i2s) 798static int config_setup(struct i2s_dai *i2s)
793{ 799{
794 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 800 struct i2s_dai *other = get_other_dai(i2s);
795 unsigned rfs, bfs, blc; 801 unsigned rfs, bfs, blc;
796 u32 psr; 802 u32 psr;
797 803
@@ -899,7 +905,7 @@ static int i2s_set_clkdiv(struct snd_soc_dai *dai,
899 int div_id, int div) 905 int div_id, int div)
900{ 906{
901 struct i2s_dai *i2s = to_info(dai); 907 struct i2s_dai *i2s = to_info(dai);
902 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 908 struct i2s_dai *other = get_other_dai(i2s);
903 909
904 switch (div_id) { 910 switch (div_id) {
905 case SAMSUNG_I2S_DIV_BCLK: 911 case SAMSUNG_I2S_DIV_BCLK:
@@ -968,7 +974,7 @@ static int i2s_resume(struct snd_soc_dai *dai)
968static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) 974static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
969{ 975{
970 struct i2s_dai *i2s = to_info(dai); 976 struct i2s_dai *i2s = to_info(dai);
971 struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai; 977 struct i2s_dai *other = get_other_dai(i2s);
972 978
973 if (is_secondary(i2s)) { /* If this is probe on the secondary DAI */ 979 if (is_secondary(i2s)) { /* If this is probe on the secondary DAI */
974 samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback, 980 samsung_asoc_init_dma_data(dai, &other->sec_dai->dma_playback,
@@ -1271,7 +1277,7 @@ static int samsung_i2s_remove(struct platform_device *pdev)
1271 struct i2s_dai *i2s, *other; 1277 struct i2s_dai *i2s, *other;
1272 1278
1273 i2s = dev_get_drvdata(&pdev->dev); 1279 i2s = dev_get_drvdata(&pdev->dev);
1274 other = i2s->pri_dai ? : i2s->sec_dai; 1280 other = get_other_dai(i2s);
1275 1281
1276 if (other) { 1282 if (other) {
1277 other->pri_dai = NULL; 1283 other->pri_dai = NULL;