124-mtd-nand-sunxi-fallback-to-chip-config.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From de994d9c849ca0ca020fccfa1916afcde7f313f2 Mon Sep 17 00:00:00 2001
  2. From: Boris BREZILLON <boris.brezillon@free-electrons.com>
  3. Date: Sun, 24 Aug 2014 10:40:44 +0200
  4. Subject: [PATCH] mtd: nand: sunxi: Fallback to chip config when partition
  5. config is not available
  6. Fallback to chip config for partitions where ecc/rnd config are not
  7. specified in the device tree.
  8. Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
  9. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  10. ---
  11. drivers/mtd/nand/sunxi_nand.c | 27 ++++++++++++++++++---------
  12. 1 file changed, 18 insertions(+), 9 deletions(-)
  13. --- a/drivers/mtd/nand/sunxi_nand.c
  14. +++ b/drivers/mtd/nand/sunxi_nand.c
  15. @@ -1709,28 +1709,37 @@ static void sunxi_nand_part_release(stru
  16. struct nand_part *sunxi_ofnandpart_parse(void *priv, struct mtd_info *master,
  17. struct device_node *pp)
  18. {
  19. + struct nand_chip *chip = master->priv;
  20. struct sunxi_nand_part *part;
  21. int ret;
  22. part = kzalloc(sizeof(*part), GFP_KERNEL);
  23. part->part.release = sunxi_nand_part_release;
  24. - ret = sunxi_nand_ecc_init(master, &part->ecc, pp);
  25. - if (ret)
  26. - goto err;
  27. -
  28. - ret = sunxi_nand_rnd_init(master, &part->rnd, &part->ecc, pp);
  29. - if (ret) {
  30. - sunxi_nand_ecc_cleanup(&part->ecc);
  31. - goto err;
  32. + if (of_find_property(pp, "nand-ecc-mode", NULL)) {
  33. + ret = sunxi_nand_ecc_init(master, &part->ecc, pp);
  34. + if (ret)
  35. + goto err;
  36. +
  37. + part->part.ecc = &part->ecc;
  38. }
  39. - part->part.ecc = &part->ecc;
  40. - part->part.rnd = &part->rnd;
  41. + if (of_find_property(pp, "nand-rnd-mode", NULL)) {
  42. + ret = sunxi_nand_rnd_init(master, &part->rnd,
  43. + part->part.ecc ? part->part.ecc : &chip->ecc,
  44. + pp);
  45. + if (ret)
  46. + goto err;
  47. +
  48. + part->part.rnd = &part->rnd;
  49. + }
  50. return &part->part;
  51. err:
  52. + if (part->part.ecc)
  53. + sunxi_nand_ecc_cleanup(part->part.ecc);
  54. +
  55. kfree(part);
  56. return ERR_PTR(ret);
  57. }