Re: [PATCH] mtd: spi-nor: use spi-mem dirmap API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 25 Oct 2019 23:26:42 +0300
Sergei Shtylyov <sergei.shtylyov@xxxxxxxxxxxxxxxxxx> wrote:

> Make use of the spi-mem direct mapping API to let advanced controllers
> optimize read/write operations when they support direct mapping.
> 
> Based on the original patch by Boris Brezillon <boris.brezillon@xxxxxxxxxxx>.
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@xxxxxxxxxxxxxxxxxx>
> 
> ---
> This patch is against the 'spi-nor/next' branch of the MTD 'linux.git' repo.
> 
>  drivers/mtd/spi-nor/spi-nor.c |   79 ++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mtd/spi-nor.h   |    5 ++
>  2 files changed, 84 insertions(+)
> 
> Index: linux/drivers/mtd/spi-nor/spi-nor.c
> ===================================================================
> --- linux.orig/drivers/mtd/spi-nor/spi-nor.c
> +++ linux/drivers/mtd/spi-nor/spi-nor.c
> @@ -2562,6 +2562,14 @@ static int spi_nor_read(struct mtd_info
>  	if (ret)
>  		return ret;
>  
> +	if (nor->dirmap.rdesc) {
> +		ret = spi_mem_dirmap_read(nor->dirmap.rdesc, from, len, buf);

This spi_mem_dirmap_read() call should be moved to
spi_nor_spimem_read_data().

> +		if (ret < 0)
> +			goto read_err;
> +		*retlen += ret;
> +		goto done;
> +	}
> +
>  	while (len) {
>  		loff_t addr = from;
>  
> @@ -2582,6 +2590,7 @@ static int spi_nor_read(struct mtd_info
>  		from += ret;
>  		len -= ret;
>  	}
> +done:
>  	ret = 0;
>  
>  read_err:
> @@ -2686,6 +2695,14 @@ static int spi_nor_write(struct mtd_info
>  	if (ret)
>  		return ret;
>  
> +	if (nor->dirmap.wdesc) {
> +		ret = spi_mem_dirmap_write(nor->dirmap.wdesc, to, len, buf);

Same here, this should be moved to spi_nor_spimem_write_data(). BTW, I
wonder how this can work since write_enable() is called in the below for
loop (which you skip). Is your SPI controller sending the WE cmd
automatically?

> +		if (ret < 0)
> +			goto write_err;
> +		*retlen += ret;
> +		goto done;
> +	}
> +
>  	for (i = 0; i < len; ) {
>  		ssize_t written;
>  		loff_t addr = to + i;
> @@ -2723,6 +2740,8 @@ static int spi_nor_write(struct mtd_info
>  		*retlen += written;
>  		i += written;
>  	}
> +done:
> +	ret = 0;
>  
>  write_err:
>  	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_WRITE);
> @@ -4991,6 +5010,58 @@ int spi_nor_scan(struct spi_nor *nor, co
>  }
>  EXPORT_SYMBOL_GPL(spi_nor_scan);
>  


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux