Skip to contentSkip to conversation

ASoC: jz4740-i2s: Use managed resources

PATCH Applied Lars-Peter Clausen 2 participants 3 messages Dec 3, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ASoC: jz4740-i2s: Use managed resources

Makes the code a bit shorter.

---
 sound/soc/jz4740/jz4740-i2s.c |   85 ++++++++---------------------------------
 1 file changed, 15 insertions(+), 70 deletions(-)
sound/soc/jz4740/jz4740-i2s.c +15 -70
index 4c849a4..a0b6a85 100644
@@ -432,91 +432,36 @@ static const struct snd_soc_component_driver jz4740_i2s_component = {
 static int jz4740_i2s_dev_probe(struct platform_device *pdev)
 {
 	struct jz4740_i2s *i2s;
+	struct resource *mem;
 	int ret;
 
-	i2s = kzalloc(sizeof(*i2s), GFP_KERNEL);
-
+	i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL);
 	if (!i2s)
 		return -ENOMEM;
 
-	i2s->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!i2s->mem) {
-		ret = -ENOENT;
-		goto err_free;
-	}
-
-	i2s->mem = request_mem_region(i2s->mem->start, resource_size(i2s->mem),
-				pdev->name);
-	if (!i2s->mem) {
-		ret = -EBUSY;
-		goto err_free;
-	}
-
-	i2s->base = ioremap_nocache(i2s->mem->start, resource_size(i2s->mem));
-	if (!i2s->base) {
-		ret = -EBUSY;
-		goto err_release_mem_region;
-	}
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	i2s->base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(i2s->base))
+		return PTR_ERR(i2s->base);
 
-	i2s->phys_base = i2s->mem->start;
+	i2s->phys_base = mem->start;
 
-	i2s->clk_aic = clk_get(&pdev->dev, "aic");
-	if (IS_ERR(i2s->clk_aic)) {
-		ret = PTR_ERR(i2s->clk_aic);
-		goto err_iounmap;
-	}
+	i2s->clk_aic = devm_clk_get(&pdev->dev, "aic");
+	if (IS_ERR(i2s->clk_aic))
+		return PTR_ERR(i2s->clk_aic);
 
-	i2s->clk_i2s = clk_get(&pdev->dev, "i2s");
-	if (IS_ERR(i2s->clk_i2s)) {
-		ret = PTR_ERR(i2s->clk_i2s);
-		goto err_clk_put_aic;
-	}
+	i2s->clk_i2s = devm_clk_get(&pdev->dev, "i2s");
+	if (IS_ERR(i2s->clk_i2s))
+		return PTR_ERR(i2s->clk_i2s);
 
 	platform_set_drvdata(pdev, i2s);
-	ret = snd_soc_register_component(&pdev->dev, &jz4740_i2s_component,
-					 &jz4740_i2s_dai, 1);
-
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to register DAI\n");
-		goto err_clk_put_i2s;
-	}
-
-	return 0;
-
-err_clk_put_i2s:
-	clk_put(i2s->clk_i2s);
-err_clk_put_aic:
-	clk_put(i2s->clk_aic);
-err_iounmap:
-	iounmap(i2s->base);
-err_release_mem_region:
-	release_mem_region(i2s->mem->start, resource_size(i2s->mem));
-err_free:
-	kfree(i2s);
-
-	return ret;
-}
-
-static int jz4740_i2s_dev_remove(struct platform_device *pdev)
-{
-	struct jz4740_i2s *i2s = platform_get_drvdata(pdev);
-
-	snd_soc_unregister_component(&pdev->dev);
-
-	clk_put(i2s->clk_i2s);
-	clk_put(i2s->clk_aic);
 
-	iounmap(i2s->base);
-	release_mem_region(i2s->mem->start, resource_size(i2s->mem));
-
-	kfree(i2s);
-
-	return 0;
+	return devm_snd_soc_register_component(&pdev->dev,
+		&jz4740_i2s_component, &jz4740_i2s_dai, 1);
 }
 
 static struct platform_driver jz4740_i2s_driver = {
 	.probe = jz4740_i2s_dev_probe,
-	.remove = jz4740_i2s_dev_remove,
 	.driver = {
 		.name = "jz4740-i2s",
 		.owner = THIS_MODULE,
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 2/2 ASoC: jz4740: Use the generic dmaengine PCM driver

Now that there is a dmaengine driver for the jz4740 DMA core we can use the generic dmaengine PCM driver. This allows us to remove the custom jz4740-pcm code completely.

---
 sound/soc/jz4740/Kconfig      |    1 +
 sound/soc/jz4740/jz4740-i2s.c |   54 +++----
 sound/soc/jz4740/jz4740-pcm.c |  358 -----------------------------------------
 sound/soc/jz4740/jz4740-pcm.h |   20 ---
 sound/soc/jz4740/qi_lb60.c    |    2 +-
 5 files changed, 24 insertions(+), 411 deletions(-)
 delete mode 100644 sound/soc/jz4740/jz4740-pcm.c
 delete mode 100644 sound/soc/jz4740/jz4740-pcm.h
sound/soc/jz4740/Kconfig +1 -0
index 94406de..74b2f2b 100644
@@ -1,6 +1,7 @@
 config SND_JZ4740_SOC
 	tristate "SoC Audio for Ingenic JZ4740 SoC"
 	depends on MACH_JZ4740 && SND_SOC
+	select SND_SOC_GENERIC_DMAENGINE_PCM
 	help
 	  Say Y or M if you want to add support for codecs attached to
 	  the JZ4740 I2S interface. You will also need to select the audio
sound/soc/jz4740/jz4740-i2s.c +22 -32

119 lines not on this page · raw message

sound/soc/jz4740/jz4740-pcm.c deleted +0 -358

358 lines not on this page · raw message

sound/soc/jz4740/jz4740-pcm.h deleted +0 -20
deleted file mode 100644
index 1220cbb..0000000
@@ -1,20 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _JZ4740_PCM_H
-#define _JZ4740_PCM_H
-
-#include <linux/dma-mapping.h>
-#include <asm/mach-jz4740/dma.h>
-
-
-struct jz4740_pcm_config {
-	struct jz4740_dma_config dma_config;
-	phys_addr_t fifo_addr;
-};
-
-#endif
sound/soc/jz4740/qi_lb60.c +1 -1
index 55fd6b5..82b5f37 100644
@@ -73,7 +73,7 @@ static struct snd_soc_dai_link qi_lb60_dai = {
 	.name = "jz4740",
 	.stream_name = "jz4740",
 	.cpu_dai_name = "jz4740-i2s",
-	.platform_name = "jz4740-pcm-audio",
+	.platform_name = "jz4740-i2s",
 	.codec_dai_name = "jz4740-hifi",
 	.codec_name = "jz4740-codec",
 	.init = qi_lb60_codec_init,
Signature · 1 line
1.7.10.4