diff mbox

[U-Boot,v5,02/21] sf: Simplify lock ops detection code

Message ID 1477849590-11954-3-git-send-email-jagan@openedev.com
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Jagan Teki Oct. 30, 2016, 5:46 p.m. UTC
Simplify the flash_lock ops detection code and added
meaningful comment.

Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: York Sun <york.sun@nxp.com>
Cc: Vignesh R <vigneshr@ti.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Jagan Teki <jagan@openedev.com>
---
 drivers/mtd/spi/spi_flash.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Simon Glass Nov. 5, 2016, 4:07 p.m. UTC | #1
Hi Jagan,

On 30 October 2016 at 11:46, Jagan Teki <jagan@openedev.com> wrote:
> Simplify the flash_lock ops detection code and added
> meaningful comment.
>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: York Sun <york.sun@nxp.com>
> Cc: Vignesh R <vigneshr@ti.com>
> Cc: Mugunthan V N <mugunthanvnm@ti.com>
> Cc: Michal Simek <michal.simek@xilinx.com>
> Cc: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
> Signed-off-by: Jagan Teki <jagan@openedev.com>
> ---
>  drivers/mtd/spi/spi_flash.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
> index daa9014..b92b0bf 100644
> --- a/drivers/mtd/spi/spi_flash.c
> +++ b/drivers/mtd/spi/spi_flash.c
> @@ -1117,19 +1117,15 @@ int spi_flash_scan(struct spi_flash *flash)
>         flash->read = spi_flash_cmd_read_ops;
>  #endif
>
> -       /* lock hooks are flash specific - assign them based on idcode0 */
> -       switch (JEDEC_MFR(info)) {
>  #if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST)
> -       case SPI_FLASH_CFI_MFR_STMICRO:
> -       case SPI_FLASH_CFI_MFR_SST:
> +       /* NOR protection support for STmicro/Micron chips and similar */
> +       if (JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_STMICRO ||
> +           JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_SST) {
>                 flash->flash_lock = stm_lock;
>                 flash->flash_unlock = stm_unlock;
>                 flash->flash_is_locked = stm_is_locked;
> -#endif
> -               break;
> -       default:
> -               debug("SF: Lock ops not supported for %02x flash\n", JEDEC_MFR(info));

Did you intentionally drop this?

>         }
> +#endif
>
>         /* Compute the flash size */
>         flash->shift = (flash->dual_flash & SF_DUAL_PARALLEL_FLASH) ? 1 : 0;
> --
> 2.7.4
>


Regards,
Simon
Jagan Teki Nov. 15, 2016, 7:02 a.m. UTC | #2
On Sat, Nov 5, 2016 at 9:37 PM, Simon Glass <sjg@chromium.org> wrote:
> Hi Jagan,
>
> On 30 October 2016 at 11:46, Jagan Teki <jagan@openedev.com> wrote:
>> Simplify the flash_lock ops detection code and added
>> meaningful comment.
>>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: Bin Meng <bmeng.cn@gmail.com>
>> Cc: York Sun <york.sun@nxp.com>
>> Cc: Vignesh R <vigneshr@ti.com>
>> Cc: Mugunthan V N <mugunthanvnm@ti.com>
>> Cc: Michal Simek <michal.simek@xilinx.com>
>> Cc: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
>> Signed-off-by: Jagan Teki <jagan@openedev.com>
>> ---
>>  drivers/mtd/spi/spi_flash.c | 12 ++++--------
>>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
>>
>> diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
>> index daa9014..b92b0bf 100644
>> --- a/drivers/mtd/spi/spi_flash.c
>> +++ b/drivers/mtd/spi/spi_flash.c
>> @@ -1117,19 +1117,15 @@ int spi_flash_scan(struct spi_flash *flash)
>>         flash->read = spi_flash_cmd_read_ops;
>>  #endif
>>
>> -       /* lock hooks are flash specific - assign them based on idcode0 */
>> -       switch (JEDEC_MFR(info)) {
>>  #if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST)
>> -       case SPI_FLASH_CFI_MFR_STMICRO:
>> -       case SPI_FLASH_CFI_MFR_SST:
>> +       /* NOR protection support for STmicro/Micron chips and similar */
>> +       if (JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_STMICRO ||
>> +           JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_SST) {
>>                 flash->flash_lock = stm_lock;
>>                 flash->flash_unlock = stm_unlock;
>>                 flash->flash_is_locked = stm_is_locked;
>> -#endif
>> -               break;
>> -       default:
>> -               debug("SF: Lock ops not supported for %02x flash\n", JEDEC_MFR(info));
>
> Did you intentionally drop this?

Since spi_flash_protect returns -EOPNOTSUPP, this extra debug not need.

thanks!
diff mbox

Patch

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index daa9014..b92b0bf 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -1117,19 +1117,15 @@  int spi_flash_scan(struct spi_flash *flash)
 	flash->read = spi_flash_cmd_read_ops;
 #endif
 
-	/* lock hooks are flash specific - assign them based on idcode0 */
-	switch (JEDEC_MFR(info)) {
 #if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST)
-	case SPI_FLASH_CFI_MFR_STMICRO:
-	case SPI_FLASH_CFI_MFR_SST:
+	/* NOR protection support for STmicro/Micron chips and similar */
+	if (JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_STMICRO ||
+	    JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_SST) {
 		flash->flash_lock = stm_lock;
 		flash->flash_unlock = stm_unlock;
 		flash->flash_is_locked = stm_is_locked;
-#endif
-		break;
-	default:
-		debug("SF: Lock ops not supported for %02x flash\n", JEDEC_MFR(info));
 	}
+#endif
 
 	/* Compute the flash size */
 	flash->shift = (flash->dual_flash & SF_DUAL_PARALLEL_FLASH) ? 1 : 0;