Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2018-07-09 18:43:31 +0800
committerColy Li <colyli@suse.de>2018-07-09 18:43:41 +0800
commit4ce874e08e1c57f815cfefa8f40e525f4cb4d0b6 (patch)
treed85e7e89b225c93fd282d37b9df931e4da563b63
parent5258c8af12f832c9df05d3c6079c05f41deb4ae0 (diff)
mtd: partitions: add helper for deleting partition
(bsc#1099918).
-rw-r--r--patches.suse/0001-mtd-partitions-add-helper-for-deleting-partition.patch125
-rw-r--r--series.conf1
2 files changed, 126 insertions, 0 deletions
diff --git a/patches.suse/0001-mtd-partitions-add-helper-for-deleting-partition.patch b/patches.suse/0001-mtd-partitions-add-helper-for-deleting-partition.patch
new file mode 100644
index 0000000000..0f13561617
--- /dev/null
+++ b/patches.suse/0001-mtd-partitions-add-helper-for-deleting-partition.patch
@@ -0,0 +1,125 @@
+From 08263a9ae664b24fa777d20b365601534842b236 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Wed, 21 Jun 2017 08:26:42 +0200
+Subject: [PATCH] mtd: partitions: add helper for deleting partition
+Git-commit: 08263a9ae664b24fa777d20b365601534842b236
+Patch-mainline: v4.13-rc1
+References: bsc#1099918
+
+There are two similar functions handling deletion. One handles single
+partition and another the whole MTD flash device. They share (duplicate)
+some code so it makes sense to add a small helper for that part.
+
+Function del_mtd_partitions has been moved a bit to keep all deleting
+stuff together.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
+Signed-off-by: Coly Li <colyli@suse.de>
+---
+ drivers/mtd/mtdpart.c | 75 +++++++++++++++++++++++++------------------
+ 1 file changed, 43 insertions(+), 32 deletions(-)
+
+diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
+index 7ececd3d7799..bcec72148d0b 100644
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -363,32 +363,6 @@ static inline void free_partition(struct mtd_part *p)
+ kfree(p);
+ }
+
+-/*
+- * This function unregisters and destroy all slave MTD objects which are
+- * attached to the given master MTD object.
+- */
+-
+-int del_mtd_partitions(struct mtd_info *master)
+-{
+- struct mtd_part *slave, *next;
+- int ret, err = 0;
+-
+- mutex_lock(&mtd_partitions_mutex);
+- list_for_each_entry_safe(slave, next, &mtd_partitions, list)
+- if (slave->master == master) {
+- ret = del_mtd_device(&slave->mtd);
+- if (ret < 0) {
+- err = ret;
+- continue;
+- }
+- list_del(&slave->list);
+- free_partition(slave);
+- }
+- mutex_unlock(&mtd_partitions_mutex);
+-
+- return err;
+-}
+-
+ static struct mtd_part *allocate_partition(struct mtd_info *master,
+ const struct mtd_partition *part, int partno,
+ uint64_t cur_offset)
+@@ -675,6 +649,48 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
+ }
+ EXPORT_SYMBOL_GPL(mtd_add_partition);
+
++/**
++ * __mtd_del_partition - delete MTD partition
++ *
++ * @priv: internal MTD struct for partition to be deleted
++ *
++ * This function must be called with the partitions mutex locked.
++ */
++static int __mtd_del_partition(struct mtd_part *priv)
++{
++ int err;
++
++ err = del_mtd_device(&priv->mtd);
++ if (err)
++ return err;
++
++ list_del(&priv->list);
++ free_partition(priv);
++
++ return 0;
++}
++
++/*
++ * This function unregisters and destroy all slave MTD objects which are
++ * attached to the given master MTD object.
++ */
++int del_mtd_partitions(struct mtd_info *master)
++{
++ struct mtd_part *slave, *next;
++ int ret, err = 0;
++
++ mutex_lock(&mtd_partitions_mutex);
++ list_for_each_entry_safe(slave, next, &mtd_partitions, list)
++ if (slave->master == master) {
++ ret = __mtd_del_partition(slave);
++ if (ret < 0)
++ err = ret;
++ }
++ mutex_unlock(&mtd_partitions_mutex);
++
++ return err;
++}
++
+ int mtd_del_partition(struct mtd_info *master, int partno)
+ {
+ struct mtd_part *slave, *next;
+@@ -686,12 +702,7 @@ int mtd_del_partition(struct mtd_info *master, int partno)
+ (slave->mtd.index == partno)) {
+ sysfs_remove_files(&slave->mtd.dev.kobj,
+ mtd_partition_attrs);
+- ret = del_mtd_device(&slave->mtd);
+- if (ret < 0)
+- break;
+-
+- list_del(&slave->list);
+- free_partition(slave);
++ ret = __mtd_del_partition(slave);
+ break;
+ }
+ mutex_unlock(&mtd_partitions_mutex);
+--
+2.17.1
+
diff --git a/series.conf b/series.conf
index 65f9ec08ae..472ed1b20f 100644
--- a/series.conf
+++ b/series.conf
@@ -15916,6 +15916,7 @@
patches.drivers/bnxt_en-Fix-bug-in-ethtool-L.patch
patches.drivers/bnxt_en-Fix-SRIOV-on-big-endian-architecture.patch
patches.fixes/net-hns-Bugfix-for-Tx-timeout-handling-in-hns-driver.patch
+ patches.suse/0001-mtd-partitions-add-helper-for-deleting-partition.patch
patches.drivers/mlx5-Avoid-that-mlx5_ib_sg_to_klms-overflows-the-klm.patch
patches.drivers/IB-core-Add-ordered-workqueue-for-RoCE-GID-managemen.patch
patches.drivers/xgene-sp3-0024-xgene-Don-t-fail-probe-if-there-is-no-clk-resource-f.patch