mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/6] cdev: make __devfs_add_partition's last argument optional
Date: Wed,  3 Jan 2024 11:16:24 +0100	[thread overview]
Message-ID: <20240103101629.2629497-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240103101629.2629497-1-a.fatoum@pengutronix.de>

Follow-up commit will expose __devfs_add_partition after rename to more
users. Most of these don't care about the last parameter, so accept
NULL to indicate that it won't be read back.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/devfs-core.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 4e16d55e367e..6abf5eacc8dd 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -478,6 +478,7 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev,
 		const struct devfs_partition *partinfo, loff_t *end)
 {
 	loff_t offset, size;
+	loff_t _end = end ? *end : 0;
 	static struct cdev *new;
 	struct cdev *overlap;
 
@@ -488,7 +489,7 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev,
 		offset = partinfo->offset;
 	else if (partinfo->offset == 0)
 		/* append to previous partition */
-		offset = *end;
+		offset = _end;
 	else
 		/* relative to end of cdev */
 		offset = cdev->size + partinfo->offset;
@@ -498,13 +499,15 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev,
 	else
 		size = cdev->size + partinfo->size - offset;
 
-	if (offset >= 0 && offset < *end)
+	if (offset >= 0 && offset < _end)
 		pr_debug("partition %s not after previous partition\n",
 				partinfo->name);
 
-	*end = offset + size;
+	_end = offset + size;
+	if (end)
+		*end = _end;
 
-	if (offset < 0 || *end > cdev->size) {
+	if (offset < 0 || _end > cdev->size) {
 		pr_warn("partition %s not completely inside device %s\n",
 				partinfo->name, cdev->name);
 		return ERR_PTR(-EINVAL);
@@ -558,7 +561,6 @@ struct cdev *devfs_add_partition(const char *devname, loff_t offset,
 		loff_t size, unsigned int flags, const char *name)
 {
 	struct cdev *cdev;
-	loff_t end = 0;
 	const struct devfs_partition partinfo = {
 		.offset = offset,
 		.size = size,
@@ -570,7 +572,7 @@ struct cdev *devfs_add_partition(const char *devname, loff_t offset,
 	if (!cdev)
 		return ERR_PTR(-ENOENT);
 
-	return __devfs_add_partition(cdev, &partinfo, &end);
+	return __devfs_add_partition(cdev, &partinfo, NULL);
 }
 
 int devfs_del_partition(const char *name)
-- 
2.39.2




  reply	other threads:[~2024-01-03 10:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03 10:16 [PATCH 0/6] cdev: delete partitions when deleting master cdev Ahmad Fatoum
2024-01-03 10:16 ` Ahmad Fatoum [this message]
2024-01-03 10:16 ` [PATCH 2/6] driver.h: move devfs_add/del_partition later in file Ahmad Fatoum
2024-01-03 10:16 ` [PATCH 3/6] cdev: export cdevfs_add_partition for general use Ahmad Fatoum
2024-01-04  8:22   ` Sascha Hauer
2024-01-04  8:51   ` [PATCH] fixup! " Ahmad Fatoum
2024-01-03 10:16 ` [PATCH 4/6] partition: switch to using cdevfs_add_partition Ahmad Fatoum
2024-01-03 10:16 ` [PATCH 5/6] cdev: export and use cdevfs_del_partition Ahmad Fatoum
2024-01-03 10:16 ` [PATCH 6/6] cdev: delete partitions when deleting master cdev Ahmad Fatoum
2024-01-08  9:59 ` [PATCH 0/6] " 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=20240103101629.2629497-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@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