1 From 49ff5bd7d4d51a8eb05796f130e9a1a96d18f522 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Wed, 17 Apr 2013 13:38:14 -0300
4 Subject: [PATCH 106/203] mtd: nand: pxa3xx: Move buffer release code to its
7 Create a function to release the buffer and the dma channel, thus undoing
8 what pxa3xx_nand_init_buff() did. This commit makes the code more readable
9 and will allow to handle non-DMA capable platforms easier.
11 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
12 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
13 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
15 drivers/mtd/nand/pxa3xx_nand.c | 26 ++++++++++++++------------
16 1 file changed, 14 insertions(+), 12 deletions(-)
18 --- a/drivers/mtd/nand/pxa3xx_nand.c
19 +++ b/drivers/mtd/nand/pxa3xx_nand.c
20 @@ -912,6 +912,18 @@ static int pxa3xx_nand_init_buff(struct
24 +static void pxa3xx_nand_free_buff(struct pxa3xx_nand_info *info)
26 + struct platform_device *pdev = info->pdev;
28 + pxa_free_dma(info->data_dma_ch);
29 + dma_free_coherent(&pdev->dev, MAX_BUFF_SIZE,
30 + info->data_buff, info->data_buff_phys);
32 + kfree(info->data_buff);
36 static int pxa3xx_nand_sensing(struct pxa3xx_nand_info *info)
39 @@ -1137,12 +1149,7 @@ static int alloc_nand_resource(struct pl
44 - pxa_free_dma(info->data_dma_ch);
45 - dma_free_coherent(&pdev->dev, MAX_BUFF_SIZE,
46 - info->data_buff, info->data_buff_phys);
48 - kfree(info->data_buff);
49 + pxa3xx_nand_free_buff(info);
51 clk_disable_unprepare(info->clk);
53 @@ -1163,12 +1170,7 @@ static int pxa3xx_nand_remove(struct pla
54 irq = platform_get_irq(pdev, 0);
58 - pxa_free_dma(info->data_dma_ch);
59 - dma_free_writecombine(&pdev->dev, MAX_BUFF_SIZE,
60 - info->data_buff, info->data_buff_phys);
62 - kfree(info->data_buff);
63 + pxa3xx_nand_free_buff(info);
65 clk_disable_unprepare(info->clk);