mtd: spinand: make spinand_{wait,otp_page_size} global

Change the functions spinand_wait() and spinand_otp_page_size() from
static to global so that SPI NAND flash drivers don't duplicate it.

Signed-off-by: Martin Kurbanov <mmkurbanov@salutedevices.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
Martin Kurbanov 2025-02-10 17:34:15 +03:00 committed by Miquel Raynal
parent c06b1f753b
commit e278b8c73b
3 changed files with 32 additions and 9 deletions

View File

@ -534,10 +534,20 @@ static int spinand_erase_op(struct spinand_device *spinand,
return spi_mem_exec_op(spinand->spimem, &op);
}
static int spinand_wait(struct spinand_device *spinand,
unsigned long initial_delay_us,
unsigned long poll_delay_us,
u8 *s)
/**
* spinand_wait() - Poll memory device status
* @spinand: the spinand device
* @initial_delay_us: delay in us before starting to poll
* @poll_delay_us: time to sleep between reads in us
* @s: the pointer to variable to store the value of REG_STATUS
*
* This function polls a status register (REG_STATUS) and returns when
* the STATUS_READY bit is 0 or when the timeout has expired.
*
* Return: 0 on success, a negative error code otherwise.
*/
int spinand_wait(struct spinand_device *spinand, unsigned long initial_delay_us,
unsigned long poll_delay_us, u8 *s)
{
struct spi_mem_op op = SPINAND_GET_FEATURE_OP(REG_STATUS,
spinand->scratchbuf);

View File

@ -8,14 +8,23 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/spinand.h>
/**
* spinand_otp_page_size() - Get SPI-NAND OTP page size
* @spinand: the spinand device
*
* Return: the OTP page size.
*/
size_t spinand_otp_page_size(struct spinand_device *spinand)
{
struct nand_device *nand = spinand_to_nand(spinand);
return nanddev_page_size(nand) + nanddev_per_page_oobsize(nand);
}
static size_t spinand_otp_size(struct spinand_device *spinand,
const struct spinand_otp_layout *layout)
{
struct nand_device *nand = spinand_to_nand(spinand);
size_t otp_pagesize = nanddev_page_size(nand) +
nanddev_per_page_oobsize(nand);
return layout->npages * otp_pagesize;
return layout->npages * spinand_otp_page_size(spinand);
}
/**

View File

@ -676,12 +676,16 @@ int spinand_upd_cfg(struct spinand_device *spinand, u8 mask, u8 val);
int spinand_write_reg_op(struct spinand_device *spinand, u8 reg, u8 val);
int spinand_select_target(struct spinand_device *spinand, unsigned int target);
int spinand_wait(struct spinand_device *spinand, unsigned long initial_delay_us,
unsigned long poll_delay_us, u8 *s);
int spinand_read_page(struct spinand_device *spinand,
const struct nand_page_io_req *req);
int spinand_write_page(struct spinand_device *spinand,
const struct nand_page_io_req *req);
size_t spinand_otp_page_size(struct spinand_device *spinand);
size_t spinand_fact_otp_size(struct spinand_device *spinand);
size_t spinand_user_otp_size(struct spinand_device *spinand);