openwrtv4/target/linux/sunxi/patches-4.1/124-mtd-nand-sunxi-fallback-to-chip-config.patch
Hauke Mehrtens da94b00df5 kernel: update kernel 4.1 to version 4.1.11
https://www.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.1.11

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

SVN-Revision: 47252
2015-10-25 17:32:01 +00:00

65 lines
1.8 KiB
Diff

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);
}