aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-jack.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-jack.c')
-rw-r--r--sound/soc/soc-jack.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 29159e1781d0..8a0a9205b1e7 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -32,14 +32,14 @@
32 * Returns zero if successful, or a negative error code on failure. 32 * Returns zero if successful, or a negative error code on failure.
33 * On success jack will be initialised. 33 * On success jack will be initialised.
34 */ 34 */
35int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type, 35int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
36 struct snd_soc_jack *jack) 36 struct snd_soc_jack *jack)
37{ 37{
38 jack->card = card; 38 jack->codec = codec;
39 INIT_LIST_HEAD(&jack->pins); 39 INIT_LIST_HEAD(&jack->pins);
40 BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); 40 BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
41 41
42 return snd_jack_new(card->codec->card, id, type, &jack->jack); 42 return snd_jack_new(codec->card->snd_card, id, type, &jack->jack);
43} 43}
44EXPORT_SYMBOL_GPL(snd_soc_jack_new); 44EXPORT_SYMBOL_GPL(snd_soc_jack_new);
45 45
@@ -67,7 +67,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
67 if (!jack) 67 if (!jack)
68 return; 68 return;
69 69
70 codec = jack->card->codec; 70 codec = jack->codec;
71 71
72 mutex_lock(&codec->mutex); 72 mutex_lock(&codec->mutex);
73 73
@@ -188,9 +188,6 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
188 int enable; 188 int enable;
189 int report; 189 int report;
190 190
191 if (gpio->debounce_time > 0)
192 mdelay(gpio->debounce_time);
193
194 enable = gpio_get_value(gpio->gpio); 191 enable = gpio_get_value(gpio->gpio);
195 if (gpio->invert) 192 if (gpio->invert)
196 enable = !enable; 193 enable = !enable;
@@ -211,7 +208,8 @@ static irqreturn_t gpio_handler(int irq, void *data)
211{ 208{
212 struct snd_soc_jack_gpio *gpio = data; 209 struct snd_soc_jack_gpio *gpio = data;
213 210
214 schedule_work(&gpio->work); 211 schedule_delayed_work(&gpio->work,
212 msecs_to_jiffies(gpio->debounce_time));
215 213
216 return IRQ_HANDLED; 214 return IRQ_HANDLED;
217} 215}
@@ -221,7 +219,7 @@ static void gpio_work(struct work_struct *work)
221{ 219{
222 struct snd_soc_jack_gpio *gpio; 220 struct snd_soc_jack_gpio *gpio;
223 221
224 gpio = container_of(work, struct snd_soc_jack_gpio, work); 222 gpio = container_of(work, struct snd_soc_jack_gpio, work.work);
225 snd_soc_jack_gpio_detect(gpio); 223 snd_soc_jack_gpio_detect(gpio);
226} 224}
227 225
@@ -262,13 +260,13 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
262 if (ret) 260 if (ret)
263 goto err; 261 goto err;
264 262
265 INIT_WORK(&gpios[i].work, gpio_work); 263 INIT_DELAYED_WORK(&gpios[i].work, gpio_work);
266 gpios[i].jack = jack; 264 gpios[i].jack = jack;
267 265
268 ret = request_irq(gpio_to_irq(gpios[i].gpio), 266 ret = request_irq(gpio_to_irq(gpios[i].gpio),
269 gpio_handler, 267 gpio_handler,
270 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 268 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
271 jack->card->dev->driver->name, 269 jack->codec->dev->driver->name,
272 &gpios[i]); 270 &gpios[i]);
273 if (ret) 271 if (ret)
274 goto err; 272 goto err;
@@ -312,6 +310,7 @@ void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
312 gpio_unexport(gpios[i].gpio); 310 gpio_unexport(gpios[i].gpio);
313#endif 311#endif
314 free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]); 312 free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]);
313 cancel_delayed_work_sync(&gpios[i].work);
315 gpio_free(gpios[i].gpio); 314 gpio_free(gpios[i].gpio);
316 gpios[i].jack = NULL; 315 gpios[i].jack = NULL;
317 } 316 }