]> Pileus Git - ~andy/linux/commitdiff
Merge remote-tracking branch 'asoc/topic/devm' into asoc-next
authorMark Brown <broonie@linaro.org>
Fri, 8 Nov 2013 10:43:27 +0000 (10:43 +0000)
committerMark Brown <broonie@linaro.org>
Fri, 8 Nov 2013 10:43:27 +0000 (10:43 +0000)
12 files changed:
include/sound/soc.h
sound/soc/Makefile
sound/soc/fsl/fsl_spdif.c
sound/soc/fsl/imx-sgtl5000.c
sound/soc/fsl/imx-spdif.c
sound/soc/fsl/imx-wm8962.c
sound/soc/mid-x86/mfld_machine.c
sound/soc/mxs/mxs-saif.c
sound/soc/omap/omap-mcpdm.c
sound/soc/omap/omap-twl4030.c
sound/soc/pxa/mmp-sspa.c
sound/soc/soc-devres.c [new file with mode: 0644]

index 6ed3dc0773cc74a4912f4e7637ea4d1d74b629e1..fbea72f9cc661212aa68f4a9a02a1cb6eeaaf982 100644 (file)
@@ -365,6 +365,7 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
 
 int snd_soc_register_card(struct snd_soc_card *card);
 int snd_soc_unregister_card(struct snd_soc_card *card);
+int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
 int snd_soc_suspend(struct device *dev);
 int snd_soc_resume(struct device *dev);
 int snd_soc_poweroff(struct device *dev);
@@ -382,6 +383,9 @@ void snd_soc_unregister_codec(struct device *dev);
 int snd_soc_register_component(struct device *dev,
                         const struct snd_soc_component_driver *cmpnt_drv,
                         struct snd_soc_dai_driver *dai_drv, int num_dai);
+int devm_snd_soc_register_component(struct device *dev,
+                        const struct snd_soc_component_driver *cmpnt_drv,
+                        struct snd_soc_dai_driver *dai_drv, int num_dai);
 void snd_soc_unregister_component(struct device *dev);
 int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
                                    unsigned int reg);
index 61a64d281905e4b8997bc2ae3eb42ce387de9e7c..8b9e70105dd28f5ccceabad1cd2ea414a97640a1 100644 (file)
@@ -1,5 +1,5 @@
 snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o
-snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o
+snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o
 
 ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),)
 snd-soc-core-objs += soc-generic-dmaengine-pcm.o
index 3920c3e849ce4dfd6b76f77d877363243d8234d5..44378e6e269679ee542df17638496e3c286ebc6f 100644 (file)
@@ -1172,23 +1172,16 @@ static int fsl_spdif_probe(struct platform_device *pdev)
        /* Register with ASoC */
        dev_set_drvdata(&pdev->dev, spdif_priv);
 
-       ret = snd_soc_register_component(&pdev->dev, &fsl_spdif_component,
-                                        &spdif_priv->cpu_dai_drv, 1);
+       ret = devm_snd_soc_register_component(&pdev->dev, &fsl_spdif_component,
+                                             &spdif_priv->cpu_dai_drv, 1);
        if (ret) {
                dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
                return ret;
        }
 
        ret = imx_pcm_dma_init(pdev);
-       if (ret) {
+       if (ret)
                dev_err(&pdev->dev, "imx_pcm_dma_init failed: %d\n", ret);
-               goto error_component;
-       }
-
-       return ret;
-
-error_component:
-       snd_soc_unregister_component(&pdev->dev);
 
        return ret;
 }
@@ -1196,7 +1189,6 @@ error_component:
 static int fsl_spdif_remove(struct platform_device *pdev)
 {
        imx_pcm_dma_exit(pdev);
-       snd_soc_unregister_component(&pdev->dev);
 
        return 0;
 }
index ca1be1d9dcf0349b608f77367f5330ca7c2c6308..ed6ba1eba557f5b826f3b8abc4f51f25ab81d7df 100644 (file)
@@ -159,7 +159,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
        data->card.dapm_widgets = imx_sgtl5000_dapm_widgets;
        data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets);
 
-       ret = snd_soc_register_card(&data->card);
+       ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
        if (ret) {
                dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
                goto fail;
@@ -186,7 +186,6 @@ static int imx_sgtl5000_remove(struct platform_device *pdev)
 {
        struct imx_sgtl5000_data *data = platform_get_drvdata(pdev);
 
-       snd_soc_unregister_card(&data->card);
        clk_put(data->codec_clk);
 
        return 0;
index 816013b0ebba4f0b16e3fdfddd0e763833d1ee39..8499d5292f088a45e9ea736106ee2db13e7d205a 100644 (file)
@@ -87,7 +87,7 @@ static int imx_spdif_audio_probe(struct platform_device *pdev)
        if (ret)
                goto error_dir;
 
-       ret = snd_soc_register_card(&data->card);
+       ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
        if (ret) {
                dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret);
                goto error_dir;
@@ -119,8 +119,6 @@ static int imx_spdif_audio_remove(struct platform_device *pdev)
        if (data->txdev)
                platform_device_unregister(data->txdev);
 
-       snd_soc_unregister_card(&data->card);
-
        return 0;
 }
 
index 722afe69169e904798974115292159a89a08ba18..6c6066618f3bba119f32480ef59e9253be2834b5 100644 (file)
@@ -266,7 +266,7 @@ static int imx_wm8962_probe(struct platform_device *pdev)
        data->card.late_probe = imx_wm8962_late_probe;
        data->card.set_bias_level = imx_wm8962_set_bias_level;
 
-       ret = snd_soc_register_card(&data->card);
+       ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
        if (ret) {
                dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
                goto clk_fail;
@@ -296,7 +296,6 @@ static int imx_wm8962_remove(struct platform_device *pdev)
 
        if (!IS_ERR(data->codec_clk))
                clk_disable_unprepare(data->codec_clk);
-       snd_soc_unregister_card(&data->card);
 
        return 0;
 }
index ee363845759eca555346193ce17d740868d5fd6d..d3d4c32434f7614d944296b34b9b87f6c80a66b3 100644 (file)
@@ -400,7 +400,7 @@ static int snd_mfld_mc_probe(struct platform_device *pdev)
        }
        /* register the soc card */
        snd_soc_card_mfld.dev = &pdev->dev;
-       ret_val = snd_soc_register_card(&snd_soc_card_mfld);
+       ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_mfld);
        if (ret_val) {
                pr_debug("snd_soc_register_card failed %d\n", ret_val);
                return ret_val;
@@ -410,20 +410,12 @@ static int snd_mfld_mc_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int snd_mfld_mc_remove(struct platform_device *pdev)
-{
-       pr_debug("snd_mfld_mc_remove called\n");
-       snd_soc_unregister_card(&snd_soc_card_mfld);
-       return 0;
-}
-
 static struct platform_driver snd_mfld_mc_driver = {
        .driver = {
                .owner = THIS_MODULE,
                .name = "msic_audio",
        },
        .probe = snd_mfld_mc_probe,
-       .remove = snd_mfld_mc_remove,
 };
 
 module_platform_driver(snd_mfld_mc_driver);
index b56b8a0e8deb43b6fdca0668fb43677bb1ce47ba..14152f6f70ddccaada89a26176c6b9437e814b06 100644 (file)
@@ -768,8 +768,8 @@ static int mxs_saif_probe(struct platform_device *pdev)
                        dev_warn(&pdev->dev, "failed to init clocks\n");
        }
 
-       ret = snd_soc_register_component(&pdev->dev, &mxs_saif_component,
-                                        &mxs_saif_dai, 1);
+       ret = devm_snd_soc_register_component(&pdev->dev, &mxs_saif_component,
+                                             &mxs_saif_dai, 1);
        if (ret) {
                dev_err(&pdev->dev, "register DAI failed\n");
                return ret;
@@ -778,21 +778,15 @@ static int mxs_saif_probe(struct platform_device *pdev)
        ret = mxs_pcm_platform_register(&pdev->dev);
        if (ret) {
                dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
-               goto failed_pdev_alloc;
+               return ret;
        }
 
        return 0;
-
-failed_pdev_alloc:
-       snd_soc_unregister_component(&pdev->dev);
-
-       return ret;
 }
 
 static int mxs_saif_remove(struct platform_device *pdev)
 {
        mxs_pcm_platform_unregister(&pdev->dev);
-       snd_soc_unregister_component(&pdev->dev);
 
        return 0;
 }
index 90d2a7cd2563d06170d450b5bb6a9cc8a6615210..cd9ee167959dcc0b34512ffdf32d26208d506c31 100644 (file)
@@ -490,14 +490,9 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
 
        mcpdm->dev = &pdev->dev;
 
-       return snd_soc_register_component(&pdev->dev, &omap_mcpdm_component,
-                                         &omap_mcpdm_dai, 1);
-}
-
-static int asoc_mcpdm_remove(struct platform_device *pdev)
-{
-       snd_soc_unregister_component(&pdev->dev);
-       return 0;
+       return devm_snd_soc_register_component(&pdev->dev,
+                                              &omap_mcpdm_component,
+                                              &omap_mcpdm_dai, 1);
 }
 
 static const struct of_device_id omap_mcpdm_of_match[] = {
@@ -514,7 +509,6 @@ static struct platform_driver asoc_mcpdm_driver = {
        },
 
        .probe  = asoc_mcpdm_probe,
-       .remove = asoc_mcpdm_remove,
 };
 
 module_platform_driver(asoc_mcpdm_driver);
index 2a9324f794d8468172637ff07d28537a4a4cdd11..6a8d6b5f160debac623f79ad72b91dd5c77b1550 100644 (file)
@@ -338,9 +338,9 @@ static int omap_twl4030_probe(struct platform_device *pdev)
        }
 
        snd_soc_card_set_drvdata(card, priv);
-       ret = snd_soc_register_card(card);
+       ret = devm_snd_soc_register_card(&pdev->dev, card);
        if (ret) {
-               dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
+               dev_err(&pdev->dev, "devm_snd_soc_register_card() failed: %d\n",
                        ret);
                return ret;
        }
@@ -357,7 +357,6 @@ static int omap_twl4030_remove(struct platform_device *pdev)
                snd_soc_jack_free_gpios(&priv->hs_jack,
                                        ARRAY_SIZE(hs_jack_gpios),
                                        hs_jack_gpios);
-       snd_soc_unregister_card(card);
 
        return 0;
 }
index 41752a5fe3b07148c5402b2ea66d6f292fdc3133..5bf5f1f7cac5013f461657e0487687ce597a485b 100644 (file)
@@ -455,8 +455,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev)
        priv->dai_fmt = (unsigned int) -1;
        platform_set_drvdata(pdev, priv);
 
-       return snd_soc_register_component(&pdev->dev, &mmp_sspa_component,
-                                         &mmp_sspa_dai, 1);
+       return devm_snd_soc_register_component(&pdev->dev, &mmp_sspa_component,
+                                              &mmp_sspa_dai, 1);
 }
 
 static int asoc_mmp_sspa_remove(struct platform_device *pdev)
@@ -466,7 +466,6 @@ static int asoc_mmp_sspa_remove(struct platform_device *pdev)
        clk_disable(priv->audio_clk);
        clk_put(priv->audio_clk);
        clk_put(priv->sysclk);
-       snd_soc_unregister_component(&pdev->dev);
        return 0;
 }
 
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
new file mode 100644 (file)
index 0000000..b1d7322
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * soc-devres.c  --  ALSA SoC Audio Layer devres functions
+ *
+ * Copyright (C) 2013 Linaro Ltd
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <sound/soc.h>
+
+static void devm_component_release(struct device *dev, void *res)
+{
+       snd_soc_unregister_component(*(struct device **)res);
+}
+
+/**
+ * devm_snd_soc_register_component - resource managed component registration
+ * @dev: Device used to manage component
+ * @cmpnt_drv: Component driver
+ * @dai_drv: DAI driver
+ * @num_dai: Number of DAIs to register
+ *
+ * Register a component with automatic unregistration when the device is
+ * unregistered.
+ */
+int devm_snd_soc_register_component(struct device *dev,
+                        const struct snd_soc_component_driver *cmpnt_drv,
+                        struct snd_soc_dai_driver *dai_drv, int num_dai)
+{
+       struct device **ptr;
+       int ret;
+
+       ptr = devres_alloc(devm_component_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return -ENOMEM;
+
+       ret = snd_soc_register_component(dev, cmpnt_drv, dai_drv, num_dai);
+       if (ret == 0) {
+               *ptr = dev;
+               devres_add(dev, ptr);
+       } else {
+               devres_free(ptr);
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
+
+static void devm_card_release(struct device *dev, void *res)
+{
+       snd_soc_unregister_card(*(struct snd_soc_card **)res);
+}
+
+/**
+ * devm_snd_soc_register_card - resource managed card registration
+ * @dev: Device used to manage card
+ * @card: Card to register
+ *
+ * Register a card with automatic unregistration when the device is
+ * unregistered.
+ */
+int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
+{
+       struct device **ptr;
+       int ret;
+
+       ptr = devres_alloc(devm_card_release, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return -ENOMEM;
+
+       ret = snd_soc_register_card(card);
+       if (ret == 0) {
+               *ptr = dev;
+               devres_add(dev, ptr);
+       } else {
+               devres_free(ptr);
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(devm_snd_soc_register_card);