aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/wm8731.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index a32caa72bd7d..9d1b9b0271f1 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -635,16 +635,17 @@ static int __devinit wm8731_spi_probe(struct spi_device *spi)
635 struct wm8731_priv *wm8731; 635 struct wm8731_priv *wm8731;
636 int ret; 636 int ret;
637 637
638 wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL); 638 wm8731 = devm_kzalloc(&spi->dev, sizeof(struct wm8731_priv),
639 GFP_KERNEL);
639 if (wm8731 == NULL) 640 if (wm8731 == NULL)
640 return -ENOMEM; 641 return -ENOMEM;
641 642
642 wm8731->regmap = regmap_init_spi(spi, &wm8731_regmap); 643 wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap);
643 if (IS_ERR(wm8731->regmap)) { 644 if (IS_ERR(wm8731->regmap)) {
644 ret = PTR_ERR(wm8731->regmap); 645 ret = PTR_ERR(wm8731->regmap);
645 dev_err(&spi->dev, "Failed to allocate register map: %d\n", 646 dev_err(&spi->dev, "Failed to allocate register map: %d\n",
646 ret); 647 ret);
647 goto err; 648 return ret;
648 } 649 }
649 650
650 spi_set_drvdata(spi, wm8731); 651 spi_set_drvdata(spi, wm8731);
@@ -653,25 +654,15 @@ static int __devinit wm8731_spi_probe(struct spi_device *spi)
653 &soc_codec_dev_wm8731, &wm8731_dai, 1); 654 &soc_codec_dev_wm8731, &wm8731_dai, 1);
654 if (ret != 0) { 655 if (ret != 0) {
655 dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret); 656 dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret);
656 goto err_regmap; 657 return ret;
657 } 658 }
658 659
659 return 0; 660 return 0;
660
661err_regmap:
662 regmap_exit(wm8731->regmap);
663err:
664 kfree(wm8731);
665 return ret;
666} 661}
667 662
668static int __devexit wm8731_spi_remove(struct spi_device *spi) 663static int __devexit wm8731_spi_remove(struct spi_device *spi)
669{ 664{
670 struct wm8731_priv *wm8731 = spi_get_drvdata(spi);
671
672 snd_soc_unregister_codec(&spi->dev); 665 snd_soc_unregister_codec(&spi->dev);
673 regmap_exit(wm8731->regmap);
674 kfree(wm8731);
675 return 0; 666 return 0;
676} 667}
677 668
@@ -693,16 +684,17 @@ static __devinit int wm8731_i2c_probe(struct i2c_client *i2c,
693 struct wm8731_priv *wm8731; 684 struct wm8731_priv *wm8731;
694 int ret; 685 int ret;
695 686
696 wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL); 687 wm8731 = devm_kzalloc(&i2c->dev, sizeof(struct wm8731_priv),
688 GFP_KERNEL);
697 if (wm8731 == NULL) 689 if (wm8731 == NULL)
698 return -ENOMEM; 690 return -ENOMEM;
699 691
700 wm8731->regmap = regmap_init_i2c(i2c, &wm8731_regmap); 692 wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap);
701 if (IS_ERR(wm8731->regmap)) { 693 if (IS_ERR(wm8731->regmap)) {
702 ret = PTR_ERR(wm8731->regmap); 694 ret = PTR_ERR(wm8731->regmap);
703 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 695 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
704 ret); 696 ret);
705 goto err; 697 return ret;
706 } 698 }
707 699
708 i2c_set_clientdata(i2c, wm8731); 700 i2c_set_clientdata(i2c, wm8731);
@@ -711,24 +703,15 @@ static __devinit int wm8731_i2c_probe(struct i2c_client *i2c,
711 &soc_codec_dev_wm8731, &wm8731_dai, 1); 703 &soc_codec_dev_wm8731, &wm8731_dai, 1);
712 if (ret != 0) { 704 if (ret != 0) {
713 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); 705 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
714 goto err_regmap; 706 return ret;
715 } 707 }
716 708
717 return 0; 709 return 0;
718
719err_regmap:
720 regmap_exit(wm8731->regmap);
721err:
722 kfree(wm8731);
723 return ret;
724} 710}
725 711
726static __devexit int wm8731_i2c_remove(struct i2c_client *client) 712static __devexit int wm8731_i2c_remove(struct i2c_client *client)
727{ 713{
728 struct wm8731_priv *wm8731 = i2c_get_clientdata(client);
729 snd_soc_unregister_codec(&client->dev); 714 snd_soc_unregister_codec(&client->dev);
730 regmap_exit(wm8731->regmap);
731 kfree(wm8731);
732 return 0; 715 return 0;
733} 716}
734 717