From: Thomas Gleixner Date: Tue, 27 Jun 2006 22:11:45 +0000 (+0200) Subject: [MTD] NAND: Select chip before checking write protect status X-Git-Tag: firefly_0821_release~34835^2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6a93096195305f6f2a39544a034e77e2e74d5799;p=firefly-linux-kernel-4.4.55.git [MTD] NAND: Select chip before checking write protect status The other way round works not really well with boards which have a static NAND chipselect. Signed-off-by: Thomas Gleixner Signed-off-by: David Woodhouse --- diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 8df184f6d8d1..80a76654d963 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1610,13 +1610,13 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, if (!writelen) return 0; + chipnr = (int)(to >> chip->chip_shift); + chip->select_chip(mtd, chipnr); + /* Check, if it is write protected */ if (nand_check_wp(mtd)) return -EIO; - chipnr = (int)(to >> chip->chip_shift); - chip->select_chip(mtd, chipnr); - realpage = (int)(to >> chip->page_shift); page = realpage & chip->pagemask; blockmask = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1;