[U-Boot] [PATCH v2 2/2] spi: Add SPI NOR protection mechanism

Fabio Estevam festevam at gmail.com
Wed Sep 30 18:38:50 CEST 2015


On Tue, Sep 29, 2015 at 6:12 PM, Jagan Teki <jteki at openedev.com> wrote:

>> +#ifdef CONFIG_SPI_FLASH_STM_PROTECT
>
> Drop this vendor specific macro on command code (usually command code
> deals generic-ness)

Ok

>
>> +static int do_spi_protect(int argc, char * const argv[])
>> +{
>> +       int start, len, ret = 0;
>> +
>> +       if (argc != 4)
>> +               return -1;
>> +
>> +       start = simple_strtoull(argv[2], NULL, 16);
>> +       len = simple_strtoull(argv[3], NULL, 16);
>
> Use proper endptr - see the sample code on same file.

Will use str2off function which automatically handles endptr.

>
>> +
>> +       if (strcmp(argv[1], "on") == 0)
>> +               ret = stm_lock(flash, start, len);
>> +       else if (strcmp(argv[1], "off") == 0)
>> +               ret = stm_unlock(flash, start, len);
>> +       else
>> +               return -1;  /* Unknown parameter */
>
> Again stm_* vendor calls, use spi_flash_protect(flash, start, end,
> prot) then in spi_flash.c call functions flash->lock and flash->unlock
> like read/write ops.

Ok

> Please handle protect check on spi_ops instead of spi_flash, like
> check the whether the sector is protected or not before erasing it.

Ok.

Addressed your comments in v3.

Thanks for your review.

Regards,

Fabio Estevam


More information about the U-Boot mailing list