mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-29 18:19:02 +00:00
74d00a8c38
* properly format/comment all patches * merge debloat patches * merge Kconfig patches * merge swconfig patches * merge hotplug patches * drop 200-fix_localversion.patch - upstream * drop 222-arm_zimage_none.patch - unused * drop 252-mv_cesa_depends.patch - no longer required * drop 410-mtd-move-forward-declaration-of-struct-mtd_info.patch - unused * drop 661-fq_codel_keep_dropped_stats.patch - outdated * drop 702-phy_add_aneg_done_function.patch - upstream * drop 840-rtc7301.patch - unused * drop 841-rtc_pt7c4338.patch - upstream * drop 921-use_preinit_as_init.patch - unused * drop spio-gpio-old and gpio-mmc - unused Signed-off-by: John Crispin <john@phrozen.org>
97 lines
3.1 KiB
Diff
97 lines
3.1 KiB
Diff
From 97519dc52b44af054d7654776e78eaa211cf1842 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:45 +0200
|
|
Subject: [PATCH] mtd: partitions: add support for subpartitions
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Some flash device partitions can be containers with extra subpartitions
|
|
(volumes). All callbacks are already capable of this additional level of
|
|
indirection.
|
|
|
|
This patch makes sure we always display subpartitions using a tree
|
|
structure and takes care of deleting subpartitions when parent gets
|
|
removed.
|
|
|
|
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
---
|
|
drivers/mtd/mtdpart.c | 23 ++++++++++++++++-------
|
|
1 file changed, 16 insertions(+), 7 deletions(-)
|
|
|
|
--- a/drivers/mtd/mtdpart.c
|
|
+++ b/drivers/mtd/mtdpart.c
|
|
@@ -413,7 +413,7 @@ static struct mtd_part *allocate_partiti
|
|
* parent conditional on that option. Note, this is a way to
|
|
* distinguish between the master and the partition in sysfs.
|
|
*/
|
|
- slave->mtd.dev.parent = IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER) ?
|
|
+ slave->mtd.dev.parent = IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER) || mtd_is_partition(parent) ?
|
|
&parent->dev :
|
|
parent->dev.parent;
|
|
slave->mtd.dev.of_node = part->of_node;
|
|
@@ -664,8 +664,17 @@ EXPORT_SYMBOL_GPL(mtd_add_partition);
|
|
*/
|
|
static int __mtd_del_partition(struct mtd_part *priv)
|
|
{
|
|
+ struct mtd_part *child, *next;
|
|
int err;
|
|
|
|
+ list_for_each_entry_safe(child, next, &mtd_partitions, list) {
|
|
+ if (child->parent == &priv->mtd) {
|
|
+ err = __mtd_del_partition(child);
|
|
+ if (err)
|
|
+ return err;
|
|
+ }
|
|
+ }
|
|
+
|
|
sysfs_remove_files(&priv->mtd.dev.kobj, mtd_partition_attrs);
|
|
|
|
err = del_mtd_device(&priv->mtd);
|
|
@@ -680,16 +689,16 @@ static int __mtd_del_partition(struct mt
|
|
|
|
/*
|
|
* This function unregisters and destroy all slave MTD objects which are
|
|
- * attached to the given master MTD object.
|
|
+ * attached to the given MTD object.
|
|
*/
|
|
-int del_mtd_partitions(struct mtd_info *master)
|
|
+int del_mtd_partitions(struct mtd_info *mtd)
|
|
{
|
|
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->parent == master) {
|
|
+ if (slave->parent == mtd) {
|
|
ret = __mtd_del_partition(slave);
|
|
if (ret < 0)
|
|
err = ret;
|
|
@@ -699,14 +708,14 @@ int del_mtd_partitions(struct mtd_info *
|
|
return err;
|
|
}
|
|
|
|
-int mtd_del_partition(struct mtd_info *master, int partno)
|
|
+int mtd_del_partition(struct mtd_info *mtd, int partno)
|
|
{
|
|
struct mtd_part *slave, *next;
|
|
int ret = -EINVAL;
|
|
|
|
mutex_lock(&mtd_partitions_mutex);
|
|
list_for_each_entry_safe(slave, next, &mtd_partitions, list)
|
|
- if ((slave->parent == master) &&
|
|
+ if ((slave->parent == mtd) &&
|
|
(slave->mtd.index == partno)) {
|
|
ret = __mtd_del_partition(slave);
|
|
break;
|
|
@@ -939,6 +948,6 @@ uint64_t mtd_get_device_size(const struc
|
|
if (!mtd_is_partition(mtd))
|
|
return mtd->size;
|
|
|
|
- return mtd_to_part(mtd)->parent->size;
|
|
+ return mtd_get_device_size(mtd_to_part(mtd)->parent);
|
|
}
|
|
EXPORT_SYMBOL_GPL(mtd_get_device_size);
|