From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: uol@pengutronix.de, ske@pengutronix.de,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 1/3] cdev: return error code from cdev_close
Date: Wed, 15 May 2024 10:05:05 +0200 [thread overview]
Message-ID: <20240515080507.4056255-1-a.fatoum@pengutronix.de> (raw)
cdev_operations::close can fail and thus cdev_close should pass along
the error code to the users instead of discarding it.
Do that, so users like devfs close() can start propagating this error.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/devfs-core.c | 11 ++++++++---
include/driver.h | 2 +-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 376c62be9eab..21e5c2dc969a 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -224,12 +224,17 @@ struct cdev *cdev_open_by_name(const char *name, unsigned long flags)
return cdev;
}
-void cdev_close(struct cdev *cdev)
+int cdev_close(struct cdev *cdev)
{
- if (cdev->ops->close)
- cdev->ops->close(cdev);
+ if (cdev->ops->close) {
+ int ret = cdev->ops->close(cdev);
+ if (ret)
+ return ret;
+ }
cdev->open--;
+
+ return 0;
}
ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
diff --git a/include/driver.h b/include/driver.h
index 5a3e46e99e14..3401ab4f07f4 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -529,7 +529,7 @@ struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset);
void cdev_remove_loop(struct cdev *cdev);
int cdev_open(struct cdev *, unsigned long flags);
int cdev_fdopen(struct cdev *cdev, unsigned long flags);
-void cdev_close(struct cdev *cdev);
+int cdev_close(struct cdev *cdev);
int cdev_flush(struct cdev *cdev);
ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags);
ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags);
--
2.39.2
next reply other threads:[~2024-05-15 8:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 8:05 Ahmad Fatoum [this message]
2024-05-15 8:05 ` [PATCH master 2/3] fs: devfs: restore cdev reference count maintenance Ahmad Fatoum
2024-05-15 8:05 ` [PATCH master 3/3] partition: reparse tables only if CONFIG_PARTITION_MANIPULATION=y Ahmad Fatoum
2024-05-15 9:24 ` [PATCH] fixup! " Ahmad Fatoum
2024-05-16 7:13 ` [PATCH master 1/3] cdev: return error code from cdev_close 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=20240515080507.4056255-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=ske@pengutronix.de \
--cc=uol@pengutronix.de \
/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