All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Tudor.Ambarus@microchip.com>
To: <chaochao2021666@163.com>, <jagan@amarulasolutions.com>,
	<vigneshr@ti.com>, <michael@walle.cc>
Cc: <chao.zeng@siemens.com>, <jan.kiszka@siemens.com>,
	<trini@konsulko.com>, <u-boot@lists.denx.de>,
	<baocheng.su@siemens.com>, <le.jin@siemens.com>
Subject: Re: [PATCH v2] sf: Querying write-protect status before operating the flash
Date: Mon, 15 Nov 2021 05:57:25 +0000	[thread overview]
Message-ID: <fed36e0c-ce71-5533-ee79-04cd79eb2b62@microchip.com> (raw)
In-Reply-To: <20211115023710.893954-1-chaochao2021666@163.com>

Hi,

+ Michael

On 11/15/21 4:37 AM, chaochao2021666@163.com wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> 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
> ---
>  drivers/mtd/spi/sf_probe.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
> index f461082e03..995801817d 100644
> --- a/drivers/mtd/spi/sf_probe.c
> +++ b/drivers/mtd/spi/sf_probe.c
> @@ -109,6 +109,11 @@ 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: Flash is locked\n");

I would use a debug message, it's a flash specific thing. Also, I would update
a bit the message, something like
"SF: Flash has protected areas in the requested length. Writes will be ignored on those."

> +               return 0;

Michael has suggested to drop this line. I agree with him, check the conversation
on the previous email thread.

Cheers,
ta

> +       }
> +
>         return mtd->_write(mtd, offset, len, &retlen, buf);
>  }
> 
> @@ -127,6 +132,11 @@ 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: Flash is locked\n");
> +               return 0;
> +       }
> +
>         return mtd->_erase(mtd, &instr);
>  }
> 
> --
> 2.33.1
> 
> 


  reply	other threads:[~2021-11-15  5:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15  2:37 [PATCH v2] sf: Querying write-protect status before operating the flash chaochao2021666
2021-11-15  5:57 ` Tudor.Ambarus [this message]
2021-11-15 13:20   ` chaochao2021666
2021-11-15 14:02     ` Jagan Teki
2021-11-15 14:18       ` Tom Rini
2021-11-15 14:49         ` Jagan Teki
2021-11-16  8:41       ` chaochao
2021-11-16 20:10         ` 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=fed36e0c-ce71-5533-ee79-04cd79eb2b62@microchip.com \
    --to=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=michael@walle.cc \
    --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 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.