Commit 146bad96191753f1918bfa4dca75d20e03fc63b2

Authored by Tom Rini
Committed by Jagan Teki
1 parent 5b3b0d687e

sf: ops: Add spi_flash_copy_mmap function

When doing a memory mapped copy we may have DMA available and thus need
to have this copy abstracted so that the driver can do it, rather than a
simple memcpy.

Signed-off-by: Tom Rini <trini@ti.com>
Signed-off-by: Vignesh R <vigneshr@ti.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>

Showing 2 changed files with 10 additions and 1 deletions Side-by-side Diff

drivers/mtd/spi/sf_ops.c
... ... @@ -14,6 +14,7 @@
14 14 #include <spi.h>
15 15 #include <spi_flash.h>
16 16 #include <watchdog.h>
  17 +#include <linux/compiler.h>
17 18  
18 19 #include "sf_internal.h"
19 20  
... ... @@ -378,6 +379,11 @@
378 379 return ret;
379 380 }
380 381  
  382 +void __weak spi_flash_copy_mmap(void *data, void *offset, size_t len)
  383 +{
  384 + memcpy(data, offset, len);
  385 +}
  386 +
381 387 int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
382 388 size_t len, void *data)
383 389 {
... ... @@ -394,7 +400,7 @@
394 400 return ret;
395 401 }
396 402 spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP);
397   - memcpy(data, flash->memory_map + offset, len);
  403 + spi_flash_copy_mmap(data, flash->memory_map + offset, len);
398 404 spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP_END);
399 405 spi_release_bus(flash->spi);
400 406 return 0;
... ... @@ -272,6 +272,9 @@
272 272 int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
273 273 void *din, unsigned long flags);
274 274  
  275 +/* Copy memory mapped data */
  276 +void spi_flash_copy_mmap(void *data, void *offset, size_t len);
  277 +
275 278 /**
276 279 * Determine if a SPI chipselect is valid.
277 280 * This function is provided by the board if the low-level SPI driver