Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Thomas Knobloch and committed by
David Woodhouse
1a12f46a 4839f048

+5 -6
+5 -6
drivers/mtd/nand/nand_base.c
··· 303 303 struct nand_chip *chip = mtd->priv; 304 304 u16 bad; 305 305 306 + page = (int)(ofs >> chip->page_shift) & chip->pagemask; 307 + 306 308 if (getchip) { 307 - page = (int)(ofs >> chip->page_shift); 308 309 chipnr = (int)(ofs >> chip->chip_shift); 309 310 310 311 nand_get_device(chip, mtd, FL_READING); 311 312 312 313 /* Select the NAND device */ 313 314 chip->select_chip(mtd, chipnr); 314 - } else 315 - page = (int)(ofs >> chip->page_shift); 315 + } 316 316 317 317 if (chip->options & NAND_BUSWIDTH_16) { 318 318 chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE, 319 - page & chip->pagemask); 319 + page); 320 320 bad = cpu_to_le16(chip->read_word(mtd)); 321 321 if (chip->badblockpos & 0x1) 322 322 bad >>= 8; 323 323 if ((bad & 0xFF) != 0xff) 324 324 res = 1; 325 325 } else { 326 - chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, 327 - page & chip->pagemask); 326 + chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page); 328 327 if (chip->read_byte(mtd) != 0xff) 329 328 res = 1; 330 329 }