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