diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2011-03-07 02:04:57 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-03-07 07:19:42 -0500 |
commit | b7874e4490aa201be2f904ffd8bb88a7b9970c6a (patch) | |
tree | 5f3beafa804d7ae25766a517f00b92463cdb068a /sound/soc/samsung | |
parent | da70a3e926b9d8456240ede505c8854d89c90e49 (diff) |
ASoC: neo1973_gta02_wm8753: Use gpio_request_array to request gpios
Using gpio_request_array instead of requesting and setting up each gpio by hand
makes the code more readable and more compact.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/samsung')
-rw-r--r-- | sound/soc/samsung/neo1973_gta02_wm8753.c | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/sound/soc/samsung/neo1973_gta02_wm8753.c b/sound/soc/samsung/neo1973_gta02_wm8753.c index b007dd7902e6..28d8448e959d 100644 --- a/sound/soc/samsung/neo1973_gta02_wm8753.c +++ b/sound/soc/samsung/neo1973_gta02_wm8753.c | |||
@@ -370,6 +370,11 @@ static struct snd_soc_card neo1973_gta02 = { | |||
370 | .num_links = ARRAY_SIZE(neo1973_gta02_dai), | 370 | .num_links = ARRAY_SIZE(neo1973_gta02_dai), |
371 | }; | 371 | }; |
372 | 372 | ||
373 | static const struct gpio neo1973_gta02_gpios[] = { | ||
374 | { GTA02_GPIO_HP_IN, GPIOF_OUT_INIT_HIGH, "GTA02_HP_IN" }, | ||
375 | { GTA02_GPIO_AMP_SHUT, GPIOF_OUT_INIT_HIGH, "GTA02_AMP_SHUT" }, | ||
376 | }; | ||
377 | |||
373 | static struct platform_device *neo1973_gta02_snd_device; | 378 | static struct platform_device *neo1973_gta02_snd_device; |
374 | 379 | ||
375 | static int __init neo1973_gta02_init(void) | 380 | static int __init neo1973_gta02_init(void) |
@@ -382,9 +387,16 @@ static int __init neo1973_gta02_init(void) | |||
382 | return -ENODEV; | 387 | return -ENODEV; |
383 | } | 388 | } |
384 | 389 | ||
390 | ret = gpio_request_array(neo1973_gta02_gpios, | ||
391 | ARRAY_SIZE(neo1973_gta02_gpios)); | ||
392 | if (ret) | ||
393 | return ret; | ||
394 | |||
385 | neo1973_gta02_snd_device = platform_device_alloc("soc-audio", -1); | 395 | neo1973_gta02_snd_device = platform_device_alloc("soc-audio", -1); |
386 | if (!neo1973_gta02_snd_device) | 396 | if (!neo1973_gta02_snd_device) { |
387 | return -ENOMEM; | 397 | ret = -ENOMEM; |
398 | goto err_gpio_free; | ||
399 | } | ||
388 | 400 | ||
389 | /* register bluetooth DAI here */ | 401 | /* register bluetooth DAI here */ |
390 | ret = snd_soc_register_dai(&neo1973_gta02_snd_device->dev, &bt_dai); | 402 | ret = snd_soc_register_dai(&neo1973_gta02_snd_device->dev, &bt_dai); |
@@ -397,43 +409,14 @@ static int __init neo1973_gta02_init(void) | |||
397 | if (ret) | 409 | if (ret) |
398 | goto err_unregister_dai; | 410 | goto err_unregister_dai; |
399 | 411 | ||
400 | /* Initialise GPIOs used by amp */ | ||
401 | ret = gpio_request(GTA02_GPIO_HP_IN, "GTA02_HP_IN"); | ||
402 | if (ret) { | ||
403 | pr_err("gta02_wm8753: Failed to register GPIO %d\n", GTA02_GPIO_HP_IN); | ||
404 | goto err_del_device; | ||
405 | } | ||
406 | |||
407 | ret = gpio_direction_output(GTA02_GPIO_HP_IN, 1); | ||
408 | if (ret) { | ||
409 | pr_err("gta02_wm8753: Failed to configure GPIO %d\n", GTA02_GPIO_HP_IN); | ||
410 | goto err_free_gpio_hp_in; | ||
411 | } | ||
412 | |||
413 | ret = gpio_request(GTA02_GPIO_AMP_SHUT, "GTA02_AMP_SHUT"); | ||
414 | if (ret) { | ||
415 | pr_err("gta02_wm8753: Failed to register GPIO %d\n", GTA02_GPIO_AMP_SHUT); | ||
416 | goto err_free_gpio_hp_in; | ||
417 | } | ||
418 | |||
419 | ret = gpio_direction_output(GTA02_GPIO_AMP_SHUT, 1); | ||
420 | if (ret) { | ||
421 | pr_err("gta02_wm8753: Failed to configure GPIO %d\n", GTA02_GPIO_AMP_SHUT); | ||
422 | goto err_free_gpio_amp_shut; | ||
423 | } | ||
424 | |||
425 | return 0; | 412 | return 0; |
426 | 413 | ||
427 | err_free_gpio_amp_shut: | ||
428 | gpio_free(GTA02_GPIO_AMP_SHUT); | ||
429 | err_free_gpio_hp_in: | ||
430 | gpio_free(GTA02_GPIO_HP_IN); | ||
431 | err_del_device: | ||
432 | platform_device_del(neo1973_gta02_snd_device); | ||
433 | err_unregister_dai: | 414 | err_unregister_dai: |
434 | snd_soc_unregister_dai(&neo1973_gta02_snd_device->dev); | 415 | snd_soc_unregister_dai(&neo1973_gta02_snd_device->dev); |
435 | err_put_device: | 416 | err_put_device: |
436 | platform_device_put(neo1973_gta02_snd_device); | 417 | platform_device_put(neo1973_gta02_snd_device); |
418 | err_gpio_free: | ||
419 | gpio_free_array(neo1973_gta02_gpios, ARRAY_SIZE(neo1973_gta02_gpios)); | ||
437 | return ret; | 420 | return ret; |
438 | } | 421 | } |
439 | module_init(neo1973_gta02_init); | 422 | module_init(neo1973_gta02_init); |
@@ -442,8 +425,7 @@ static void __exit neo1973_gta02_exit(void) | |||
442 | { | 425 | { |
443 | snd_soc_unregister_dai(&neo1973_gta02_snd_device->dev); | 426 | snd_soc_unregister_dai(&neo1973_gta02_snd_device->dev); |
444 | platform_device_unregister(neo1973_gta02_snd_device); | 427 | platform_device_unregister(neo1973_gta02_snd_device); |
445 | gpio_free(GTA02_GPIO_HP_IN); | 428 | gpio_free_array(neo1973_gta02_gpios, ARRAY_SIZE(neo1973_gta02_gpios)); |
446 | gpio_free(GTA02_GPIO_AMP_SHUT); | ||
447 | } | 429 | } |
448 | module_exit(neo1973_gta02_exit); | 430 | module_exit(neo1973_gta02_exit); |
449 | 431 | ||