diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-25 16:04:04 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-25 16:23:51 -0400 |
commit | 32c50a31aad77e8faf2718d149da13f2136c1b46 (patch) | |
tree | 981de5f0e88c8f8dae932a206cd0243d9461919a /sound | |
parent | bf9d323722845c8643287dca436e04e34cb21bb8 (diff) |
ASoC: wm0010: Move resource acquisition to device probe
This is more idimatic for modern drivers. Also fix a couple of return
codes while we're at it.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/wm0010.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index 30ec0bd85307..5f99148447e1 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c | |||
@@ -799,14 +799,35 @@ static irqreturn_t wm0010_irq(int irq, void *data) | |||
799 | static int wm0010_probe(struct snd_soc_codec *codec) | 799 | static int wm0010_probe(struct snd_soc_codec *codec) |
800 | { | 800 | { |
801 | struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); | 801 | struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); |
802 | struct spi_device *spi = to_spi_device(wm0010->dev); | 802 | |
803 | wm0010->codec = codec; | ||
804 | |||
805 | return 0; | ||
806 | } | ||
807 | |||
808 | static int __devinit wm0010_spi_probe(struct spi_device *spi) | ||
809 | { | ||
803 | unsigned long flags; | 810 | unsigned long flags; |
804 | unsigned long gpio_flags; | 811 | unsigned long gpio_flags; |
805 | int ret; | 812 | int ret; |
806 | int trigger; | 813 | int trigger; |
807 | int irq; | 814 | int irq; |
815 | struct wm0010_priv *wm0010; | ||
808 | 816 | ||
809 | wm0010->codec = codec; | 817 | wm0010 = devm_kzalloc(&spi->dev, sizeof(*wm0010), |
818 | GFP_KERNEL); | ||
819 | if (!wm0010) | ||
820 | return -ENOMEM; | ||
821 | |||
822 | mutex_init(&wm0010->lock); | ||
823 | spin_lock_init(&wm0010->irq_lock); | ||
824 | |||
825 | spi_set_drvdata(spi, wm0010); | ||
826 | wm0010->dev = &spi->dev; | ||
827 | |||
828 | if (dev_get_platdata(&spi->dev)) | ||
829 | memcpy(&wm0010->pdata, dev_get_platdata(&spi->dev), | ||
830 | sizeof(wm0010->pdata)); | ||
810 | 831 | ||
811 | init_completion(&wm0010->boot_completion); | 832 | init_completion(&wm0010->boot_completion); |
812 | 833 | ||
@@ -850,7 +871,7 @@ static int wm0010_probe(struct snd_soc_codec *codec) | |||
850 | } | 871 | } |
851 | } else { | 872 | } else { |
852 | dev_err(wm0010->dev, "No reset GPIO configured\n"); | 873 | dev_err(wm0010->dev, "No reset GPIO configured\n"); |
853 | return ret; | 874 | return -EINVAL; |
854 | } | 875 | } |
855 | 876 | ||
856 | irq = spi->irq; | 877 | irq = spi->irq; |
@@ -862,9 +883,11 @@ static int wm0010_probe(struct snd_soc_codec *codec) | |||
862 | 883 | ||
863 | ret = request_threaded_irq(irq, NULL, wm0010_irq, trigger, | 884 | ret = request_threaded_irq(irq, NULL, wm0010_irq, trigger, |
864 | "wm0010", wm0010); | 885 | "wm0010", wm0010); |
865 | if (ret) | 886 | if (ret) { |
866 | dev_err(wm0010->dev, "Failed to request IRQ %d: %d\n", | 887 | dev_err(wm0010->dev, "Failed to request IRQ %d: %d\n", |
867 | irq, ret); | 888 | irq, ret); |
889 | return ret; | ||
890 | } | ||
868 | wm0010->irq = irq; | 891 | wm0010->irq = irq; |
869 | 892 | ||
870 | if (spi->max_speed_hz) | 893 | if (spi->max_speed_hz) |
@@ -876,29 +899,6 @@ static int wm0010_probe(struct snd_soc_codec *codec) | |||
876 | wm0010->state = WM0010_POWER_OFF; | 899 | wm0010->state = WM0010_POWER_OFF; |
877 | spin_unlock_irqrestore(&wm0010->irq_lock, flags); | 900 | spin_unlock_irqrestore(&wm0010->irq_lock, flags); |
878 | 901 | ||
879 | return 0; | ||
880 | } | ||
881 | |||
882 | static int __devinit wm0010_spi_probe(struct spi_device *spi) | ||
883 | { | ||
884 | struct wm0010_priv *wm0010; | ||
885 | int ret; | ||
886 | |||
887 | wm0010 = devm_kzalloc(&spi->dev, sizeof(*wm0010), | ||
888 | GFP_KERNEL); | ||
889 | if (!wm0010) | ||
890 | return -ENOMEM; | ||
891 | |||
892 | mutex_init(&wm0010->lock); | ||
893 | spin_lock_init(&wm0010->irq_lock); | ||
894 | |||
895 | spi_set_drvdata(spi, wm0010); | ||
896 | wm0010->dev = &spi->dev; | ||
897 | |||
898 | if (dev_get_platdata(&spi->dev)) | ||
899 | memcpy(&wm0010->pdata, dev_get_platdata(&spi->dev), | ||
900 | sizeof(wm0010->pdata)); | ||
901 | |||
902 | ret = snd_soc_register_codec(&spi->dev, | 902 | ret = snd_soc_register_codec(&spi->dev, |
903 | &soc_codec_dev_wm0010, wm0010_dai, | 903 | &soc_codec_dev_wm0010, wm0010_dai, |
904 | ARRAY_SIZE(wm0010_dai)); | 904 | ARRAY_SIZE(wm0010_dai)); |