public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: "Cédric Le Goater" <clg@kaod.org>, linux-mtd@lists.infradead.org
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>,
	Richard Weinberger <richard@nod.at>,
	Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH 4/4] mtd: spi-nor: aspeed: use command mode for reads
Date: Thu, 20 Apr 2017 15:31:30 +0200	[thread overview]
Message-ID: <b28c97cc-1daf-c1dd-4a86-4f8bf6c46b2b@gmail.com> (raw)
In-Reply-To: <1492689397-4704-5-git-send-email-clg@kaod.org>

On 04/20/2017 01:56 PM, Cédric Le Goater wrote:
> When reading flash contents, try to use the "command mode" if the AHB
> window configured for the flash module is big enough. Else, just fall
> back to the "user mode" to perform the read.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> 
>  Changes since initial version :
> 
>  - rebased on current patchset which removed DMA support
> 
>  drivers/mtd/spi-nor/aspeed-smc.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
> index 60c020482946..43015aec4557 100644
> --- a/drivers/mtd/spi-nor/aspeed-smc.c
> +++ b/drivers/mtd/spi-nor/aspeed-smc.c
> @@ -394,6 +394,31 @@ static ssize_t aspeed_smc_read_user(struct spi_nor *nor, loff_t from,
>  
>  	aspeed_smc_read_from_ahb(read_buf, chip->ahb_base, len);
>  	aspeed_smc_stop_user(nor);
> +	return 0;
> +}
> +
> +static ssize_t aspeed_smc_read(struct spi_nor *nor, loff_t from, size_t len,
> +			       u_char *read_buf)
> +{
> +	struct aspeed_smc_chip *chip = nor->priv;
> +
> +	/*
> +	 * The AHB window configured for the chip is too small for the
> +	 * read offset. Use the "User mode" of the controller to
> +	 * perform the read.
> +	 */
> +	if (from >= chip->ahb_window_size) {
> +		aspeed_smc_read_user(nor, from, len, read_buf);
> +		goto out;

What about turning this into dumb if () {} else {} and dropping the goto ?

> +	}
> +
> +	/*
> +	 * Use the "Command mode" to do a direct read from the AHB
> +	 * window configured for the chip. This should be the default.
> +	 */
> +	memcpy_fromio(read_buf, chip->ahb_base + from, len);
> +
> +out:
>  	return len;
>  }
>  
> @@ -817,7 +842,7 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
>  		nor->dev = dev;
>  		nor->priv = chip;
>  		spi_nor_set_flash_node(nor, child);
> -		nor->read = aspeed_smc_read_user;
> +		nor->read = aspeed_smc_read;
>  		nor->write = aspeed_smc_write_user;
>  		nor->read_reg = aspeed_smc_read_reg;
>  		nor->write_reg = aspeed_smc_write_reg;
> 


-- 
Best regards,
Marek Vasut

  reply	other threads:[~2017-04-20 13:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20 11:56 [PATCH 0/4] mtd: spi-nor: aspeed: add dual read and command mode support Cédric Le Goater
2017-04-20 11:56 ` [PATCH 1/4] mtd: spi-nor: aspeed: remove dummies from keep mask Cédric Le Goater
2017-04-20 13:28   ` Marek Vasut
2017-06-20 22:25     ` Cyrille Pitchen
2017-04-20 11:56 ` [PATCH 2/4] mtd: spi-nor: aspeed: add support for SPI dual IO read mode Cédric Le Goater
2017-04-20 13:28   ` Marek Vasut
2017-06-20 22:50   ` Cyrille Pitchen
2017-06-21  7:32     ` Cédric Le Goater
2017-06-21 12:25       ` Cédric Le Goater
2017-06-21 22:46         ` Cyrille Pitchen
2017-04-20 11:56 ` [PATCH 3/4] mtd: spi-nor: aspeed: configure chip window on AHB bus Cédric Le Goater
2017-04-20 13:30   ` Marek Vasut
2017-06-20 22:34     ` Cyrille Pitchen
2017-04-20 11:56 ` [PATCH 4/4] mtd: spi-nor: aspeed: use command mode for reads Cédric Le Goater
2017-04-20 13:31   ` Marek Vasut [this message]
2017-04-20 13:33     ` Richard Weinberger
2017-04-20 13:53     ` Cédric Le Goater
2017-04-20 13:58       ` Marek Vasut
2017-06-20  7:10         ` Cédric Le Goater
2017-06-20  9:07         ` Cédric Le Goater
     [not found]           ` <2bd0b105-7652-8917-4a1d-6f218eaf848e@atmel.com>
2017-06-20 13:49             ` Cédric Le Goater
2017-06-20 14:06             ` Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b28c97cc-1daf-c1dd-4a86-4f8bf6c46b2b@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=clg@kaod.org \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox