[PATCH master 1/3] cdev: return error code from cdev_close

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux