From f790b94d7867fb0555f91ae920b9001b42ae38a6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 25 Feb 2013 00:40:09 -0800 Subject: ASoC: core: tidyup snd_soc_register_codec() fail case kfree() on snd_soc_register_codec() was summarized to one place. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b7e84a7..a872be1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4022,8 +4022,8 @@ int snd_soc_register_codec(struct device *dev, /* create CODEC component name */ codec->name = fmt_single_name(dev, &codec->id); if (codec->name == NULL) { - kfree(codec); - return -ENOMEM; + ret = -ENOMEM; + goto fail_codec; } if (codec_drv->compress_type) @@ -4062,7 +4062,7 @@ int snd_soc_register_codec(struct device *dev, reg_size, GFP_KERNEL); if (!codec->reg_def_copy) { ret = -ENOMEM; - goto fail; + goto fail_codec_name; } } } @@ -4096,8 +4096,9 @@ int snd_soc_register_codec(struct device *dev, dev_dbg(codec->dev, "ASoC: Registered codec '%s'\n", codec->name); return 0; -fail: +fail_codec_name: kfree(codec->name); +fail_codec: kfree(codec); return ret; } -- cgit v0.10.2 From 5acd7dfbd7851446fb1d2c947661d365e4c635a0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 25 Feb 2013 00:40:40 -0800 Subject: ASoC: core: use snd_soc_register_dais() on codec snd_soc_register_dais() considers dai counts inside. snd_soc_register_codec() does not need to care for it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a872be1..e02c374 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4086,11 +4086,10 @@ int snd_soc_register_codec(struct device *dev, mutex_unlock(&client_mutex); /* register any DAIs */ - if (num_dai) { - ret = snd_soc_register_dais(dev, dai_drv, num_dai); - if (ret < 0) - dev_err(codec->dev, "ASoC: Failed to regster" - " DAIs: %d\n", ret); + ret = snd_soc_register_dais(dev, dai_drv, num_dai); + if (ret < 0) { + dev_err(codec->dev, "ASoC: Failed to regster DAIs: %d\n", ret); + goto fail_codec_name; } dev_dbg(codec->dev, "ASoC: Registered codec '%s'\n", codec->name); @@ -4112,7 +4111,6 @@ EXPORT_SYMBOL_GPL(snd_soc_register_codec); void snd_soc_unregister_codec(struct device *dev) { struct snd_soc_codec *codec; - int i; list_for_each_entry(codec, &codec_list, list) { if (dev == codec->dev) @@ -4121,9 +4119,7 @@ void snd_soc_unregister_codec(struct device *dev) return; found: - if (codec->num_dai) - for (i = 0; i < codec->num_dai; i++) - snd_soc_unregister_dai(dev); + snd_soc_unregister_dais(dev, codec->num_dai); mutex_lock(&client_mutex); list_del(&codec->list); -- cgit v0.10.2 From e383c467ceeee3b040444d6dcd27f331d72b1426 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 8 Mar 2013 13:44:26 +0100 Subject: ASoC: core: Drop unused "dapm" field form soc_enum struct This field was added in commit 2e72f8e ("ASoC: New enum type: value_enum"), but has never been used since. Considering that the soc_enum struct is usually shared between all instances of a CODEC, it also doesn't make much sense to have a pointer to DAPM specific data in it. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown diff --git a/include/sound/soc.h b/include/sound/soc.h index a6a059c..c84062b 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1086,7 +1086,6 @@ struct soc_enum { unsigned int mask; const char * const *texts; const unsigned int *values; - void *dapm; }; /* codec IO */ -- cgit v0.10.2 From a93f8e76a446e0a146a169cc2cc82bf1e145ad35 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 8 Mar 2013 13:44:27 +0100 Subject: ASoC: core: Remove unused "n_widgets" field from snd_soc_dapm struct Commit 497098be ("ASoC: dapm: Remove bodges for no-widget CODECs") removed the last user of the n_widgets field. Currently it is incremented for each widget added, but the value is never used, so we can remove it. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index e1ef63d..d4c0049 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -565,7 +565,6 @@ struct snd_soc_dapm_update { /* DAPM context */ struct snd_soc_dapm_context { - int n_widgets; /* number of widgets in this context */ enum snd_soc_bias_level bias_level; enum snd_soc_bias_level suspend_bias_level; struct delayed_work delayed_work; diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 1d6a9b3..625d482 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3123,7 +3123,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, break; } - dapm->n_widgets++; w->dapm = dapm; w->codec = dapm->codec; w->platform = dapm->platform; -- cgit v0.10.2 From e1328a832c7eeeb4dd3c3666605717c555de9e83 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 7 Mar 2013 17:42:33 -0800 Subject: ASoC: core: remove codec from list if registration failed Current snd_soc_register_codec() adds codec to list, and calls snd_soc_register_dais(). But, this listed codec should be removed if dais registration was failed. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e02c374..0ce075c 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4096,6 +4096,10 @@ int snd_soc_register_codec(struct device *dev, return 0; fail_codec_name: + mutex_lock(&client_mutex); + list_del(&codec->list); + mutex_unlock(&client_mutex); + kfree(codec->name); fail_codec: kfree(codec); -- cgit v0.10.2 From 36300fd09823be8f7d6feaaa79ddbf54cf205378 Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghiu Date: Mon, 25 Mar 2013 16:33:59 +0200 Subject: ASoC: core: Use PTR_RET function Used PTR_RET function instead of IS_ERR and PTR_ERR. Patch found using coccinelle. Signed-off-by: Alexandru Gheorghiu Signed-off-by: Mark Brown diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 29183ef..8ca9ecc 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -158,10 +158,7 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, return -EINVAL; } - if (IS_ERR(codec->control_data)) - return PTR_ERR(codec->control_data); - - return 0; + return PTR_RET(codec->control_data); } EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io); #else -- cgit v0.10.2 From d79e57db84f8359bc96418900f86b8fc4189eff9 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 27 Mar 2013 12:02:22 +0100 Subject: ASoC: Constify the 'driver' field of snd_soc_platform The ASoC core does no not modify the driver of a platform. Making it const allows ASoC platform drivers to declare the snd_soc_platform_driver struct as const. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown diff --git a/include/sound/soc.h b/include/sound/soc.h index c84062b..5fb70d1 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -371,7 +371,7 @@ int snd_soc_suspend(struct device *dev); int snd_soc_resume(struct device *dev); int snd_soc_poweroff(struct device *dev); int snd_soc_register_platform(struct device *dev, - struct snd_soc_platform_driver *platform_drv); + const struct snd_soc_platform_driver *platform_drv); void snd_soc_unregister_platform(struct device *dev); int snd_soc_register_codec(struct device *dev, const struct snd_soc_codec_driver *codec_drv, @@ -823,7 +823,7 @@ struct snd_soc_platform { const char *name; int id; struct device *dev; - struct snd_soc_platform_driver *driver; + const struct snd_soc_platform_driver *driver; struct mutex mutex; unsigned int suspended:1; /* platform is suspended */ diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0ce075c..4d24b5e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3906,7 +3906,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dais); * @platform: platform to register */ int snd_soc_register_platform(struct device *dev, - struct snd_soc_platform_driver *platform_drv) + const struct snd_soc_platform_driver *platform_drv) { struct snd_soc_platform *platform; -- cgit v0.10.2 From 1f03f55b0ca679f950148954e807feb22cff325c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 27 Mar 2013 12:02:23 +0100 Subject: ASoC: Constify the 'ops' field of snd_soc_platform_driver The ASoC core does not modify a platform driver's ops structure. Making it const allows ASoC platform drivers to declare their snd_pcm_ops struct as const. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown diff --git a/include/sound/soc.h b/include/sound/soc.h index 5fb70d1..966a854 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -801,7 +801,7 @@ struct snd_soc_platform_driver { struct snd_soc_dai *); /* platform stream pcm ops */ - struct snd_pcm_ops *ops; + const struct snd_pcm_ops *ops; /* platform stream compress ops */ struct snd_compr_ops *compr_ops; -- cgit v0.10.2 From ef03c9ae967bf1b40bec1456f7e744033853a01d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 27 Mar 2013 12:02:24 +0100 Subject: ASoC: Constify the 'compr_ops' field of snd_soc_platform_driver The ASoC core does not modify a platform driver's compr_ops structure. Making it const allows ASoC platform drivers to declare their snd_compr_ops struct as const. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown diff --git a/include/sound/soc.h b/include/sound/soc.h index 966a854..f619905 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -804,7 +804,7 @@ struct snd_soc_platform_driver { const struct snd_pcm_ops *ops; /* platform stream compress ops */ - struct snd_compr_ops *compr_ops; + const struct snd_compr_ops *compr_ops; /* platform stream completion event */ int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); -- cgit v0.10.2 From 379cf39781fdb34c75bab6ac54707bc4466f3dc4 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Tue, 12 Mar 2013 21:08:38 +0100 Subject: ASoC: codecs: remove hidden prompt The Kconfig symbol SND_SOC_OF_SIMPLE got removed in commit f0fba2ad1b6b53d5360125c41953b7afcd6deff0 ("ASoC: multi-component - ASoC Multi-Component Support"). But that commit missed one instance. Remove it now, together with the prompt it has effectively hidden ever since. Signed-off-by: Paul Bolle Signed-off-by: Mark Brown diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 45b7256..350b864 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -324,7 +324,7 @@ config SND_SOC_TLV320AIC23 tristate config SND_SOC_TLV320AIC26 - tristate "TI TLV320AIC26 Codec support" if SND_SOC_OF_SIMPLE + tristate depends on SPI config SND_SOC_TLV320AIC32X4 -- cgit v0.10.2 From 60b6f1a1e578a5f8a245d4b7622ebf2bad7798cb Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Wed, 17 Apr 2013 16:34:06 +0400 Subject: ASoC: define playback and capture streams in dummy codec This patch adds a playback and capture streams to the dummy codec DAI configuration. Most permissive set of sampling rates and formats is used. This patch is needed for playback and capturing on a codec-less systems, as otherwise the PCM device nodes are not even created. Signed-off-by: Stas Sergeev Signed-off-by: Mark Brown diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index fe4541d..4b3be6c 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -90,8 +90,33 @@ static struct snd_soc_platform_driver dummy_platform = { }; static struct snd_soc_codec_driver dummy_codec; + +#define STUB_RATES SNDRV_PCM_RATE_8000_192000 +#define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ + SNDRV_PCM_FMTBIT_U8 | \ + SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_U16_LE | \ + SNDRV_PCM_FMTBIT_S24_LE | \ + SNDRV_PCM_FMTBIT_U24_LE | \ + SNDRV_PCM_FMTBIT_S32_LE | \ + SNDRV_PCM_FMTBIT_U32_LE | \ + SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) static struct snd_soc_dai_driver dummy_dai = { .name = "snd-soc-dummy-dai", + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 384, + .rates = STUB_RATES, + .formats = STUB_FORMATS, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 384, + .rates = STUB_RATES, + .formats = STUB_FORMATS, + }, }; static int snd_soc_dummy_probe(struct platform_device *pdev) -- cgit v0.10.2