mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 17:59:32 +00:00
[MTD] [NAND] Tidy up handling of page number in nand_block_bad()
Further to the previous patch fixing the calculation of page number, both branches are using the same result. Clean up the function accordingly, calculating it (and also masking with pagemask) only in one place. Signed-off-by: Thomas Knobloch <knobloch@siemens.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
This commit is contained in:
parent
4839f0481d
commit
1a12f46af1
1 changed files with 5 additions and 6 deletions
|
@ -303,28 +303,27 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
|
|||
struct nand_chip *chip = mtd->priv;
|
||||
u16 bad;
|
||||
|
||||
page = (int)(ofs >> chip->page_shift) & chip->pagemask;
|
||||
|
||||
if (getchip) {
|
||||
page = (int)(ofs >> chip->page_shift);
|
||||
chipnr = (int)(ofs >> chip->chip_shift);
|
||||
|
||||
nand_get_device(chip, mtd, FL_READING);
|
||||
|
||||
/* Select the NAND device */
|
||||
chip->select_chip(mtd, chipnr);
|
||||
} else
|
||||
page = (int)(ofs >> chip->page_shift);
|
||||
}
|
||||
|
||||
if (chip->options & NAND_BUSWIDTH_16) {
|
||||
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE,
|
||||
page & chip->pagemask);
|
||||
page);
|
||||
bad = cpu_to_le16(chip->read_word(mtd));
|
||||
if (chip->badblockpos & 0x1)
|
||||
bad >>= 8;
|
||||
if ((bad & 0xFF) != 0xff)
|
||||
res = 1;
|
||||
} else {
|
||||
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos,
|
||||
page & chip->pagemask);
|
||||
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page);
|
||||
if (chip->read_byte(mtd) != 0xff)
|
||||
res = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue