summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/pxa3xx_nand.c
diff options
context:
space:
mode:
authorEzequiel Garcia2013-04-17 18:38:14 +0200
committerDavid Woodhouse2013-08-05 21:48:13 +0200
commit498b6145b8878c3659dfe57921deb7802196ce43 (patch)
tree70b9364f3ac8827ceb33b4c633df304fe5c6421a /drivers/mtd/nand/pxa3xx_nand.c
parentmtd: nand: pxa3xx: Check for clk_prepare_enable() return value (diff)
downloadkernel-qcow2-linux-498b6145b8878c3659dfe57921deb7802196ce43.tar.gz
kernel-qcow2-linux-498b6145b8878c3659dfe57921deb7802196ce43.tar.xz
kernel-qcow2-linux-498b6145b8878c3659dfe57921deb7802196ce43.zip
mtd: nand: pxa3xx: Move buffer release code to its own function
Create a function to release the buffer and the dma channel, thus undoing what pxa3xx_nand_init_buff() did. This commit makes the code more readable and will allow to handle non-DMA capable platforms easier. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand/pxa3xx_nand.c')
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 0f820caaa893..14d3db518821 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -912,6 +912,18 @@ static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info *info)
return 0;
}
+static void pxa3xx_nand_free_buff(struct pxa3xx_nand_info *info)
+{
+ struct platform_device *pdev = info->pdev;
+ if (use_dma) {
+ pxa_free_dma(info->data_dma_ch);
+ dma_free_coherent(&pdev->dev, MAX_BUFF_SIZE,
+ info->data_buff, info->data_buff_phys);
+ } else {
+ kfree(info->data_buff);
+ }
+}
+
static int pxa3xx_nand_sensing(struct pxa3xx_nand_info *info)
{
struct mtd_info *mtd;
@@ -1137,12 +1149,7 @@ static int alloc_nand_resource(struct platform_device *pdev)
fail_free_buf:
free_irq(irq, info);
- if (use_dma) {
- pxa_free_dma(info->data_dma_ch);
- dma_free_coherent(&pdev->dev, MAX_BUFF_SIZE,
- info->data_buff, info->data_buff_phys);
- } else
- kfree(info->data_buff);
+ pxa3xx_nand_free_buff(info);
fail_disable_clk:
clk_disable_unprepare(info->clk);
return ret;
@@ -1163,12 +1170,7 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0);
if (irq >= 0)
free_irq(irq, info);
- if (use_dma) {
- pxa_free_dma(info->data_dma_ch);
- dma_free_writecombine(&pdev->dev, MAX_BUFF_SIZE,
- info->data_buff, info->data_buff_phys);
- } else
- kfree(info->data_buff);
+ pxa3xx_nand_free_buff(info);
clk_disable_unprepare(info->clk);