Skip to content

Commit df9803b

Browse files
committed
mtd: rawnand: Add a helper for calculating a page index
For LUN crossing boundaries, it is handy to know what is the index of the last page in a LUN. This helper will soon be reused. At the same time I rename page_per_lun to ppl in the calling function to clarify the lines. Cc: [email protected] # v6.7 Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent c7ee7c8 commit df9803b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/mtd/nand/raw/nand_base.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,19 +1211,25 @@ static int nand_lp_exec_read_page_op(struct nand_chip *chip, unsigned int page,
12111211
return nand_exec_op(chip, &op);
12121212
}
12131213

1214+
static unsigned int rawnand_last_page_of_lun(unsigned int pages_per_lun, unsigned int lun)
1215+
{
1216+
/* lun is expected to be very small */
1217+
return (lun * pages_per_lun) + pages_per_lun - 1;
1218+
}
1219+
12141220
static void rawnand_cap_cont_reads(struct nand_chip *chip)
12151221
{
12161222
struct nand_memory_organization *memorg;
1217-
unsigned int pages_per_lun, first_lun, last_lun;
1223+
unsigned int ppl, first_lun, last_lun;
12181224

12191225
memorg = nanddev_get_memorg(&chip->base);
1220-
pages_per_lun = memorg->pages_per_eraseblock * memorg->eraseblocks_per_lun;
1221-
first_lun = chip->cont_read.first_page / pages_per_lun;
1222-
last_lun = chip->cont_read.last_page / pages_per_lun;
1226+
ppl = memorg->pages_per_eraseblock * memorg->eraseblocks_per_lun;
1227+
first_lun = chip->cont_read.first_page / ppl;
1228+
last_lun = chip->cont_read.last_page / ppl;
12231229

12241230
/* Prevent sequential cache reads across LUN boundaries */
12251231
if (first_lun != last_lun)
1226-
chip->cont_read.pause_page = first_lun * pages_per_lun + pages_per_lun - 1;
1232+
chip->cont_read.pause_page = rawnand_last_page_of_lun(ppl, first_lun);
12271233
else
12281234
chip->cont_read.pause_page = chip->cont_read.last_page;
12291235
}

0 commit comments

Comments
 (0)