mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-20 20:04:46 +00:00
mtd: spi: Convert is_locked callback to is_unlocked
There was no user of this callback after 5b66fdb29d
anymore, and its
semantic as now inconsistent between stm and sst26. What we need for the
upcoming new usecase is a "completely unlocked" semantic. So consolidate
over this.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Jagan Teki <jagan@amarulasolutions.com>
This commit is contained in:
parent
cd2f9031e4
commit
513c6071ce
2 changed files with 16 additions and 16 deletions
|
@ -1315,13 +1315,13 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if a region of the flash is (completely) locked. See stm_lock() for
|
* Check if a region of the flash is (completely) unlocked. See stm_lock() for
|
||||||
* more info.
|
* more info.
|
||||||
*
|
*
|
||||||
* Returns 1 if entire region is locked, 0 if any portion is unlocked, and
|
* Returns 1 if entire region is unlocked, 0 if any portion is locked, and
|
||||||
* negative on errors.
|
* negative on errors.
|
||||||
*/
|
*/
|
||||||
static int stm_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len)
|
static int stm_is_unlocked(struct spi_nor *nor, loff_t ofs, uint64_t len)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
@ -1329,7 +1329,7 @@ static int stm_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len)
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
return stm_is_locked_sr(nor, ofs, len, status);
|
return stm_is_unlocked_sr(nor, ofs, len, status);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SPI_FLASH_STMICRO */
|
#endif /* CONFIG_SPI_FLASH_STMICRO */
|
||||||
|
|
||||||
|
@ -1562,16 +1562,16 @@ static int sst26_lock(struct spi_nor *nor, loff_t ofs, uint64_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns EACCES (positive value) if region is locked, 0 if region is unlocked,
|
* Returns EACCES (positive value) if region is (partially) locked, 0 if region
|
||||||
* and negative on errors.
|
* is completely unlocked, and negative on errors.
|
||||||
*/
|
*/
|
||||||
static int sst26_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len)
|
static int sst26_is_unlocked(struct spi_nor *nor, loff_t ofs, uint64_t len)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* is_locked function is used for check before reading or erasing flash
|
* is_unlocked function is used for check before reading or erasing
|
||||||
* region, so offset and length might be not 64k allighned, so adjust
|
* flash region, so offset and length might be not 64k aligned, so
|
||||||
* them to be 64k allighned as sst26_lock_ctl works only with 64k
|
* adjust them to be 64k aligned as sst26_lock_ctl works only with 64k
|
||||||
* allighned regions.
|
* aligned regions.
|
||||||
*/
|
*/
|
||||||
ofs -= ofs & (SZ_64K - 1);
|
ofs -= ofs & (SZ_64K - 1);
|
||||||
len = len & (SZ_64K - 1) ? (len & ~(SZ_64K - 1)) + SZ_64K : len;
|
len = len & (SZ_64K - 1) ? (len & ~(SZ_64K - 1)) + SZ_64K : len;
|
||||||
|
@ -3924,7 +3924,7 @@ int spi_nor_scan(struct spi_nor *nor)
|
||||||
info->flags & SPI_NOR_HAS_LOCK) {
|
info->flags & SPI_NOR_HAS_LOCK) {
|
||||||
nor->flash_lock = stm_lock;
|
nor->flash_lock = stm_lock;
|
||||||
nor->flash_unlock = stm_unlock;
|
nor->flash_unlock = stm_unlock;
|
||||||
nor->flash_is_locked = stm_is_locked;
|
nor->flash_is_unlocked = stm_is_unlocked;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3936,7 +3936,7 @@ int spi_nor_scan(struct spi_nor *nor)
|
||||||
if (info->flags & SPI_NOR_HAS_SST26LOCK) {
|
if (info->flags & SPI_NOR_HAS_SST26LOCK) {
|
||||||
nor->flash_lock = sst26_lock;
|
nor->flash_lock = sst26_lock;
|
||||||
nor->flash_unlock = sst26_unlock;
|
nor->flash_unlock = sst26_unlock;
|
||||||
nor->flash_is_locked = sst26_is_locked;
|
nor->flash_is_unlocked = sst26_is_unlocked;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -517,8 +517,8 @@ struct spi_flash {
|
||||||
* spi-nor will send the erase opcode via write_reg()
|
* spi-nor will send the erase opcode via write_reg()
|
||||||
* @flash_lock: [FLASH-SPECIFIC] lock a region of the SPI NOR
|
* @flash_lock: [FLASH-SPECIFIC] lock a region of the SPI NOR
|
||||||
* @flash_unlock: [FLASH-SPECIFIC] unlock a region of the SPI NOR
|
* @flash_unlock: [FLASH-SPECIFIC] unlock a region of the SPI NOR
|
||||||
* @flash_is_locked: [FLASH-SPECIFIC] check if a region of the SPI NOR is
|
* @flash_is_unlocked: [FLASH-SPECIFIC] check if a region of the SPI NOR is
|
||||||
* completely locked
|
* completely unlocked
|
||||||
* @quad_enable: [FLASH-SPECIFIC] enables SPI NOR quad mode
|
* @quad_enable: [FLASH-SPECIFIC] enables SPI NOR quad mode
|
||||||
* @octal_dtr_enable: [FLASH-SPECIFIC] enables SPI NOR octal DTR mode.
|
* @octal_dtr_enable: [FLASH-SPECIFIC] enables SPI NOR octal DTR mode.
|
||||||
* @ready: [FLASH-SPECIFIC] check if the flash is ready
|
* @ready: [FLASH-SPECIFIC] check if the flash is ready
|
||||||
|
@ -567,7 +567,7 @@ struct spi_nor {
|
||||||
|
|
||||||
int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
|
int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
|
||||||
int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
|
int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
|
||||||
int (*flash_is_locked)(struct spi_nor *nor, loff_t ofs, uint64_t len);
|
int (*flash_is_unlocked)(struct spi_nor *nor, loff_t ofs, uint64_t len);
|
||||||
int (*quad_enable)(struct spi_nor *nor);
|
int (*quad_enable)(struct spi_nor *nor);
|
||||||
int (*octal_dtr_enable)(struct spi_nor *nor);
|
int (*octal_dtr_enable)(struct spi_nor *nor);
|
||||||
int (*ready)(struct spi_nor *nor);
|
int (*ready)(struct spi_nor *nor);
|
||||||
|
|
Loading…
Add table
Reference in a new issue