aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-jack.c
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@linux.intel.com>2014-05-26 07:34:36 -0400
committerMark Brown <broonie@linaro.org>2014-05-26 10:23:14 -0400
commit50dfb69d1bb0062e2811547525c73e9a45a423e9 (patch)
treeff6bbcec55ce9a19cab917931288c91ecac21c03 /sound/soc/soc-jack.c
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
ASoC: jack: Basic GPIO descriptor conversion
This patch does basic GPIO descriptor conversion to soc-jack. Even the GPIOs are still passed and requested using legacy GPIO numbers the driver internals are converted to use GPIO descriptor API. Motivation for this is to prepare soc-jack so that it will allow registering jack GPIO pins using both GPIO descriptors and legacy GPIO numbers. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-jack.c')
-rw-r--r--sound/soc/soc-jack.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index b903f822d1b2..7203842fea66 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -14,6 +14,7 @@
14#include <sound/jack.h> 14#include <sound/jack.h>
15#include <sound/soc.h> 15#include <sound/soc.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/gpio/consumer.h>
17#include <linux/interrupt.h> 18#include <linux/interrupt.h>
18#include <linux/workqueue.h> 19#include <linux/workqueue.h>
19#include <linux/delay.h> 20#include <linux/delay.h>
@@ -240,7 +241,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
240 int enable; 241 int enable;
241 int report; 242 int report;
242 243
243 enable = gpio_get_value_cansleep(gpio->gpio); 244 enable = gpiod_get_value_cansleep(gpio->desc);
244 if (gpio->invert) 245 if (gpio->invert)
245 enable = !enable; 246 enable = !enable;
246 247
@@ -314,14 +315,16 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
314 if (ret) 315 if (ret)
315 goto undo; 316 goto undo;
316 317
317 ret = gpio_direction_input(gpios[i].gpio); 318 gpios[i].desc = gpio_to_desc(gpios[i].gpio);
319
320 ret = gpiod_direction_input(gpios[i].desc);
318 if (ret) 321 if (ret)
319 goto err; 322 goto err;
320 323
321 INIT_DELAYED_WORK(&gpios[i].work, gpio_work); 324 INIT_DELAYED_WORK(&gpios[i].work, gpio_work);
322 gpios[i].jack = jack; 325 gpios[i].jack = jack;
323 326
324 ret = request_any_context_irq(gpio_to_irq(gpios[i].gpio), 327 ret = request_any_context_irq(gpiod_to_irq(gpios[i].desc),
325 gpio_handler, 328 gpio_handler,
326 IRQF_TRIGGER_RISING | 329 IRQF_TRIGGER_RISING |
327 IRQF_TRIGGER_FALLING, 330 IRQF_TRIGGER_FALLING,
@@ -331,7 +334,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
331 goto err; 334 goto err;
332 335
333 if (gpios[i].wake) { 336 if (gpios[i].wake) {
334 ret = irq_set_irq_wake(gpio_to_irq(gpios[i].gpio), 1); 337 ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1);
335 if (ret != 0) 338 if (ret != 0)
336 dev_err(jack->codec->dev, "ASoC: " 339 dev_err(jack->codec->dev, "ASoC: "
337 "Failed to mark GPIO %d as wake source: %d\n", 340 "Failed to mark GPIO %d as wake source: %d\n",
@@ -339,7 +342,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
339 } 342 }
340 343
341 /* Expose GPIO value over sysfs for diagnostic purposes */ 344 /* Expose GPIO value over sysfs for diagnostic purposes */
342 gpio_export(gpios[i].gpio, false); 345 gpiod_export(gpios[i].desc, false);
343 346
344 /* Update initial jack status */ 347 /* Update initial jack status */
345 schedule_delayed_work(&gpios[i].work, 348 schedule_delayed_work(&gpios[i].work,
@@ -372,10 +375,10 @@ void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
372 int i; 375 int i;
373 376
374 for (i = 0; i < count; i++) { 377 for (i = 0; i < count; i++) {
375 gpio_unexport(gpios[i].gpio); 378 gpiod_unexport(gpios[i].desc);
376 free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]); 379 free_irq(gpiod_to_irq(gpios[i].desc), &gpios[i]);
377 cancel_delayed_work_sync(&gpios[i].work); 380 cancel_delayed_work_sync(&gpios[i].work);
378 gpio_free(gpios[i].gpio); 381 gpiod_put(gpios[i].desc);
379 gpios[i].jack = NULL; 382 gpios[i].jack = NULL;
380 } 383 }
381} 384}