mediatek: backport upstream mediatek patches
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.14 / 0162-mtd-nand-mtk-use-nand_reset-to-reset-NAND-devices-in.patch
1 From fb607c7c1eaeb47ec2ffed99cab571892cb6af7d Mon Sep 17 00:00:00 2001
2 From: Xiaolei Li <xiaolei.li@mediatek.com>
3 Date: Thu, 2 Nov 2017 10:05:07 +0800
4 Subject: [PATCH 162/224] mtd: nand: mtk: use nand_reset() to reset NAND
5 devices in resume function
6
7 Previously, we only select chips and then send reset command to a NAND
8 device during resuming nand driver. There is a lack of deselecting chips.
9 It is advised to reset and initialize a NAND device using nand_reset().
10
11 Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
12 Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
13 Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
14 ---
15 drivers/mtd/nand/mtk_nand.c | 8 ++------
16 1 file changed, 2 insertions(+), 6 deletions(-)
17
18 diff --git a/drivers/mtd/nand/mtk_nand.c b/drivers/mtd/nand/mtk_nand.c
19 index d86a7d131cc0..6d0101e13ef6 100644
20 --- a/drivers/mtd/nand/mtk_nand.c
21 +++ b/drivers/mtd/nand/mtk_nand.c
22 @@ -1540,7 +1540,6 @@ static int mtk_nfc_resume(struct device *dev)
23 struct mtk_nfc *nfc = dev_get_drvdata(dev);
24 struct mtk_nfc_nand_chip *chip;
25 struct nand_chip *nand;
26 - struct mtd_info *mtd;
27 int ret;
28 u32 i;
29
30 @@ -1553,11 +1552,8 @@ static int mtk_nfc_resume(struct device *dev)
31 /* reset NAND chip if VCC was powered off */
32 list_for_each_entry(chip, &nfc->chips, node) {
33 nand = &chip->nand;
34 - mtd = nand_to_mtd(nand);
35 - for (i = 0; i < chip->nsels; i++) {
36 - nand->select_chip(mtd, i);
37 - nand->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
38 - }
39 + for (i = 0; i < chip->nsels; i++)
40 + nand_reset(nand, i);
41 }
42
43 return 0;
44 --
45 2.11.0
46