aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/sunxi/patches-4.1/124-mtd-nand-sunxi-fallback-to-chip-config.patch
blob: cba30d27f516cfd889bbda25b6f389281ae63c9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From de994d9c849ca0ca020fccfa1916afcde7f313f2 Mon Sep 17 00:00:00 2001
From: Boris BREZILLON <boris.brezillon@free-electrons.com>
Date: Sun, 24 Aug 2014 10:40:44 +0200
Subject: [PATCH] mtd: nand: sunxi: Fallback to chip config when partition
 config is not available

Fallback to chip config for partitions where ecc/rnd config are not
specified in the device tree.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/mtd/nand/sunxi_nand.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -1709,28 +1709,37 @@ static void sunxi_nand_part_release(stru
 struct nand_part *sunxi_ofnandpart_parse(void *priv, struct mtd_info *master,
 					 struct device_node *pp)
 {
+	struct nand_chip *chip = master->priv;
 	struct sunxi_nand_part *part;
 	int ret;
 
 	part = kzalloc(sizeof(*part), GFP_KERNEL);
 	part->part.release = sunxi_nand_part_release;
 
-	ret = sunxi_nand_ecc_init(master, &part->ecc, pp);
-	if (ret)
-		goto err;
-
-	ret = sunxi_nand_rnd_init(master, &part->rnd, &part->ecc, pp);
-	if (ret) {
-		sunxi_nand_ecc_cleanup(&part->ecc);
-		goto err;
+	if (of_find_property(pp, "nand-ecc-mode", NULL)) {
+		ret = sunxi_nand_ecc_init(master, &part->ecc, pp);
+		if (ret)
+			goto err;
+
+		part->part.ecc = &part->ecc;
 	}
 
-	part->part.ecc = &part->ecc;
-	part->part.rnd = &part->rnd;
+	if (of_find_property(pp, "nand-rnd-mode", NULL)) {
+		ret = sunxi_nand_rnd_init(master, &part->rnd,
+				part->part.ecc ? part->part.ecc : &chip->ecc,
+				pp);
+		if (ret)
+			goto err;
+
+		part->part.rnd = &part->rnd;
+	}
 
 	return &part->part;
 
 err:
+	if (part->part.ecc)
+		sunxi_nand_ecc_cleanup(part->part.ecc);
+
 	kfree(part);
 	return ERR_PTR(ret);
 }