aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ath79/files
diff options
context:
space:
mode:
authorDavid Bauer <mail@david-bauer.net>2021-02-17 22:12:43 +0100
committerDavid Bauer <mail@david-bauer.net>2021-02-20 01:26:22 +0100
commitfb64e2c30f0cba887d3b183ce52de36b3e8bbb7e (patch)
tree1cc7c1aba2fb05a97babb1f37969ca6c1355b319 /target/linux/ath79/files
parentda55758cc58a2e6f0570eacd4bb9c2d4792572a6 (diff)
downloadupstream-fb64e2c30f0cba887d3b183ce52de36b3e8bbb7e.tar.gz
upstream-fb64e2c30f0cba887d3b183ce52de36b3e8bbb7e.tar.bz2
upstream-fb64e2c30f0cba887d3b183ce52de36b3e8bbb7e.zip
ath79: ar934x-nand: add kernel 5.10 compatibility
Adapt the driver to make it work with the NAND subsystem changes between kernel 5.4 and 5.10. Tested-on: Aerohive HiveAP121 Signed-off-by: David Bauer <mail@david-bauer.net>
Diffstat (limited to 'target/linux/ath79/files')
-rw-r--r--target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c b/target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c
index 5f0026b475..207bcd59ac 100644
--- a/target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c
+++ b/target/linux/ath79/files/drivers/mtd/nand/raw/ar934x_nand.c
@@ -14,6 +14,9 @@
#include <linux/module.h>
#include <linux/dma-mapping.h>
#include <linux/mtd/mtd.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
+#include <linux/mtd/nand.h>
+#endif
#include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h>
#include <linux/platform_device.h>
@@ -719,7 +722,11 @@ static void ar934x_nfc_cmdfunc(struct nand_chip *nand, unsigned int command,
break;
case NAND_CMD_PAGEPROG:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
+ if (nand->ecc.engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) {
+#else
if (nand->ecc.mode == NAND_ECC_HW) {
+#endif
/* the data is already written */
break;
}
@@ -1325,15 +1332,29 @@ static int ar934x_nfc_attach_chip(struct nand_chip *nand)
if (ret)
return ret;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
+ if (nand->ecc.engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) {
+#else
if (nand->ecc.mode == NAND_ECC_HW) {
+#endif
ret = ar934x_nfc_setup_hwecc(nfc);
if (ret)
return ret;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
+ } else if (nand->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT) {
+ dev_err(dev, "unknown ECC mode %d\n", nand->ecc.engine_type);
+#else
} else if (nand->ecc.mode != NAND_ECC_SOFT) {
dev_err(dev, "unknown ECC mode %d\n", nand->ecc.mode);
+#endif
return -EINVAL;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
+ } else if ((nand->ecc.algo != NAND_ECC_ALGO_BCH) &&
+ (nand->ecc.algo != NAND_ECC_ALGO_HAMMING)) {
+#else
} else if ((nand->ecc.algo != NAND_ECC_BCH) &&
(nand->ecc.algo != NAND_ECC_HAMMING)) {
+#endif
dev_err(dev, "unknown software ECC algo %d\n", nand->ecc.algo);
return -EINVAL;
}
@@ -1422,7 +1443,11 @@ static int ar934x_nfc_probe(struct platform_device *pdev)
nand->legacy.read_byte = ar934x_nfc_read_byte;
nand->legacy.write_buf = ar934x_nfc_write_buf;
nand->legacy.read_buf = ar934x_nfc_read_buf;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)
+ nand->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST; /* default */
+#else
nand->ecc.mode = NAND_ECC_HW; /* default */
+#endif
nand->priv = nfc;
platform_set_drvdata(pdev, nfc);
@@ -1462,7 +1487,12 @@ static int ar934x_nfc_remove(struct platform_device *pdev)
nfc = platform_get_drvdata(pdev);
if (nfc) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)
+ mtd_device_unregister(nand_to_mtd(&nfc->nand_chip));
+ nand_cleanup(&nfc->nand_chip);
+#else
nand_release(&nfc->nand_chip);
+#endif
ar934x_nfc_free_buf(nfc);
}