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 1/7] fs: move cdev open count to cdev_open()/cdev_close()
Date: Thu, 15 Feb 2024 08:47:51 +0100	[thread overview]
Message-ID: <20240215074757.960200-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240215074757.960200-1-s.hauer@pengutronix.de>

All code opening a cdev goes through cdev_open(), so open counting
must be done there and not in devfs_open() which itself only calls
cdev_open().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/devfs-core.c | 13 +++++++++++--
 fs/devfs.c      |  4 ----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index c7187e3c01..87d4591d99 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -175,8 +175,15 @@ int cdev_find_free_index(const char *basename)
 
 int cdev_open(struct cdev *cdev, unsigned long flags)
 {
-	if (cdev->ops->open)
-		return cdev->ops->open(cdev, flags);
+	int ret;
+
+	if (cdev->ops->open) {
+		ret = cdev->ops->open(cdev, flags);
+		if (ret)
+			return ret;
+	}
+
+	cdev->open++;
 
 	return 0;
 }
@@ -221,6 +228,8 @@ void cdev_close(struct cdev *cdev)
 {
 	if (cdev->ops->close)
 		cdev->ops->close(cdev);
+
+	cdev->open--;
 }
 
 ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
diff --git a/fs/devfs.c b/fs/devfs.c
index c30ae4f384..c8ddbbdab0 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -114,8 +114,6 @@ static int devfs_open(struct device *_dev, FILE *f, const char *filename)
 			return ret;
 	}
 
-	cdev->open++;
-
 	return 0;
 }
 
@@ -130,8 +128,6 @@ static int devfs_close(struct device *_dev, FILE *f)
 			return ret;
 	}
 
-	cdev->open--;
-
 	return 0;
 }
 
-- 
2.39.2




  reply	other threads:[~2024-02-15  7:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15  7:47 [PATCH 0/7] Detect partition changes at runtime Sascha Hauer
2024-02-15  7:47 ` Sascha Hauer [this message]
2024-02-15  7:47 ` [PATCH 2/7] common: partitions: efi: fix memory leak Sascha Hauer
2024-02-15  7:47 ` [PATCH 3/7] partition: allow to reparse a partition table Sascha Hauer
2024-02-15 11:07   ` Marco Felsch
2024-02-16 11:14     ` Sascha Hauer
2024-02-15  7:47 ` [PATCH 4/7] block: reparse partition table when necessary Sascha Hauer
2024-02-15 12:52   ` Marco Felsch
2024-02-16 11:16     ` Sascha Hauer
2024-02-15  7:47 ` [PATCH 5/7] fastboot: pass list to fb_addvar() Sascha Hauer
2024-02-15  7:47 ` [PATCH 6/7] fastboot: add function to free a list of fastboot variables Sascha Hauer
2024-02-15  7:47 ` [PATCH 7/7] fastboot: evaluate fastboot partitions when used Sascha Hauer
2024-02-15 12:51   ` Marco Felsch
2024-02-16 11:15     ` Sascha Hauer
2024-02-15  8:31 ` [PATCH 0/7] Detect partition changes at runtime Ahmad Fatoum
2024-02-15 12:54 ` Marco Felsch
2024-02-16 11:13 ` 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=20240215074757.960200-2-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