Skip to content

Commit e278b8c

Browse files
m-kurbanovmiquelraynal
authored andcommitted
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 <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent c06b1f7 commit e278b8c

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

drivers/mtd/nand/spi/core.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,20 @@ static int spinand_erase_op(struct spinand_device *spinand,
534534
return spi_mem_exec_op(spinand->spimem, &op);
535535
}
536536

537-
static int spinand_wait(struct spinand_device *spinand,
538-
unsigned long initial_delay_us,
539-
unsigned long poll_delay_us,
540-
u8 *s)
537+
/**
538+
* spinand_wait() - Poll memory device status
539+
* @spinand: the spinand device
540+
* @initial_delay_us: delay in us before starting to poll
541+
* @poll_delay_us: time to sleep between reads in us
542+
* @s: the pointer to variable to store the value of REG_STATUS
543+
*
544+
* This function polls a status register (REG_STATUS) and returns when
545+
* the STATUS_READY bit is 0 or when the timeout has expired.
546+
*
547+
* Return: 0 on success, a negative error code otherwise.
548+
*/
549+
int spinand_wait(struct spinand_device *spinand, unsigned long initial_delay_us,
550+
unsigned long poll_delay_us, u8 *s)
541551
{
542552
struct spi_mem_op op = SPINAND_GET_FEATURE_OP(REG_STATUS,
543553
spinand->scratchbuf);

drivers/mtd/nand/spi/otp.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@
88
#include <linux/mtd/mtd.h>
99
#include <linux/mtd/spinand.h>
1010

11-
static size_t spinand_otp_size(struct spinand_device *spinand,
12-
const struct spinand_otp_layout *layout)
11+
/**
12+
* spinand_otp_page_size() - Get SPI-NAND OTP page size
13+
* @spinand: the spinand device
14+
*
15+
* Return: the OTP page size.
16+
*/
17+
size_t spinand_otp_page_size(struct spinand_device *spinand)
1318
{
1419
struct nand_device *nand = spinand_to_nand(spinand);
15-
size_t otp_pagesize = nanddev_page_size(nand) +
16-
nanddev_per_page_oobsize(nand);
1720

18-
return layout->npages * otp_pagesize;
21+
return nanddev_page_size(nand) + nanddev_per_page_oobsize(nand);
22+
}
23+
24+
static size_t spinand_otp_size(struct spinand_device *spinand,
25+
const struct spinand_otp_layout *layout)
26+
{
27+
return layout->npages * spinand_otp_page_size(spinand);
1928
}
2029

2130
/**

include/linux/mtd/spinand.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,16 @@ int spinand_upd_cfg(struct spinand_device *spinand, u8 mask, u8 val);
676676
int spinand_write_reg_op(struct spinand_device *spinand, u8 reg, u8 val);
677677
int spinand_select_target(struct spinand_device *spinand, unsigned int target);
678678

679+
int spinand_wait(struct spinand_device *spinand, unsigned long initial_delay_us,
680+
unsigned long poll_delay_us, u8 *s);
681+
679682
int spinand_read_page(struct spinand_device *spinand,
680683
const struct nand_page_io_req *req);
681684

682685
int spinand_write_page(struct spinand_device *spinand,
683686
const struct nand_page_io_req *req);
684687

688+
size_t spinand_otp_page_size(struct spinand_device *spinand);
685689
size_t spinand_fact_otp_size(struct spinand_device *spinand);
686690
size_t spinand_user_otp_size(struct spinand_device *spinand);
687691

0 commit comments

Comments
 (0)