From: Michael Walle <michael@walle.cc>
To: chaochao2021666@163.com
Cc: jagan@amarulasolutions.com, Tudor.Ambarus@microchip.com,
vigneshr@ti.com, jan.kiszka@siemens.com, baocheng.su@siemens.com,
le.jin@siemens.com, u-boot@lists.denx.de, trini@konsulko.com,
chao zeng <chao.zeng@siemens.com>
Subject: Re: [PATCH V3] sf: Querying write-protect status before operating the flash
Date: Wed, 17 Nov 2021 09:03:19 +0100 [thread overview]
Message-ID: <1122e19f1f4d0fc7b5cef0a02cb4439a@walle.cc> (raw)
In-Reply-To: <20211117024831.45586-1-chaochao2021666@163.com>
Hi,
Am 2021-11-17 03:48, schrieb chaochao2021666@163.com:
> From: chao zeng <chao.zeng@siemens.com>
>
> When operating the write-protection flash,spi_flash_std_write() and
> spi_flash_std_erase() would return wrong result.The flash is protected,
> but write or erase the flash would show "OK".
>
> Check the flash write protection state before operating the flash
> and give a prompt to show it has been locked if the write-protection
> has enbale
>
> Signed-off-by: chao zeng <chao.zeng@siemens.com>
>
> ---
>
> Changes for V2:
> - Return 0 not ENOPROTOOPT to refelect the flash feature
> - Output prompt information
> Changes for V3:
> - Modify output information
> - Delete return statement
> ---
> drivers/mtd/spi/sf_probe.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
> index f461082e03..f9e879aec5 100644
> --- a/drivers/mtd/spi/sf_probe.c
> +++ b/drivers/mtd/spi/sf_probe.c
> @@ -109,6 +109,9 @@ static int spi_flash_std_write(struct udevice
> *dev, u32 offset, size_t len,
> struct mtd_info *mtd = &flash->mtd;
> size_t retlen;
>
> + if (flash->flash_is_locked && flash->flash_is_locked(flash, offset,
> len))
> + printf("SF: Operate on the protected area.Writes will be
> ignored\n");
I don't think this is the correct place for this output. This could
also be called from a board file programmatically and then it might
display this error, which is annoying.
Also, this is issuing an additional command "read SR" for every write.
What is your intention here? To make the user aware that he is going
to write to a write-protected region when he is using the "sf" command?
If that is the case, this should be added to that command instead.
> +
> return mtd->_write(mtd, offset, len, &retlen, buf);
> }
>
> @@ -127,6 +130,9 @@ static int spi_flash_std_erase(struct udevice
> *dev, u32 offset, size_t len)
> instr.addr = offset;
> instr.len = len;
>
> + if (flash->flash_is_locked && flash->flash_is_locked(flash, offset,
> len))
> + printf("SF: Operate on the protected area.Erase will be ignored\n");
likewise.
-michael
next prev parent reply other threads:[~2021-11-17 8:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 2:48 [PATCH V3] sf: Querying write-protect status before operating the flash chaochao2021666
2021-11-17 8:03 ` Michael Walle [this message]
2021-11-17 8:13 ` Jagan Teki
2021-11-17 11:59 ` Tom Rini
2022-01-13 7:38 ` Jan Kiszka
2022-01-17 17:56 ` Tom Rini
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=1122e19f1f4d0fc7b5cef0a02cb4439a@walle.cc \
--to=michael@walle.cc \
--cc=Tudor.Ambarus@microchip.com \
--cc=baocheng.su@siemens.com \
--cc=chao.zeng@siemens.com \
--cc=chaochao2021666@163.com \
--cc=jagan@amarulasolutions.com \
--cc=jan.kiszka@siemens.com \
--cc=le.jin@siemens.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vigneshr@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox