mtd: nand: fix NAND_BUSWIDTH_AUTO for x16 devices
authorBrian Norris <computersforpeace@gmail.com>
Thu, 18 Jul 2013 08:17:02 +0000 (01:17 -0700)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 5 Aug 2013 20:02:31 +0000 (21:02 +0100)
commit68e8078072e802e77134664f11d2ffbfbd2f8fbe
treec1cee05a12ecb01d7e1dbca04d6a9ef6ac5ff522
parent9d40349681ea44d80ef84e7a9eb3786165ba79d1
mtd: nand: fix NAND_BUSWIDTH_AUTO for x16 devices

The code for NAND_BUSWIDTH_AUTO is broken. According to Alexander:

  "I have a problem with attach NAND UBI in 16 bit mode.
   NAND works fine if I specify NAND_BUSWIDTH_16 option, but not
   working with NAND_BUSWIDTH_AUTO option. In second case NAND
   chip is identifyed with ONFI."

See his report for the rest of the details:

  http://lists.infradead.org/pipermail/linux-mtd/2013-July/047515.html

Anyway, the problem is that nand_set_defaults() is called twice, we
intend it to reset the chip functions to their x16 buswidth verions
if the buswidth changed from x8 to x16; however, nand_set_defaults()
does exactly nothing if called a second time.

Fix this by hacking nand_set_defaults() to reset the buswidth-dependent
functions if they were set to the x8 version the first time. Note that
this does not do anything to reset from x16 to x8, but that's not the
supported use case for NAND_BUSWIDTH_AUTO anyway.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reported-by: Alexander Shiyan <shc_work@mail.ru>
Tested-by: Alexander Shiyan <shc_work@mail.ru>
Cc: Matthieu Castet <matthieu.castet@parrot.com>
Cc: <stable@vger.kernel.org> # v3.8+
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/nand/nand_base.c