aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/uda134x.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2015-07-13 06:26:45 -0400
committerMark Brown <broonie@kernel.org>2015-07-13 06:51:35 -0400
commitf15c444e58ed5b5dfc6056249ef8a74d00118be3 (patch)
treed15a5faa265a692ed61caad1a0de61fdc7884162 /sound/soc/codecs/uda134x.c
parentd770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff)
ASoC: uda134x: Move state struct allocation to bus probe
Resource allocations should be done in the bus probe rather than the CODEC probe. Move the allocation of the drivers state struct there. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/uda134x.c')
-rw-r--r--sound/soc/codecs/uda134x.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c
index 913edf283239..a89f98a773d6 100644
--- a/sound/soc/codecs/uda134x.c
+++ b/sound/soc/codecs/uda134x.c
@@ -478,8 +478,8 @@ static struct snd_soc_dai_driver uda134x_dai = {
478static int uda134x_soc_probe(struct snd_soc_codec *codec) 478static int uda134x_soc_probe(struct snd_soc_codec *codec)
479{ 479{
480 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); 480 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
481 struct uda134x_priv *uda134x;
482 struct uda134x_platform_data *pd = codec->component.card->dev->platform_data; 481 struct uda134x_platform_data *pd = codec->component.card->dev->platform_data;
482 struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
483 const struct snd_soc_dapm_widget *widgets; 483 const struct snd_soc_dapm_widget *widgets;
484 unsigned num_widgets; 484 unsigned num_widgets;
485 485
@@ -506,10 +506,6 @@ static int uda134x_soc_probe(struct snd_soc_codec *codec)
506 return -EINVAL; 506 return -EINVAL;
507 } 507 }
508 508
509 uda134x = kzalloc(sizeof(struct uda134x_priv), GFP_KERNEL);
510 if (uda134x == NULL)
511 return -ENOMEM;
512 snd_soc_codec_set_drvdata(codec, uda134x);
513 509
514 codec->control_data = pd; 510 codec->control_data = pd;
515 511
@@ -530,7 +526,6 @@ static int uda134x_soc_probe(struct snd_soc_codec *codec)
530 if (ret) { 526 if (ret) {
531 printk(KERN_ERR "%s failed to register dapm controls: %d", 527 printk(KERN_ERR "%s failed to register dapm controls: %d",
532 __func__, ret); 528 __func__, ret);
533 kfree(uda134x);
534 return ret; 529 return ret;
535 } 530 }
536 531
@@ -551,31 +546,19 @@ static int uda134x_soc_probe(struct snd_soc_codec *codec)
551 default: 546 default:
552 printk(KERN_ERR "%s unknown codec type: %d", 547 printk(KERN_ERR "%s unknown codec type: %d",
553 __func__, pd->model); 548 __func__, pd->model);
554 kfree(uda134x);
555 return -EINVAL; 549 return -EINVAL;
556 } 550 }
557 551
558 if (ret < 0) { 552 if (ret < 0) {
559 printk(KERN_ERR "UDA134X: failed to register controls\n"); 553 printk(KERN_ERR "UDA134X: failed to register controls\n");
560 kfree(uda134x);
561 return ret; 554 return ret;
562 } 555 }
563 556
564 return 0; 557 return 0;
565} 558}
566 559
567/* power down chip */
568static int uda134x_soc_remove(struct snd_soc_codec *codec)
569{
570 struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
571
572 kfree(uda134x);
573 return 0;
574}
575
576static struct snd_soc_codec_driver soc_codec_dev_uda134x = { 560static struct snd_soc_codec_driver soc_codec_dev_uda134x = {
577 .probe = uda134x_soc_probe, 561 .probe = uda134x_soc_probe,
578 .remove = uda134x_soc_remove,
579 .reg_cache_size = sizeof(uda134x_reg), 562 .reg_cache_size = sizeof(uda134x_reg),
580 .reg_word_size = sizeof(u8), 563 .reg_word_size = sizeof(u8),
581 .reg_cache_default = uda134x_reg, 564 .reg_cache_default = uda134x_reg,
@@ -592,6 +575,14 @@ static struct snd_soc_codec_driver soc_codec_dev_uda134x = {
592 575
593static int uda134x_codec_probe(struct platform_device *pdev) 576static int uda134x_codec_probe(struct platform_device *pdev)
594{ 577{
578 struct uda134x_priv *uda134x;
579
580 uda134x = devm_kzalloc(&pdev->dev, sizeof(*uda134x), GFP_KERNEL);
581 if (!uda134x)
582 return -ENOMEM;
583
584 platform_set_drvdata(pdev, uda134x);
585
595 return snd_soc_register_codec(&pdev->dev, 586 return snd_soc_register_codec(&pdev->dev,
596 &soc_codec_dev_uda134x, &uda134x_dai, 1); 587 &soc_codec_dev_uda134x, &uda134x_dai, 1);
597} 588}