summaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-10-07 02:54:28 +0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-10-07 23:58:56 +0400
commit4c14d78e8ad3bacfe1f70cb49ae17afcd658e368 (patch)
treeca487b5abebf8ce0b587434b682070c242e718ea /sound/soc
parentde535a5be53a06738409538c471a10a9de357bdd (diff)
downloadlinux-4c14d78e8ad3bacfe1f70cb49ae17afcd658e368.tar.xz
ASoC: Use delayed work for debounce of GPIO based jacks
Rather than block the workqueue by sleeping to do the debounce use delayed work to implement the debounce time. This should also means that we extend the debounce time on each new bounce, potentially allowing shorter debounce times for clean insertions. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Jarkko Nikula <jhnikula@gmail.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/soc-jack.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 8862770aa221..8a0a9205b1e7 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -188,9 +188,6 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
int enable;
int report;
- if (gpio->debounce_time > 0)
- mdelay(gpio->debounce_time);
-
enable = gpio_get_value(gpio->gpio);
if (gpio->invert)
enable = !enable;
@@ -211,7 +208,8 @@ static irqreturn_t gpio_handler(int irq, void *data)
{
struct snd_soc_jack_gpio *gpio = data;
- schedule_work(&gpio->work);
+ schedule_delayed_work(&gpio->work,
+ msecs_to_jiffies(gpio->debounce_time));
return IRQ_HANDLED;
}
@@ -221,7 +219,7 @@ static void gpio_work(struct work_struct *work)
{
struct snd_soc_jack_gpio *gpio;
- gpio = container_of(work, struct snd_soc_jack_gpio, work);
+ gpio = container_of(work, struct snd_soc_jack_gpio, work.work);
snd_soc_jack_gpio_detect(gpio);
}
@@ -262,7 +260,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
if (ret)
goto err;
- INIT_WORK(&gpios[i].work, gpio_work);
+ INIT_DELAYED_WORK(&gpios[i].work, gpio_work);
gpios[i].jack = jack;
ret = request_irq(gpio_to_irq(gpios[i].gpio),
@@ -312,6 +310,7 @@ void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
gpio_unexport(gpios[i].gpio);
#endif
free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]);
+ cancel_delayed_work_sync(&gpios[i].work);
gpio_free(gpios[i].gpio);
gpios[i].jack = NULL;
}