summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorLucas Tanure <tanureal@opensource.cirrus.com>2018-10-19 12:44:22 -0400
committerMark Brown <broonie@kernel.org>2018-10-21 07:04:38 -0400
commitc5d09485def41cab9e75ba23abbf87080183183c (patch)
treead6bb363220f7ebfeeadd0edea7a2d48be72a3e0 /sound
parent318e741ee13b5a72f3051d9bb6852b1f4d02d0bb (diff)
ASoC: wm2000: Remove wm2000_read helper function
The return type "unsigned int" was used by the wm2000_read() function despite of the aspect that it will eventually return a negative error code. The resulting function doesn't add much to the code, so replace wm2000_read with regmap_read. Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/wm2000.c54
1 files changed, 30 insertions, 24 deletions
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index c5ae07234a00..bba330e30162 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -88,19 +88,6 @@ static int wm2000_write(struct i2c_client *i2c, unsigned int reg,
88 return regmap_write(wm2000->regmap, reg, value); 88 return regmap_write(wm2000->regmap, reg, value);
89} 89}
90 90
91static unsigned int wm2000_read(struct i2c_client *i2c, unsigned int r)
92{
93 struct wm2000_priv *wm2000 = i2c_get_clientdata(i2c);
94 unsigned int val;
95 int ret;
96
97 ret = regmap_read(wm2000->regmap, r, &val);
98 if (ret < 0)
99 return -1;
100
101 return val;
102}
103
104static void wm2000_reset(struct wm2000_priv *wm2000) 91static void wm2000_reset(struct wm2000_priv *wm2000)
105{ 92{
106 struct i2c_client *i2c = wm2000->i2c; 93 struct i2c_client *i2c = wm2000->i2c;
@@ -115,14 +102,15 @@ static void wm2000_reset(struct wm2000_priv *wm2000)
115static int wm2000_poll_bit(struct i2c_client *i2c, 102static int wm2000_poll_bit(struct i2c_client *i2c,
116 unsigned int reg, u8 mask) 103 unsigned int reg, u8 mask)
117{ 104{
105 struct wm2000_priv *wm2000 = i2c_get_clientdata(i2c);
118 int timeout = 4000; 106 int timeout = 4000;
119 int val; 107 unsigned int val;
120 108
121 val = wm2000_read(i2c, reg); 109 regmap_read(wm2000->regmap, reg, &val);
122 110
123 while (!(val & mask) && --timeout) { 111 while (!(val & mask) && --timeout) {
124 msleep(1); 112 msleep(1);
125 val = wm2000_read(i2c, reg); 113 regmap_read(wm2000->regmap, reg, &val);
126 } 114 }
127 115
128 if (timeout == 0) 116 if (timeout == 0)
@@ -135,6 +123,7 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue)
135{ 123{
136 struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); 124 struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev);
137 unsigned long rate; 125 unsigned long rate;
126 unsigned int val;
138 int ret; 127 int ret;
139 128
140 if (WARN_ON(wm2000->anc_mode != ANC_OFF)) 129 if (WARN_ON(wm2000->anc_mode != ANC_OFF))
@@ -213,12 +202,17 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue)
213 WM2000_MODE_THERMAL_ENABLE); 202 WM2000_MODE_THERMAL_ENABLE);
214 } 203 }
215 204
216 ret = wm2000_read(i2c, WM2000_REG_SPEECH_CLARITY); 205 ret = regmap_read(wm2000->regmap, WM2000_REG_SPEECH_CLARITY, &val);
206 if (ret != 0) {
207 dev_err(&i2c->dev, "Unable to read Speech Clarity: %d\n", ret);
208 regulator_bulk_disable(WM2000_NUM_SUPPLIES, wm2000->supplies);
209 return ret;
210 }
217 if (wm2000->speech_clarity) 211 if (wm2000->speech_clarity)
218 ret |= WM2000_SPEECH_CLARITY; 212 val |= WM2000_SPEECH_CLARITY;
219 else 213 else
220 ret &= ~WM2000_SPEECH_CLARITY; 214 val &= ~WM2000_SPEECH_CLARITY;
221 wm2000_write(i2c, WM2000_REG_SPEECH_CLARITY, ret); 215 wm2000_write(i2c, WM2000_REG_SPEECH_CLARITY, val);
222 216
223 wm2000_write(i2c, WM2000_REG_SYS_START0, 0x33); 217 wm2000_write(i2c, WM2000_REG_SYS_START0, 0x33);
224 wm2000_write(i2c, WM2000_REG_SYS_START1, 0x02); 218 wm2000_write(i2c, WM2000_REG_SYS_START1, 0x02);
@@ -824,7 +818,7 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
824 const char *filename; 818 const char *filename;
825 const struct firmware *fw = NULL; 819 const struct firmware *fw = NULL;
826 int ret, i; 820 int ret, i;
827 int reg; 821 unsigned int reg;
828 u16 id; 822 u16 id;
829 823
830 wm2000 = devm_kzalloc(&i2c->dev, sizeof(*wm2000), GFP_KERNEL); 824 wm2000 = devm_kzalloc(&i2c->dev, sizeof(*wm2000), GFP_KERNEL);
@@ -860,9 +854,17 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
860 } 854 }
861 855
862 /* Verify that this is a WM2000 */ 856 /* Verify that this is a WM2000 */
863 reg = wm2000_read(i2c, WM2000_REG_ID1); 857 ret = regmap_read(wm2000->regmap, WM2000_REG_ID1, &reg);
858 if (ret != 0) {
859 dev_err(&i2c->dev, "Unable to read ID1: %d\n", ret);
860 return ret;
861 }
864 id = reg << 8; 862 id = reg << 8;
865 reg = wm2000_read(i2c, WM2000_REG_ID2); 863 ret = regmap_read(wm2000->regmap, WM2000_REG_ID2, &reg);
864 if (ret != 0) {
865 dev_err(&i2c->dev, "Unable to read ID2: %d\n", ret);
866 return ret;
867 }
866 id |= reg & 0xff; 868 id |= reg & 0xff;
867 869
868 if (id != 0x2000) { 870 if (id != 0x2000) {
@@ -871,7 +873,11 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
871 goto err_supplies; 873 goto err_supplies;
872 } 874 }
873 875
874 reg = wm2000_read(i2c, WM2000_REG_REVISON); 876 ret = regmap_read(wm2000->regmap, WM2000_REG_REVISON, &reg);
877 if (ret != 0) {
878 dev_err(&i2c->dev, "Unable to read Revision: %d\n", ret);
879 return ret;
880 }
875 dev_info(&i2c->dev, "revision %c\n", reg + 'A'); 881 dev_info(&i2c->dev, "revision %c\n", reg + 'A');
876 882
877 wm2000->mclk = devm_clk_get(&i2c->dev, "MCLK"); 883 wm2000->mclk = devm_clk_get(&i2c->dev, "MCLK");