mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 10/14] fs: devfs-core: replace DEVFS_PARTITION_FIXED flag with pointer to the master cdev
Date: Fri, 31 Mar 2017 07:33:19 +0200	[thread overview]
Message-ID: <20170331053323.17821-11-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170331053323.17821-1-s.hauer@pengutronix.de>

Instead of having a flag indicating a cdev is a partition on
some master cdev, just add a master pointer to the cdev, so
that we can also find out who the master is.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/base/driver.c   | 2 +-
 drivers/mtd/partition.c | 1 +
 fs/devfs-core.c         | 6 +++---
 include/driver.h        | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 5867fe45d0..83260990af 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -221,7 +221,7 @@ int unregister_device(struct device_d *old_dev)
 	}
 
 	list_for_each_entry_safe(cdev, ct, &old_dev->cdevs, devices_list) {
-		if (cdev->flags & DEVFS_IS_PARTITION) {
+		if (cdev->master) {
 			dev_dbg(old_dev, "unregister part %s\n", cdev->name);
 			devfs_del_partition(cdev->name);
 		}
diff --git a/drivers/mtd/partition.c b/drivers/mtd/partition.c
index 745834384f..2bdbef9227 100644
--- a/drivers/mtd/partition.c
+++ b/drivers/mtd/partition.c
@@ -226,6 +226,7 @@ struct mtd_info *mtd_add_partition(struct mtd_info *mtd, off_t offset,
 		goto err;
 
 	part->cdev.offset = offset;
+	part->cdev.master = &part->master->cdev;
 
 	return part;
 err:
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 7b3754ed8e..382606f1cf 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -37,7 +37,7 @@ int devfs_partition_complete(struct string_list *sl, char *instr)
 	len = strlen(instr);
 
 	list_for_each_entry(cdev, &cdev_list, list) {
-		if (cdev->flags & DEVFS_IS_PARTITION &&
+		if (cdev->master &&
 		    !strncmp(instr, cdev->name, len)) {
 			string_list_add_asprintf(sl, "%s ", cdev->name);
 		}
@@ -326,7 +326,7 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev,
 	new->offset = cdev->offset + offset;
 
 	new->dev = cdev->dev;
-	new->flags = partinfo->flags | DEVFS_IS_PARTITION;
+	new->master = cdev;
 
 	list_add_tail(&new->partition_entry, &cdev->partitions);
 
@@ -368,7 +368,7 @@ int devfs_del_partition(const char *name)
 		return ret;
 	}
 
-	if (!(cdev->flags & DEVFS_IS_PARTITION))
+	if (!cdev->master)
 		return -EINVAL;
 	if (cdev->flags & DEVFS_PARTITION_FIXED)
 		return -EPERM;
diff --git a/include/driver.h b/include/driver.h
index b7eaf290c4..2af66fe345 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -460,6 +460,7 @@ struct cdev {
 	struct cdev *link;
 	struct list_head link_entry, links;
 	struct list_head partition_entry, partitions;
+	struct cdev *master;
 };
 
 int devfs_create(struct cdev *);
@@ -482,7 +483,6 @@ int cdev_erase(struct cdev *cdev, loff_t count, loff_t offset);
 
 #define DEVFS_PARTITION_FIXED		(1U << 0)
 #define DEVFS_PARTITION_READONLY	(1U << 1)
-#define DEVFS_IS_PARTITION		(1 << 2)
 #define DEVFS_IS_CHARACTER_DEV		(1 << 3)
 
 struct cdev *devfs_add_partition(const char *devname, loff_t offset,
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2017-03-31  5:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-31  5:33 OF partitions rework Sascha Hauer
2017-03-31  5:33 ` [PATCH 01/14] of: Add of_property_write_string() Sascha Hauer
2017-03-31  5:33 ` [PATCH 02/14] treewide: Use of_property_write_string() where appropriate Sascha Hauer
2017-03-31  5:33 ` [PATCH 03/14] of: partition: Move of_mtd_fixup to drivers/of/ Sascha Hauer
2017-03-31  5:33 ` [PATCH 04/14] mtd: of: Make used partition binding configurable Sascha Hauer
2017-03-31  5:33 ` [PATCH 05/14] of: partition: support 64bit partition sizes Sascha Hauer
2017-03-31  5:33 ` [PATCH 06/14] mtd: partition: set cdev->offset to the actual offset Sascha Hauer
2017-03-31  8:46   ` Sascha Hauer
2017-03-31  5:33 ` [PATCH 07/14] cdev: Collect partitions on list Sascha Hauer
2017-03-31  5:33 ` [PATCH 08/14] of: partition: Make partition fixup independent from mtd devices Sascha Hauer
2017-03-31  5:33 ` [PATCH 09/14] fs: devfs-core: remove unused code Sascha Hauer
2017-03-31  5:33 ` Sascha Hauer [this message]
2017-03-31  5:33 ` [PATCH 11/14] of: partition: only create partition node when partitions exist Sascha Hauer
2017-03-31  5:33 ` [PATCH 12/14] of: partitions: flag partitions from a partition table Sascha Hauer
2017-03-31  5:33 ` [PATCH 13/14] of: partition: Register the of partition fixup for of partition users Sascha Hauer
2017-03-31  5:33 ` [PATCH 14/14] of: of_path: add of_find_node_by_devpath() Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170331053323.17821-11-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox