aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/uda134x.c
diff options
context:
space:
mode:
authorIan Molton <ian@mnementh.co.uk>2009-01-08 19:23:21 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-01-09 05:39:49 -0500
commit3e8e1952e3a3dd59b11233a532ca68e6471742d9 (patch)
tree3dff59c0b09cbcbc0e4b80a00cecd507219a821c /sound/soc/codecs/uda134x.c
parenta6ba2b2dabb583e7820e567fb309d771b50cb9ff (diff)
ASoC: cleanup duplicated code.
Many codec drivers were implementing cookie-cutter copies of the function that adds kcontrols to the codec. This patch moves this code to a common function snd_soc_add_controls() in soc-core.c and updates all drivers using copies of this function to use the new common version. [Edited to raise priority of error log message and document parameters. -- broonie] Signed-off-by: Ian Molton <ian@mnementh.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/uda134x.c')
-rw-r--r--sound/soc/codecs/uda134x.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c
index a2c5064a774b..277825d155a6 100644
--- a/sound/soc/codecs/uda134x.c
+++ b/sound/soc/codecs/uda134x.c
@@ -431,39 +431,6 @@ SOC_ENUM("PCM Playback De-emphasis", uda134x_mixer_enum[1]),
431SOC_SINGLE("DC Filter Enable Switch", UDA134X_STATUS0, 0, 1, 0), 431SOC_SINGLE("DC Filter Enable Switch", UDA134X_STATUS0, 0, 1, 0),
432}; 432};
433 433
434static int uda134x_add_controls(struct snd_soc_codec *codec)
435{
436 int err, i, n;
437 const struct snd_kcontrol_new *ctrls;
438 struct uda134x_platform_data *pd = codec->control_data;
439
440 switch (pd->model) {
441 case UDA134X_UDA1340:
442 case UDA134X_UDA1344:
443 n = ARRAY_SIZE(uda1340_snd_controls);
444 ctrls = uda1340_snd_controls;
445 break;
446 case UDA134X_UDA1341:
447 n = ARRAY_SIZE(uda1341_snd_controls);
448 ctrls = uda1341_snd_controls;
449 break;
450 default:
451 printk(KERN_ERR "%s unkown codec type: %d",
452 __func__, pd->model);
453 return -EINVAL;
454 }
455
456 for (i = 0; i < n; i++) {
457 err = snd_ctl_add(codec->card,
458 snd_soc_cnew(&ctrls[i],
459 codec, NULL));
460 if (err < 0)
461 return err;
462 }
463
464 return 0;
465}
466
467struct snd_soc_dai uda134x_dai = { 434struct snd_soc_dai uda134x_dai = {
468 .name = "UDA134X", 435 .name = "UDA134X",
469 /* playback capabilities */ 436 /* playback capabilities */
@@ -572,7 +539,22 @@ static int uda134x_soc_probe(struct platform_device *pdev)
572 goto pcm_err; 539 goto pcm_err;
573 } 540 }
574 541
575 ret = uda134x_add_controls(codec); 542 switch (pd->model) {
543 case UDA134X_UDA1340:
544 case UDA134X_UDA1344:
545 ret = snd_soc_add_controls(codec, uda1340_snd_controls,
546 ARRAY_SIZE(uda1340_snd_controls));
547 break;
548 case UDA134X_UDA1341:
549 ret = snd_soc_add_controls(codec, uda1341_snd_controls,
550 ARRAY_SIZE(uda1341_snd_controls));
551 break;
552 default:
553 printk(KERN_ERR "%s unkown codec type: %d",
554 __func__, pd->model);
555 return -EINVAL;
556 }
557
576 if (ret < 0) { 558 if (ret < 0) {
577 printk(KERN_ERR "UDA134X: failed to register controls\n"); 559 printk(KERN_ERR "UDA134X: failed to register controls\n");
578 goto pcm_err; 560 goto pcm_err;