diff mbox

[U-Boot,1/2] spi_flash: Add error message when lock operations are not supported

Message ID 1447255290-9288-1-git-send-email-festevam@gmail.com
State Rejected
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Fabio Estevam Nov. 11, 2015, 3:21 p.m. UTC
From: Fabio Estevam <fabio.estevam@freescale.com>

In the case of lock operations not being supported, we should better let
the user know instead of failing silently.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 include/spi_flash.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jagan Teki Nov. 17, 2015, 6:20 p.m. UTC | #1
On 11 November 2015 at 20:51, Fabio Estevam <festevam@gmail.com> wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> In the case of lock operations not being supported, we should better let
> the user know instead of failing silently.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  include/spi_flash.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/spi_flash.h b/include/spi_flash.h
> index 0ae0062..ff51c50 100644
> --- a/include/spi_flash.h
> +++ b/include/spi_flash.h
> @@ -237,8 +237,10 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
>  static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
>                                         bool prot)
>  {
> -       if (!flash->flash_lock)
> +       if (!flash->flash_lock) {
> +               printf("Protect operation not supported for this flash\n");
>                 return -EOPNOTSUPP;
> +       }

Here it's not required, it's better to print the protected area in
cmd_sf itself similar way as mtd_utils flash_lock

thanks!
diff mbox

Patch

diff --git a/include/spi_flash.h b/include/spi_flash.h
index 0ae0062..ff51c50 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -237,8 +237,10 @@  static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
 static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
 					bool prot)
 {
-	if (!flash->flash_lock)
+	if (!flash->flash_lock) {
+		printf("Protect operation not supported for this flash\n");
 		return -EOPNOTSUPP;
+	}
 
 	if (prot)
 		return flash->flash_lock(flash, ofs, len);