[U-Boot] [PATCH 3/6] sf: sf_ops: use dma to copy data from mmap region if platform supports

Simon Glass sjg at chromium.org
Tue Dec 1 22:54:40 CET 2015


Hi,

On 1 December 2015 at 04:13, Mugunthan V N <mugunthanvnm at ti.com> wrote:
> Add dma memcpy api to the default spi_flash_copy_mmap(), so that
> dma will be used to copy data when DM_DMA is defined for the
> platform.
>
> Signed-off-by: Mugunthan V N <mugunthanvnm at ti.com>
> ---
>  drivers/mtd/spi/sf_ops.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
> index 3a56d7f..3c83f8a 100644
> --- a/drivers/mtd/spi/sf_ops.c
> +++ b/drivers/mtd/spi/sf_ops.c
> @@ -16,6 +16,7 @@
>  #include <watchdog.h>
>  #include <linux/compiler.h>
>  #include <linux/log2.h>
> +#include <dma.h>
>
>  #include "sf_internal.h"
>
> @@ -389,6 +390,10 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
>
>  void __weak spi_flash_copy_mmap(void *data, void *offset, size_t len)
>  {
> +#ifdef CONFIG_DM_DMA
> +       if (!dma_memcpy(data, offset, len))
> +               return;
> +#endif
>         memcpy(data, offset, len);
>  }
>
> --
> 2.6.3.368.gf34be46
>

This looks like one driver (SPI flash) calling a weak function in
another (SPI). Why isn't this done with the driver interface?

Regards,
Simon


More information about the U-Boot mailing list