aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-08 22:15:10 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-11 21:00:03 -0400
commitb7c95d9146c8201740e2ce9dca7fb1eb8b7b0053 (patch)
tree619a148654249e33b2e26c718fad3056ddacd4a0
parente373cbfb2f7d194e48d528794b3b99274d4c1a97 (diff)
ASoC: wm8903: Move interrupt request to I2C probe
There's no reason to defer requesting of the interrupt until the CODEC probe and doing so results in more work if we hit an error as we'll have registered the CODEC with the core. It's neater to acquire as many of the resources we'll need as we can in the bus probe function. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Tested-by: Stephen Warren <swarren@wwwdotorg.org>
-rw-r--r--sound/soc/codecs/wm8903.c65
1 files changed, 31 insertions, 34 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index f5d47c8e5402..7261a68aac6f 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -1895,9 +1895,7 @@ static void wm8903_free_gpio(struct wm8903_priv *wm8903)
1895static int wm8903_probe(struct snd_soc_codec *codec) 1895static int wm8903_probe(struct snd_soc_codec *codec)
1896{ 1896{
1897 struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); 1897 struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec);
1898 struct wm8903_platform_data *pdata = wm8903->pdata;
1899 int ret; 1898 int ret;
1900 int trigger, irq_pol;
1901 u16 val; 1899 u16 val;
1902 1900
1903 wm8903->codec = codec; 1901 wm8903->codec = codec;
@@ -1909,32 +1907,6 @@ static int wm8903_probe(struct snd_soc_codec *codec)
1909 return ret; 1907 return ret;
1910 } 1908 }
1911 1909
1912 if (wm8903->irq) {
1913 if (pdata->irq_active_low) {
1914 trigger = IRQF_TRIGGER_LOW;
1915 irq_pol = WM8903_IRQ_POL;
1916 } else {
1917 trigger = IRQF_TRIGGER_HIGH;
1918 irq_pol = 0;
1919 }
1920
1921 snd_soc_update_bits(codec, WM8903_INTERRUPT_CONTROL,
1922 WM8903_IRQ_POL, irq_pol);
1923
1924 ret = request_threaded_irq(wm8903->irq, NULL, wm8903_irq,
1925 trigger | IRQF_ONESHOT,
1926 "wm8903", wm8903);
1927 if (ret != 0) {
1928 dev_err(codec->dev, "Failed to request IRQ: %d\n",
1929 ret);
1930 return ret;
1931 }
1932
1933 /* Enable write sequencer interrupts */
1934 snd_soc_update_bits(codec, WM8903_INTERRUPT_STATUS_1_MASK,
1935 WM8903_IM_WSEQ_BUSY_EINT, 0);
1936 }
1937
1938 /* power on device */ 1910 /* power on device */
1939 wm8903_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 1911 wm8903_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1940 1912
@@ -1975,11 +1947,7 @@ static int wm8903_probe(struct snd_soc_codec *codec)
1975/* power down chip */ 1947/* power down chip */
1976static int wm8903_remove(struct snd_soc_codec *codec) 1948static int wm8903_remove(struct snd_soc_codec *codec)
1977{ 1949{
1978 struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec);
1979
1980 wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); 1950 wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF);
1981 if (wm8903->irq)
1982 free_irq(wm8903->irq, wm8903);
1983 1951
1984 return 0; 1952 return 0;
1985} 1953}
@@ -2089,8 +2057,9 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
2089{ 2057{
2090 struct wm8903_platform_data *pdata = dev_get_platdata(&i2c->dev); 2058 struct wm8903_platform_data *pdata = dev_get_platdata(&i2c->dev);
2091 struct wm8903_priv *wm8903; 2059 struct wm8903_priv *wm8903;
2060 int trigger;
2092 bool mic_gpio = false; 2061 bool mic_gpio = false;
2093 unsigned int val; 2062 unsigned int val, irq_pol;
2094 int ret, i; 2063 int ret, i;
2095 2064
2096 wm8903 = devm_kzalloc(&i2c->dev, sizeof(struct wm8903_priv), 2065 wm8903 = devm_kzalloc(&i2c->dev, sizeof(struct wm8903_priv),
@@ -2108,7 +2077,6 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
2108 } 2077 }
2109 2078
2110 i2c_set_clientdata(i2c, wm8903); 2079 i2c_set_clientdata(i2c, wm8903);
2111 wm8903->irq = i2c->irq;
2112 2080
2113 /* If no platform data was supplied, create storage for defaults */ 2081 /* If no platform data was supplied, create storage for defaults */
2114 if (pdata) { 2082 if (pdata) {
@@ -2202,6 +2170,33 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
2202 2170
2203 wm8903->mic_delay = pdata->micdet_delay; 2171 wm8903->mic_delay = pdata->micdet_delay;
2204 2172
2173 if (i2c->irq) {
2174 if (pdata->irq_active_low) {
2175 trigger = IRQF_TRIGGER_LOW;
2176 irq_pol = WM8903_IRQ_POL;
2177 } else {
2178 trigger = IRQF_TRIGGER_HIGH;
2179 irq_pol = 0;
2180 }
2181
2182 regmap_update_bits(wm8903->regmap, WM8903_INTERRUPT_CONTROL,
2183 WM8903_IRQ_POL, irq_pol);
2184
2185 ret = request_threaded_irq(i2c->irq, NULL, wm8903_irq,
2186 trigger | IRQF_ONESHOT,
2187 "wm8903", wm8903);
2188 if (ret != 0) {
2189 dev_err(wm8903->dev, "Failed to request IRQ: %d\n",
2190 ret);
2191 return ret;
2192 }
2193
2194 /* Enable write sequencer interrupts */
2195 regmap_update_bits(wm8903->regmap,
2196 WM8903_INTERRUPT_STATUS_1_MASK,
2197 WM8903_IM_WSEQ_BUSY_EINT, 0);
2198 }
2199
2205 ret = snd_soc_register_codec(&i2c->dev, 2200 ret = snd_soc_register_codec(&i2c->dev,
2206 &soc_codec_dev_wm8903, &wm8903_dai, 1); 2201 &soc_codec_dev_wm8903, &wm8903_dai, 1);
2207 if (ret != 0) 2202 if (ret != 0)
@@ -2216,6 +2211,8 @@ static __devexit int wm8903_i2c_remove(struct i2c_client *client)
2216{ 2211{
2217 struct wm8903_priv *wm8903 = i2c_get_clientdata(client); 2212 struct wm8903_priv *wm8903 = i2c_get_clientdata(client);
2218 2213
2214 if (client->irq)
2215 free_irq(client->irq, wm8903);
2219 wm8903_free_gpio(wm8903); 2216 wm8903_free_gpio(wm8903);
2220 snd_soc_unregister_codec(&client->dev); 2217 snd_soc_unregister_codec(&client->dev);
2221 2218