Commit 48ce3ec1 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'asoc/topic/devm' into asoc-next

parents cf44fba0 4fa8dbc1
...@@ -365,6 +365,7 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, ...@@ -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_register_card(struct snd_soc_card *card);
int snd_soc_unregister_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_suspend(struct device *dev);
int snd_soc_resume(struct device *dev); int snd_soc_resume(struct device *dev);
int snd_soc_poweroff(struct device *dev); int snd_soc_poweroff(struct device *dev);
...@@ -382,6 +383,9 @@ void snd_soc_unregister_codec(struct device *dev); ...@@ -382,6 +383,9 @@ void snd_soc_unregister_codec(struct device *dev);
int snd_soc_register_component(struct device *dev, int snd_soc_register_component(struct device *dev,
const struct snd_soc_component_driver *cmpnt_drv, const struct snd_soc_component_driver *cmpnt_drv,
struct snd_soc_dai_driver *dai_drv, int num_dai); 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); void snd_soc_unregister_component(struct device *dev);
int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
unsigned int reg); unsigned int reg);
......
snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o 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),) ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),)
snd-soc-core-objs += soc-generic-dmaengine-pcm.o snd-soc-core-objs += soc-generic-dmaengine-pcm.o
......
...@@ -1172,23 +1172,16 @@ static int fsl_spdif_probe(struct platform_device *pdev) ...@@ -1172,23 +1172,16 @@ static int fsl_spdif_probe(struct platform_device *pdev)
/* Register with ASoC */ /* Register with ASoC */
dev_set_drvdata(&pdev->dev, spdif_priv); dev_set_drvdata(&pdev->dev, spdif_priv);
ret = snd_soc_register_component(&pdev->dev, &fsl_spdif_component, ret = devm_snd_soc_register_component(&pdev->dev, &fsl_spdif_component,
&spdif_priv->cpu_dai_drv, 1); &spdif_priv->cpu_dai_drv, 1);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to register DAI: %d\n", ret); dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
return ret; return ret;
} }
ret = imx_pcm_dma_init(pdev); ret = imx_pcm_dma_init(pdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "imx_pcm_dma_init failed: %d\n", 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; return ret;
} }
...@@ -1196,7 +1189,6 @@ static int fsl_spdif_probe(struct platform_device *pdev) ...@@ -1196,7 +1189,6 @@ static int fsl_spdif_probe(struct platform_device *pdev)
static int fsl_spdif_remove(struct platform_device *pdev) static int fsl_spdif_remove(struct platform_device *pdev)
{ {
imx_pcm_dma_exit(pdev); imx_pcm_dma_exit(pdev);
snd_soc_unregister_component(&pdev->dev);
return 0; return 0;
} }
......
...@@ -159,7 +159,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) ...@@ -159,7 +159,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; data->card.dapm_widgets = imx_sgtl5000_dapm_widgets;
data->card.num_dapm_widgets = ARRAY_SIZE(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) { if (ret) {
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
goto fail; goto fail;
...@@ -186,7 +186,6 @@ static int imx_sgtl5000_remove(struct platform_device *pdev) ...@@ -186,7 +186,6 @@ static int imx_sgtl5000_remove(struct platform_device *pdev)
{ {
struct imx_sgtl5000_data *data = platform_get_drvdata(pdev); struct imx_sgtl5000_data *data = platform_get_drvdata(pdev);
snd_soc_unregister_card(&data->card);
clk_put(data->codec_clk); clk_put(data->codec_clk);
return 0; return 0;
......
...@@ -87,7 +87,7 @@ static int imx_spdif_audio_probe(struct platform_device *pdev) ...@@ -87,7 +87,7 @@ static int imx_spdif_audio_probe(struct platform_device *pdev)
if (ret) if (ret)
goto error_dir; goto error_dir;
ret = snd_soc_register_card(&data->card); ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
if (ret) { if (ret) {
dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret); dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret);
goto error_dir; goto error_dir;
...@@ -119,8 +119,6 @@ static int imx_spdif_audio_remove(struct platform_device *pdev) ...@@ -119,8 +119,6 @@ static int imx_spdif_audio_remove(struct platform_device *pdev)
if (data->txdev) if (data->txdev)
platform_device_unregister(data->txdev); platform_device_unregister(data->txdev);
snd_soc_unregister_card(&data->card);
return 0; return 0;
} }
......
...@@ -266,7 +266,7 @@ static int imx_wm8962_probe(struct platform_device *pdev) ...@@ -266,7 +266,7 @@ static int imx_wm8962_probe(struct platform_device *pdev)
data->card.late_probe = imx_wm8962_late_probe; data->card.late_probe = imx_wm8962_late_probe;
data->card.set_bias_level = imx_wm8962_set_bias_level; 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) { if (ret) {
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
goto clk_fail; goto clk_fail;
...@@ -296,7 +296,6 @@ static int imx_wm8962_remove(struct platform_device *pdev) ...@@ -296,7 +296,6 @@ static int imx_wm8962_remove(struct platform_device *pdev)
if (!IS_ERR(data->codec_clk)) if (!IS_ERR(data->codec_clk))
clk_disable_unprepare(data->codec_clk); clk_disable_unprepare(data->codec_clk);
snd_soc_unregister_card(&data->card);
return 0; return 0;
} }
......
...@@ -400,7 +400,7 @@ static int snd_mfld_mc_probe(struct platform_device *pdev) ...@@ -400,7 +400,7 @@ static int snd_mfld_mc_probe(struct platform_device *pdev)
} }
/* register the soc card */ /* register the soc card */
snd_soc_card_mfld.dev = &pdev->dev; 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) { if (ret_val) {
pr_debug("snd_soc_register_card failed %d\n", ret_val); pr_debug("snd_soc_register_card failed %d\n", ret_val);
return ret_val; return ret_val;
...@@ -410,20 +410,12 @@ static int snd_mfld_mc_probe(struct platform_device *pdev) ...@@ -410,20 +410,12 @@ static int snd_mfld_mc_probe(struct platform_device *pdev)
return 0; 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 = { static struct platform_driver snd_mfld_mc_driver = {
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "msic_audio", .name = "msic_audio",
}, },
.probe = snd_mfld_mc_probe, .probe = snd_mfld_mc_probe,
.remove = snd_mfld_mc_remove,
}; };
module_platform_driver(snd_mfld_mc_driver); module_platform_driver(snd_mfld_mc_driver);
......
...@@ -768,8 +768,8 @@ static int mxs_saif_probe(struct platform_device *pdev) ...@@ -768,8 +768,8 @@ static int mxs_saif_probe(struct platform_device *pdev)
dev_warn(&pdev->dev, "failed to init clocks\n"); dev_warn(&pdev->dev, "failed to init clocks\n");
} }
ret = snd_soc_register_component(&pdev->dev, &mxs_saif_component, ret = devm_snd_soc_register_component(&pdev->dev, &mxs_saif_component,
&mxs_saif_dai, 1); &mxs_saif_dai, 1);
if (ret) { if (ret) {
dev_err(&pdev->dev, "register DAI failed\n"); dev_err(&pdev->dev, "register DAI failed\n");
return ret; return ret;
...@@ -778,21 +778,15 @@ static int mxs_saif_probe(struct platform_device *pdev) ...@@ -778,21 +778,15 @@ static int mxs_saif_probe(struct platform_device *pdev)
ret = mxs_pcm_platform_register(&pdev->dev); ret = mxs_pcm_platform_register(&pdev->dev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "register PCM failed: %d\n", ret); dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
goto failed_pdev_alloc; return ret;
} }
return 0; return 0;
failed_pdev_alloc:
snd_soc_unregister_component(&pdev->dev);
return ret;
} }
static int mxs_saif_remove(struct platform_device *pdev) static int mxs_saif_remove(struct platform_device *pdev)
{ {
mxs_pcm_platform_unregister(&pdev->dev); mxs_pcm_platform_unregister(&pdev->dev);
snd_soc_unregister_component(&pdev->dev);
return 0; return 0;
} }
......
...@@ -490,14 +490,9 @@ static int asoc_mcpdm_probe(struct platform_device *pdev) ...@@ -490,14 +490,9 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
mcpdm->dev = &pdev->dev; mcpdm->dev = &pdev->dev;
return snd_soc_register_component(&pdev->dev, &omap_mcpdm_component, return devm_snd_soc_register_component(&pdev->dev,
&omap_mcpdm_dai, 1); &omap_mcpdm_component,
} &omap_mcpdm_dai, 1);
static int asoc_mcpdm_remove(struct platform_device *pdev)
{
snd_soc_unregister_component(&pdev->dev);
return 0;
} }
static const struct of_device_id omap_mcpdm_of_match[] = { static const struct of_device_id omap_mcpdm_of_match[] = {
...@@ -514,7 +509,6 @@ static struct platform_driver asoc_mcpdm_driver = { ...@@ -514,7 +509,6 @@ static struct platform_driver asoc_mcpdm_driver = {
}, },
.probe = asoc_mcpdm_probe, .probe = asoc_mcpdm_probe,
.remove = asoc_mcpdm_remove,
}; };
module_platform_driver(asoc_mcpdm_driver); module_platform_driver(asoc_mcpdm_driver);
......
...@@ -338,9 +338,9 @@ static int omap_twl4030_probe(struct platform_device *pdev) ...@@ -338,9 +338,9 @@ static int omap_twl4030_probe(struct platform_device *pdev)
} }
snd_soc_card_set_drvdata(card, priv); snd_soc_card_set_drvdata(card, priv);
ret = snd_soc_register_card(card); ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret) { 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); ret);
return ret; return ret;
} }
...@@ -357,7 +357,6 @@ static int omap_twl4030_remove(struct platform_device *pdev) ...@@ -357,7 +357,6 @@ static int omap_twl4030_remove(struct platform_device *pdev)
snd_soc_jack_free_gpios(&priv->hs_jack, snd_soc_jack_free_gpios(&priv->hs_jack,
ARRAY_SIZE(hs_jack_gpios), ARRAY_SIZE(hs_jack_gpios),
hs_jack_gpios); hs_jack_gpios);
snd_soc_unregister_card(card);
return 0; return 0;
} }
......
...@@ -455,8 +455,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) ...@@ -455,8 +455,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev)
priv->dai_fmt = (unsigned int) -1; priv->dai_fmt = (unsigned int) -1;
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
return snd_soc_register_component(&pdev->dev, &mmp_sspa_component, return devm_snd_soc_register_component(&pdev->dev, &mmp_sspa_component,
&mmp_sspa_dai, 1); &mmp_sspa_dai, 1);
} }
static int asoc_mmp_sspa_remove(struct platform_device *pdev) static int asoc_mmp_sspa_remove(struct platform_device *pdev)
...@@ -466,7 +466,6 @@ 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_disable(priv->audio_clk);
clk_put(priv->audio_clk); clk_put(priv->audio_clk);
clk_put(priv->sysclk); clk_put(priv->sysclk);
snd_soc_unregister_component(&pdev->dev);
return 0; return 0;
} }
......
/*
* 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);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment