f54f9854e30d6b4ebc1140040fc87afef679e28a
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.4 / 1113-mtd-spi-nor-fsl-quad-move-mtd_device_register-to-the.patch
1 From 6f1195d231ab576809fe2f4cff44a6e48cff2457 Mon Sep 17 00:00:00 2001
2 From: Yutang Jiang <yutang.jiang@nxp.com>
3 Date: Fri, 2 Sep 2016 22:00:16 +0800
4 Subject: [PATCH 113/113] mtd: spi-nor: fsl-quad: move mtd_device_register to
5 the last of probe
6
7 After call mtd_device_register, the mtd devices should be workable immediately.
8 If before finish all of init work call the mtd_device_register, it will not
9 respond work request timely.
10
11 For example, openwrt/lede have a AUTO split special flash partitions mechanism
12 while mtd driver register. So, before call mtd_device_register, must let all of
13 init work ready.
14
15 Signed-off-by: Yutang Jiang <yutang.jiang@nxp.com>
16 ---
17 drivers/mtd/spi-nor/fsl-quadspi.c | 14 ++++++++++----
18 1 file changed, 10 insertions(+), 4 deletions(-)
19
20 --- a/drivers/mtd/spi-nor/fsl-quadspi.c
21 +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
22 @@ -1280,10 +1280,6 @@ static int fsl_qspi_probe(struct platfor
23 if (ret)
24 goto mutex_failed;
25
26 - ret = mtd_device_register(mtd, NULL, 0);
27 - if (ret)
28 - goto mutex_failed;
29 -
30 /* Set the correct NOR size now. */
31 if (q->nor_size == 0) {
32 q->nor_size = mtd->size;
33 @@ -1313,6 +1309,16 @@ static int fsl_qspi_probe(struct platfor
34 goto last_init_failed;
35
36 fsl_qspi_clk_disable_unprep(q);
37 +
38 + for (i = 0; i < q->nor_num; i++) {
39 + /* skip the holes */
40 + if (!q->has_second_chip)
41 + i *= 2;
42 +
43 + ret = mtd_device_register(&q->nor[i].mtd, NULL, 0);
44 + if (ret)
45 + goto last_init_failed;
46 + }
47 return 0;
48
49 last_init_failed: