ipq806x: 6.1: copy patches, files and config from 5.15
[openwrt/staging/ansuel.git] / target / linux / ipq806x / patches-6.1 / 130-mtd-nand-raw-qcom_nandc-handle-ret-from-parse-with-c.patch
1 From 99d897e04c0856188e371e60b00e13106cd44a24 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 21 Oct 2022 18:38:21 +0200
4 Subject: [PATCH] mtd: nand: raw: qcom_nandc: handle ret from parse with
5 codeword_fixup
6
7 With use_codeword_fixup enabled, any return from
8 mtd_device_parse_register gets overwritten. Aside from the clear bug, this
9 is also problematic as a parser can EPROBE_DEFER and because this is not
10 correctly handled, the nand is never rescanned later in the bootup
11 process.
12
13 An example of this problem is when smem requires additional time to be
14 probed and nandc use qcomsmempart as parser. Parser will return
15 EPROBE_DEFER but in the current code this ret gets overwritten by
16 qcom_nand_host_parse_boot_partitions and qcom_nand_host_init_and_register
17 return 0.
18
19 Correctly handle the return code from mtd_device_parse_register so that
20 any error from this function is not ignored.
21
22 Fixes: 862bdedd7f4b ("mtd: nand: raw: qcom_nandc: add support for unprotected spare data pages")
23 Cc: stable@vger.kernel.org # v6.0+
24 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
25 ---
26 drivers/mtd/nand/raw/qcom_nandc.c | 12 +++++++-----
27 1 file changed, 7 insertions(+), 5 deletions(-)
28
29 --- a/drivers/mtd/nand/raw/qcom_nandc.c
30 +++ b/drivers/mtd/nand/raw/qcom_nandc.c
31 @@ -3157,16 +3157,18 @@ static int qcom_nand_host_init_and_regis
32
33 ret = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
34 if (ret)
35 - nand_cleanup(chip);
36 + goto err;
37
38 if (nandc->props->use_codeword_fixup) {
39 ret = qcom_nand_host_parse_boot_partitions(nandc, host, dn);
40 - if (ret) {
41 - nand_cleanup(chip);
42 - return ret;
43 - }
44 + if (ret)
45 + goto err;
46 }
47
48 + return 0;
49 +
50 +err:
51 + nand_cleanup(chip);
52 return ret;
53 }
54