forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/codecs/nau8824.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * NAU88L24 ALSA SoC audio driver
34 *
45 * Copyright 2016 Nuvoton Technology Corp.
56 * Author: John Hsu <KCHSU0@nuvoton.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #include <linux/module.h>
....@@ -814,7 +811,7 @@
814811 static bool nau8824_is_jack_inserted(struct nau8824 *nau8824)
815812 {
816813 struct snd_soc_jack *jack = nau8824->jack;
817
- bool insert = FALSE;
814
+ bool insert = false;
818815
819816 if (nau8824->irq && jack)
820817 insert = jack->status & SND_JACK_HEADPHONE;
....@@ -1075,6 +1072,7 @@
10751072 struct snd_soc_component *component = dai->component;
10761073 struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
10771074 unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div;
1075
+ int err = -EINVAL;
10781076
10791077 nau8824_sema_acquire(nau8824, HZ);
10801078
....@@ -1091,7 +1089,7 @@
10911089 osr &= NAU8824_DAC_OVERSAMPLE_MASK;
10921090 if (nau8824_clock_check(nau8824, substream->stream,
10931091 nau8824->fs, osr))
1094
- return -EINVAL;
1092
+ goto error;
10951093 regmap_update_bits(nau8824->regmap, NAU8824_REG_CLK_DIVIDER,
10961094 NAU8824_CLK_DAC_SRC_MASK,
10971095 osr_dac_sel[osr].clk_src << NAU8824_CLK_DAC_SRC_SFT);
....@@ -1101,7 +1099,7 @@
11011099 osr &= NAU8824_ADC_SYNC_DOWN_MASK;
11021100 if (nau8824_clock_check(nau8824, substream->stream,
11031101 nau8824->fs, osr))
1104
- return -EINVAL;
1102
+ goto error;
11051103 regmap_update_bits(nau8824->regmap, NAU8824_REG_CLK_DIVIDER,
11061104 NAU8824_CLK_ADC_SRC_MASK,
11071105 osr_adc_sel[osr].clk_src << NAU8824_CLK_ADC_SRC_SFT);
....@@ -1122,7 +1120,7 @@
11221120 else if (bclk_fs <= 256)
11231121 bclk_div = 0;
11241122 else
1125
- return -EINVAL;
1123
+ goto error;
11261124 regmap_update_bits(nau8824->regmap,
11271125 NAU8824_REG_PORT0_I2S_PCM_CTRL_2,
11281126 NAU8824_I2S_LRC_DIV_MASK | NAU8824_I2S_BLK_DIV_MASK,
....@@ -1143,15 +1141,17 @@
11431141 val_len |= NAU8824_I2S_DL_32;
11441142 break;
11451143 default:
1146
- return -EINVAL;
1144
+ goto error;
11471145 }
11481146
11491147 regmap_update_bits(nau8824->regmap, NAU8824_REG_PORT0_I2S_PCM_CTRL_1,
11501148 NAU8824_I2S_DL_MASK, val_len);
1149
+ err = 0;
11511150
1151
+ error:
11521152 nau8824_sema_release(nau8824);
11531153
1154
- return 0;
1154
+ return err;
11551155 }
11561156
11571157 static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
....@@ -1159,8 +1159,6 @@
11591159 struct snd_soc_component *component = dai->component;
11601160 struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
11611161 unsigned int ctrl1_val = 0, ctrl2_val = 0;
1162
-
1163
- nau8824_sema_acquire(nau8824, HZ);
11641162
11651163 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
11661164 case SND_SOC_DAIFMT_CBM_CFM:
....@@ -1203,6 +1201,8 @@
12031201 return -EINVAL;
12041202 }
12051203
1204
+ nau8824_sema_acquire(nau8824, HZ);
1205
+
12061206 regmap_update_bits(nau8824->regmap, NAU8824_REG_PORT0_I2S_PCM_CTRL_1,
12071207 NAU8824_I2S_DF_MASK | NAU8824_I2S_BP_MASK |
12081208 NAU8824_I2S_PCMB_EN, ctrl1_val);