[U-Boot,3/4] mtd: denali: Drop custom dma mapping functions
diff mbox series

Message ID 20191115115505.893-4-vigneshr@ti.com
State New
Delegated to: Tom Rini
Headers show
Series
  • dma-mapping: Add cache flush/invalidation to dma_{un}map_single
Related show

Commit Message

Vignesh Raghavendra Nov. 15, 2019, 11:55 a.m. UTC
Drop local dma_map_single() and dma_unmap_single() and use arch specific
common implementation

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
 drivers/mtd/nand/raw/denali.c | 34 +++-------------------------------
 1 file changed, 3 insertions(+), 31 deletions(-)

Comments

Masahiro Yamada Nov. 15, 2019, 12:18 p.m. UTC | #1
On Fri, Nov 15, 2019 at 8:56 PM Vignesh Raghavendra <vigneshr@ti.com> wrote:
>
> Drop local dma_map_single() and dma_unmap_single() and use arch specific
> common implementation
>
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> ---


Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>  drivers/mtd/nand/raw/denali.c | 34 +++-------------------------------
>  1 file changed, 3 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
> index e0eb1339ecd2..8537c609fb62 100644
> --- a/drivers/mtd/nand/raw/denali.c
> +++ b/drivers/mtd/nand/raw/denali.c
> @@ -5,6 +5,7 @@
>   * Copyright (C) 2009-2010, Intel Corporation and its suppliers.
>   */
>
> +#include <asm/dma-mapping.h>
>  #include <dm.h>
>  #include <nand.h>
>  #include <linux/bitfield.h>
> @@ -16,35 +17,6 @@
>
>  #include "denali.h"
>
> -static dma_addr_t dma_map_single(void *dev, void *ptr, size_t size,
> -                                enum dma_data_direction dir)
> -{
> -       unsigned long addr = (unsigned long)ptr;
> -
> -       size = ALIGN(size, ARCH_DMA_MINALIGN);
> -
> -       if (dir == DMA_FROM_DEVICE)
> -               invalidate_dcache_range(addr, addr + size);
> -       else
> -               flush_dcache_range(addr, addr + size);
> -
> -       return addr;
> -}
> -
> -static void dma_unmap_single(void *dev, dma_addr_t addr, size_t size,
> -                            enum dma_data_direction dir)
> -{
> -       size = ALIGN(size, ARCH_DMA_MINALIGN);
> -
> -       if (dir != DMA_TO_DEVICE)
> -               invalidate_dcache_range(addr, addr + size);
> -}
> -
> -static int dma_mapping_error(void *dev, dma_addr_t addr)
> -{
> -       return 0;
> -}
> -
>  #define DENALI_NAND_NAME    "denali-nand"
>
>  /* for Indexed Addressing */
> @@ -564,7 +536,7 @@ static int denali_dma_xfer(struct denali_nand_info *denali, void *buf,
>         enum dma_data_direction dir = write ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
>         int ret = 0;
>
> -       dma_addr = dma_map_single(denali->dev, buf, size, dir);
> +       dma_addr = dma_map_single(buf, size, dir);
>         if (dma_mapping_error(denali->dev, dma_addr)) {
>                 dev_dbg(denali->dev, "Failed to DMA-map buffer. Trying PIO.\n");
>                 return denali_pio_xfer(denali, buf, size, page, raw, write);
> @@ -605,7 +577,7 @@ static int denali_dma_xfer(struct denali_nand_info *denali, void *buf,
>
>         iowrite32(0, denali->reg + DMA_ENABLE);
>
> -       dma_unmap_single(denali->dev, dma_addr, size, dir);
> +       dma_unmap_single(buf, size, dir);
>
>         if (irq_status & INTR__ERASED_PAGE)
>                 memset(buf, 0xff, size);
> --
> 2.24.0
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot

Patch
diff mbox series

diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
index e0eb1339ecd2..8537c609fb62 100644
--- a/drivers/mtd/nand/raw/denali.c
+++ b/drivers/mtd/nand/raw/denali.c
@@ -5,6 +5,7 @@ 
  * Copyright (C) 2009-2010, Intel Corporation and its suppliers.
  */
 
+#include <asm/dma-mapping.h>
 #include <dm.h>
 #include <nand.h>
 #include <linux/bitfield.h>
@@ -16,35 +17,6 @@ 
 
 #include "denali.h"
 
-static dma_addr_t dma_map_single(void *dev, void *ptr, size_t size,
-				 enum dma_data_direction dir)
-{
-	unsigned long addr = (unsigned long)ptr;
-
-	size = ALIGN(size, ARCH_DMA_MINALIGN);
-
-	if (dir == DMA_FROM_DEVICE)
-		invalidate_dcache_range(addr, addr + size);
-	else
-		flush_dcache_range(addr, addr + size);
-
-	return addr;
-}
-
-static void dma_unmap_single(void *dev, dma_addr_t addr, size_t size,
-			     enum dma_data_direction dir)
-{
-	size = ALIGN(size, ARCH_DMA_MINALIGN);
-
-	if (dir != DMA_TO_DEVICE)
-		invalidate_dcache_range(addr, addr + size);
-}
-
-static int dma_mapping_error(void *dev, dma_addr_t addr)
-{
-	return 0;
-}
-
 #define DENALI_NAND_NAME    "denali-nand"
 
 /* for Indexed Addressing */
@@ -564,7 +536,7 @@  static int denali_dma_xfer(struct denali_nand_info *denali, void *buf,
 	enum dma_data_direction dir = write ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
 	int ret = 0;
 
-	dma_addr = dma_map_single(denali->dev, buf, size, dir);
+	dma_addr = dma_map_single(buf, size, dir);
 	if (dma_mapping_error(denali->dev, dma_addr)) {
 		dev_dbg(denali->dev, "Failed to DMA-map buffer. Trying PIO.\n");
 		return denali_pio_xfer(denali, buf, size, page, raw, write);
@@ -605,7 +577,7 @@  static int denali_dma_xfer(struct denali_nand_info *denali, void *buf,
 
 	iowrite32(0, denali->reg + DMA_ENABLE);
 
-	dma_unmap_single(denali->dev, dma_addr, size, dir);
+	dma_unmap_single(buf, size, dir);
 
 	if (irq_status & INTR__ERASED_PAGE)
 		memset(buf, 0xff, size);