[PATCH u-boot-spi v2 5/9] mtd: spi-nor-core: Don't check for zero length in spi_nor_erase()

Marek Behún kabel at kernel.org
Fri Oct 1 11:25:13 CEST 2021


On Tue, 28 Sep 2021 22:29:11 +0530
Pratyush Yadav <p.yadav at ti.com> wrote:

> On 25/09/21 07:33PM, Marek Behún wrote:
> > From: Marek Behún <marek.behun at nic.cz>
> > 
> > This check is already done in mtdcore's mtd_erase(), no reason to do
> > this here as well.  
> 
> But do we always get here via mtd_erase()? What about "sf erase"? I 
> looked at the code and I don't see any checks for 0 length there.

Hello Pratyush, you are right.

This function is also called from include/spi_flash.h static inline
function spi_flash_erase(), when CONFIG_IS_ENABLED(DM_SPI_FLASH) is
false.

I think I should move this test to the static inline imlpementation,
before calling mtd->_erase(). This should be done in the caller at one
place, not in all _erase() implementations.

Marek


More information about the U-Boot mailing list