From: Brian Norris <computersforpeace@gmail.com>
To: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: linux-mtd@lists.infradead.org,
Gregory Clement <gregory.clement@free-electrons.com>,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
Stas Sergeev <stsp@list.ru>
Subject: Re: [PATCH] mtd: spi-nor: wait until lock/unlock operations are ready
Date: Tue, 15 Dec 2015 10:12:57 -0800 [thread overview]
Message-ID: <20151215181257.GD10460@google.com> (raw)
In-Reply-To: <1448240997-26969-1-git-send-email-ezequiel@vanguardiasur.com.ar>
On Sun, Nov 22, 2015 at 10:09:57PM -0300, Ezequiel Garcia wrote:
> On Micron and Numonyx devices, the status register write command
> (WRSR), raises a work-in-progress bit (WIP) on the status register.
> The datasheets for these devices specify that while the status
> register write is in progress, the status register WIP bit can still
> be read to check the end of the operation.
>
> This commit adds a wait_till_ready call on lock/unlock operations,
> only for these manufacturers. This is needed to prevent applications
> from issuing erase or program operations before the unlock operation
> is completed.
>
> Reported-by: Stas Sergeev <stsp@list.ru>
> Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
> ---
> drivers/mtd/spi-nor/spi-nor.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index e9c26c0e2258..acc9b05e02be 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -485,6 +485,7 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
> u8 status_old, status_new;
> u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
> u8 shift = ffs(mask) - 1, pow, val;
> + int ret;
I've merged other patches in the meantime (sorry), so this might need a
rebasing on l2-mtd.git. I'd do it, but should get a v2 anyway.
>
> status_old = read_sr(nor);
>
> @@ -521,7 +522,13 @@ static int stm_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
> return -EINVAL;
>
> write_enable(nor);
> - return write_sr(nor, status_new);
> + ret = write_sr(nor, status_new);
> + if (ret)
> + return ret;
> + ret = spi_nor_wait_till_ready(nor);
> + if (ret)
> + return ret;
> + return 0;
Why not just return spi_nor_wait_till_ready(nor)?
> }
>
> /*
> @@ -535,6 +542,7 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
> uint8_t status_old, status_new;
> u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
> u8 shift = ffs(mask) - 1, pow, val;
> + int ret;
>
> status_old = read_sr(nor);
>
> @@ -569,7 +577,13 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
> return -EINVAL;
>
> write_enable(nor);
> - return write_sr(nor, status_new);
> + ret = write_sr(nor, status_new);
> + if (ret)
> + return ret;
> + ret = spi_nor_wait_till_ready(nor);
> + if (ret)
> + return ret;
> + return 0;
Same?
> }
>
> /*
Brian
next prev parent reply other threads:[~2015-12-15 18:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-23 1:09 [PATCH] mtd: spi-nor: wait until lock/unlock operations are ready Ezequiel Garcia
2015-12-15 18:12 ` Brian Norris [this message]
2015-12-15 18:22 ` Ezequiel Garcia
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=20151215181257.GD10460@google.com \
--to=computersforpeace@gmail.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=gregory.clement@free-electrons.com \
--cc=linux-mtd@lists.infradead.org \
--cc=stsp@list.ru \
--cc=thomas.petazzoni@free-electrons.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.