From 85e7652d89293a6dab42bfd31f276f8bc072d4c5 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 23 Nov 2011 11:40:40 +0100 Subject: ASoC: Constify snd_soc_dai_ops structs Commit 1ee46ebd("ASoC: Make the DAI ops constant in the DAI structure") introduced the possibility to have constant DAI ops structures, yet this is barley used in both existing drivers and also new drivers being submitted, although none of them modifies its DAI ops structure. The later is not surprising since existing drivers are often used as templates for new drivers. So this patch just constifies all existing snd_soc_dai_ops structs to eliminate the issue altogether. The patch was generated with the following coccinelle semantic patch: // @@ identifier ops; @@ -struct snd_soc_dai_ops ops = +const struct snd_soc_dai_ops ops = { ... }; // Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc/kirkwood') diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 715e841c050..2b212dcb9ac 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -373,7 +373,7 @@ static int kirkwood_i2s_remove(struct snd_soc_dai *dai) return 0; } -static struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { +static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { .startup = kirkwood_i2s_startup, .trigger = kirkwood_i2s_trigger, .hw_params = kirkwood_i2s_hw_params, -- cgit v1.2.3-18-g5258 From 41b1022509733bb3347b15d670f3c1609ddf928f Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 24 Nov 2011 11:43:09 +0800 Subject: ASoC: Convert kirkwood directory to module_platform_driver Factor out some boilerplate code. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-dma.c | 12 +----------- sound/soc/kirkwood/kirkwood-i2s.c | 12 +----------- 2 files changed, 2 insertions(+), 22 deletions(-) (limited to 'sound/soc/kirkwood') diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index cd33de1c5b7..210438261a4 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c @@ -388,17 +388,7 @@ static struct platform_driver kirkwood_pcm_driver = { .remove = __devexit_p(kirkwood_soc_platform_remove), }; -static int __init kirkwood_pcm_init(void) -{ - return platform_driver_register(&kirkwood_pcm_driver); -} -module_init(kirkwood_pcm_init); - -static void __exit kirkwood_pcm_exit(void) -{ - platform_driver_unregister(&kirkwood_pcm_driver); -} -module_exit(kirkwood_pcm_exit); +module_platform_driver(kirkwood_pcm_driver); MODULE_AUTHOR("Arnaud Patard "); MODULE_DESCRIPTION("Marvell Kirkwood Audio DMA module"); diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 2b212dcb9ac..f6bb2115687 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -483,17 +483,7 @@ static struct platform_driver kirkwood_i2s_driver = { }, }; -static int __init kirkwood_i2s_init(void) -{ - return platform_driver_register(&kirkwood_i2s_driver); -} -module_init(kirkwood_i2s_init); - -static void __exit kirkwood_i2s_exit(void) -{ - platform_driver_unregister(&kirkwood_i2s_driver); -} -module_exit(kirkwood_i2s_exit); +module_platform_driver(kirkwood_i2s_driver); /* Module information */ MODULE_AUTHOR("Arnaud Patard, "); -- cgit v1.2.3-18-g5258 From 9b344ce80f8bdf5887d9b5f6d9566d336a8c6ab9 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 23 Dec 2011 14:49:28 +0800 Subject: ASoC: kirkwood: Add .owner to struct snd_soc_card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing .owner of struct snd_soc_card. This prevents the module from being removed from underneath its users. Reported-by: Lothar Waßmann Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-openrd.c | 1 + sound/soc/kirkwood/kirkwood-t5325.c | 1 + 2 files changed, 2 insertions(+) (limited to 'sound/soc/kirkwood') diff --git a/sound/soc/kirkwood/kirkwood-openrd.c b/sound/soc/kirkwood/kirkwood-openrd.c index d863afb3ee5..8a5a3ddaa5e 100644 --- a/sound/soc/kirkwood/kirkwood-openrd.c +++ b/sound/soc/kirkwood/kirkwood-openrd.c @@ -76,6 +76,7 @@ static struct snd_soc_dai_link openrd_client_dai[] = { static struct snd_soc_card openrd_client = { .name = "OpenRD Client", + .owner = THIS_MODULE, .dai_link = openrd_client_dai, .num_links = ARRAY_SIZE(openrd_client_dai), }; diff --git a/sound/soc/kirkwood/kirkwood-t5325.c b/sound/soc/kirkwood/kirkwood-t5325.c index c772b3cf403..a8930c7c9d1 100644 --- a/sound/soc/kirkwood/kirkwood-t5325.c +++ b/sound/soc/kirkwood/kirkwood-t5325.c @@ -98,6 +98,7 @@ static struct snd_soc_dai_link t5325_dai[] = { static struct snd_soc_card t5325 = { .name = "t5325", + .owner = THIS_MODULE, .dai_link = t5325_dai, .num_links = ARRAY_SIZE(t5325_dai), }; -- cgit v1.2.3-18-g5258 From d4d9820b4ad6d6227cad090a9f695eea37814215 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 28 Dec 2011 16:05:22 +0800 Subject: ASoC: Fix build error in sound/soc/kirkwood/kirkwood-i2s.c Since commit db33f4de "ARM: Orion: Remove address map info from all platform data structures", the dram is removed from struct kirkwood_asoc_platform_data. This patch fixes below build error: CC sound/soc/kirkwood/kirkwood-i2s.o sound/soc/kirkwood/kirkwood-i2s.c: In function 'kirkwood_i2s_dev_probe': sound/soc/kirkwood/kirkwood-i2s.c:444: error: 'struct kirkwood_asoc_platform_data' has no member named 'dram' sound/soc/kirkwood/kirkwood-i2s.c:450: error: 'struct kirkwood_asoc_platform_data' has no member named 'dram' make[3]: *** [sound/soc/kirkwood/kirkwood-i2s.o] Error 1 make[2]: *** [sound/soc/kirkwood] Error 2 make[1]: *** [sound/soc] Error 2 make: *** [sound] Error 2 Signed-off-by: Axel Lin Cc: Andrew Lunn Cc: Nicolas Pitre Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-i2s.c | 3 +-- sound/soc/kirkwood/kirkwood.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'sound/soc/kirkwood') diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index f6bb2115687..3cb9aa4299d 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -441,13 +441,12 @@ static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev) goto err_ioremap; } - if (!data || !data->dram) { + if (!data) { dev_err(&pdev->dev, "no platform data ?!\n"); err = -EINVAL; goto err_ioremap; } - priv->dram = data->dram; priv->burst = data->burst; return snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai); diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h index bb6e6a5648c..9047436b393 100644 --- a/sound/soc/kirkwood/kirkwood.h +++ b/sound/soc/kirkwood/kirkwood.h @@ -123,7 +123,6 @@ struct kirkwood_dma_data { void __iomem *io; int irq; int burst; - struct mbus_dram_target_info *dram; }; #endif -- cgit v1.2.3-18-g5258 From 077a2ba4c8e40e6256948c3b4cc60608a284f555 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 28 Dec 2011 18:58:17 +0800 Subject: ASoC: Use dai_fmt in kirkwood-openrd machine driver Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-openrd.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'sound/soc/kirkwood') diff --git a/sound/soc/kirkwood/kirkwood-openrd.c b/sound/soc/kirkwood/kirkwood-openrd.c index 8a5a3ddaa5e..55d2ed3df30 100644 --- a/sound/soc/kirkwood/kirkwood-openrd.c +++ b/sound/soc/kirkwood/kirkwood-openrd.c @@ -26,18 +26,7 @@ static int openrd_client_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret; - unsigned int freq, fmt; - - fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS; - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_fmt(codec_dai, fmt); - if (ret < 0) - return ret; + unsigned int freq; switch (params_rate(params)) { default: @@ -69,6 +58,7 @@ static struct snd_soc_dai_link openrd_client_dai[] = { .platform_name = "kirkwood-pcm-audio", .codec_dai_name = "cs42l51-hifi", .codec_name = "cs42l51-codec.0-004a", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, .ops = &openrd_client_ops, }, }; -- cgit v1.2.3-18-g5258 From 7e0d6ac0d894ebae2ff85ea6108dd065a274dfb9 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 28 Dec 2011 18:59:30 +0800 Subject: ASoC: Use dai_fmt in kirkwood-t5325 machine driver Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-t5325.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'sound/soc/kirkwood') diff --git a/sound/soc/kirkwood/kirkwood-t5325.c b/sound/soc/kirkwood/kirkwood-t5325.c index a8930c7c9d1..6e992307c25 100644 --- a/sound/soc/kirkwood/kirkwood-t5325.c +++ b/sound/soc/kirkwood/kirkwood-t5325.c @@ -25,18 +25,7 @@ static int t5325_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret; - unsigned int freq, fmt; - - fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS; - ret = snd_soc_dai_set_fmt(cpu_dai, fmt); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_fmt(codec_dai, fmt); - if (ret < 0) - return ret; + unsigned int freq; freq = params_rate(params) * 256; @@ -90,6 +79,7 @@ static struct snd_soc_dai_link t5325_dai[] = { .platform_name = "kirkwood-pcm-audio", .codec_dai_name = "alc5621-hifi", .codec_name = "alc562x-codec.0-001a", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, .ops = &t5325_ops, .init = t5325_dai_init, }, -- cgit v1.2.3-18-g5258 From 5f5de18a7f81382fead581efc489dfcfa34601af Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 28 Dec 2011 19:03:23 +0800 Subject: ASoC: Convert kirkwood-t5325 to table based DAPM init Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-t5325.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sound/soc/kirkwood') diff --git a/sound/soc/kirkwood/kirkwood-t5325.c b/sound/soc/kirkwood/kirkwood-t5325.c index 6e992307c25..b47cc4e9b74 100644 --- a/sound/soc/kirkwood/kirkwood-t5325.c +++ b/sound/soc/kirkwood/kirkwood-t5325.c @@ -59,11 +59,6 @@ static int t5325_dai_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; - snd_soc_dapm_new_controls(dapm, t5325_dapm_widgets, - ARRAY_SIZE(t5325_dapm_widgets)); - - snd_soc_dapm_add_routes(dapm, t5325_route, ARRAY_SIZE(t5325_route)); - snd_soc_dapm_enable_pin(dapm, "Mic Jack"); snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin(dapm, "Speaker"); @@ -91,6 +86,11 @@ static struct snd_soc_card t5325 = { .owner = THIS_MODULE, .dai_link = t5325_dai, .num_links = ARRAY_SIZE(t5325_dai), + + .dapm_widgets = t5325_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(t5325_dapm_widgets), + .dapm_routes = t5325_route, + .num_dapm_routes = ARRAY_SIZE(t5325_route), }; static struct platform_device *t5325_snd_device; -- cgit v1.2.3-18-g5258 From 25e9e7565f9aa9e4b976387a3fab60bfaa4efac8 Mon Sep 17 00:00:00 2001 From: Joachim Eastwood Date: Sun, 1 Jan 2012 01:58:44 +0100 Subject: ASoC: check for substream not channels_min in pcm engines This is a follow up on 53dea36c70c1857 which fixes the other affected pcm engines. Description from 53dea36c70c1857: Don't rely on the codec's channels_min information to decide wheter or not allocate a substream's DMA buffer. Rather check if the substream itself was allocated previously. Without this patch I was seeing null-pointer dereferenc in atmel-pcm. Signed-off-by: Joachim Eastwood Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-dma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sound/soc/kirkwood') diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index 210438261a4..d4a17780cef 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c @@ -315,7 +315,6 @@ static int kirkwood_dma_preallocate_dma_buffer(struct snd_pcm *pcm, static int kirkwood_dma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; - struct snd_soc_dai *dai = rtd->cpu_dai; struct snd_pcm *pcm = rtd->pcm; int ret; @@ -324,14 +323,14 @@ static int kirkwood_dma_new(struct snd_soc_pcm_runtime *rtd) if (!card->dev->coherent_dma_mask) card->dev->coherent_dma_mask = 0xffffffff; - if (dai->driver->playback.channels_min) { + if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { ret = kirkwood_dma_preallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_PLAYBACK); if (ret) return ret; } - if (dai->driver->capture.channels_min) { + if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { ret = kirkwood_dma_preallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_CAPTURE); if (ret) -- cgit v1.2.3-18-g5258