]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.4
authorSasha Levin <sashal@kernel.org>
Sun, 11 Oct 2020 21:31:39 +0000 (17:31 -0400)
committerSasha Levin <sashal@kernel.org>
Sun, 11 Oct 2020 21:31:39 +0000 (17:31 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.4/mtd-nand-provide-nand_cleanup-function-to-free-nand-.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/mtd-nand-provide-nand_cleanup-function-to-free-nand-.patch b/queue-4.4/mtd-nand-provide-nand_cleanup-function-to-free-nand-.patch
new file mode 100644 (file)
index 0000000..5550e06
--- /dev/null
@@ -0,0 +1,95 @@
+From e5ff569730ff0bb3007c1f24247d48b15695c88c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 21 Sep 2016 11:44:41 +0200
+Subject: mtd: nand: Provide nand_cleanup() function to free NAND related
+ resources
+
+From: Richard Weinberger <richard@nod.at>
+
+[ Upstream commit d44154f969a44269a9288c274c1c2fd9e85df8a5 ]
+
+Provide a nand_cleanup() function to free all nand related resources
+without unregistering the mtd device.
+This should allow drivers to call mtd_device_unregister() and handle
+its return value and still being able to cleanup all nand related
+resources.
+
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
+Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mtd/nand/nand_base.c | 22 +++++++++++++++-------
+ include/linux/mtd/nand.h     |  6 +++++-
+ 2 files changed, 20 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
+index 8406f346b0be5..09864226428b2 100644
+--- a/drivers/mtd/nand/nand_base.c
++++ b/drivers/mtd/nand/nand_base.c
+@@ -4427,18 +4427,14 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
+ EXPORT_SYMBOL(nand_scan);
+ /**
+- * nand_release - [NAND Interface] Free resources held by the NAND device
+- * @mtd: MTD device structure
++ * nand_cleanup - [NAND Interface] Free resources held by the NAND device
++ * @chip: NAND chip object
+  */
+-void nand_release(struct mtd_info *mtd)
++void nand_cleanup(struct nand_chip *chip)
+ {
+-      struct nand_chip *chip = mtd->priv;
+-
+       if (chip->ecc.mode == NAND_ECC_SOFT_BCH)
+               nand_bch_free((struct nand_bch_control *)chip->ecc.priv);
+-      mtd_device_unregister(mtd);
+-
+       /* Free bad block table memory */
+       kfree(chip->bbt);
+       if (!(chip->options & NAND_OWN_BUFFERS))
+@@ -4449,6 +4445,18 @@ void nand_release(struct mtd_info *mtd)
+                       & NAND_BBT_DYNAMICSTRUCT)
+               kfree(chip->badblock_pattern);
+ }
++EXPORT_SYMBOL_GPL(nand_cleanup);
++
++/**
++ * nand_release - [NAND Interface] Unregister the MTD device and free resources
++ *              held by the NAND device
++ * @mtd: MTD device structure
++ */
++void nand_release(struct mtd_info *mtd)
++{
++      mtd_device_unregister(mtd);
++      nand_cleanup(mtd->priv);
++}
+ EXPORT_SYMBOL_GPL(nand_release);
+ static int __init nand_base_init(void)
+diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
+index 93fc372007937..1a066faf7b801 100644
+--- a/include/linux/mtd/nand.h
++++ b/include/linux/mtd/nand.h
+@@ -38,7 +38,7 @@ extern int nand_scan_ident(struct mtd_info *mtd, int max_chips,
+                          struct nand_flash_dev *table);
+ extern int nand_scan_tail(struct mtd_info *mtd);
+-/* Free resources held by the NAND device */
++/* Unregister the MTD device and free resources held by the NAND device */
+ extern void nand_release(struct mtd_info *mtd);
+ /* Internal helper for board drivers which need to override command function */
+@@ -1029,4 +1029,8 @@ int nand_check_erased_ecc_chunk(void *data, int datalen,
+                               void *ecc, int ecclen,
+                               void *extraoob, int extraooblen,
+                               int threshold);
++
++/* Free resources held by the NAND device */
++void nand_cleanup(struct nand_chip *chip);
++
+ #endif /* __LINUX_MTD_NAND_H */
+-- 
+2.25.1
+
index a4b2940d5386883b6af39869c87d09a448b3c42b..4e8747fdd9db18010660c89e4a87cf798773d85b 100644 (file)
@@ -27,3 +27,4 @@ perf-top-fix-stdio-interface-input-handling-with-glibc-2.28.patch
 sctp-fix-sctp_auth_init_hmacs-error-path.patch
 team-set-dev-needed_headroom-in-team_setup_by_port.patch
 net-team-fix-memory-leak-in-__team_options_register.patch
+mtd-nand-provide-nand_cleanup-function-to-free-nand-.patch