mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 5/9] cdev: allow to open a struct cdev
Date: Wed, 10 Jul 2013 12:52:04 +0200	[thread overview]
Message-ID: <1373453528-3723-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1373453528-3723-1-git-send-email-s.hauer@pengutronix.de>

cdev_open() opens a cdev by name. This introduces cdev_do_open which
allows to open a cdev when the cdev is already found by other means.

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

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index a2bea93..816f244 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -70,6 +70,14 @@ int cdev_find_free_index(const char *basename)
 	return -EBUSY;	/* all indexes are used */
 }
 
+int cdev_do_open(struct cdev *cdev, unsigned long flags)
+{
+	if (cdev->ops->open)
+		return cdev->ops->open(cdev, flags);
+
+	return 0;
+}
+
 struct cdev *cdev_open(const char *name, unsigned long flags)
 {
 	struct cdev *cdev = cdev_by_name(name);
@@ -78,11 +86,9 @@ struct cdev *cdev_open(const char *name, unsigned long flags)
 	if (!cdev)
 		return NULL;
 
-	if (cdev->ops->open) {
-		ret = cdev->ops->open(cdev, flags);
-		if (ret)
-			return NULL;
-	}
+	ret = cdev_do_open(cdev, flags);
+	if (ret)
+		return NULL;
 
 	return cdev;
 }
diff --git a/include/driver.h b/include/driver.h
index 353af3a..7ac2eef 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -460,6 +460,7 @@ int devfs_remove(struct cdev *);
 int cdev_find_free_index(const char *);
 struct cdev *cdev_by_name(const char *filename);
 struct cdev *cdev_open(const char *name, unsigned long flags);
+int cdev_do_open(struct cdev *, unsigned long flags);
 void 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);
-- 
1.8.3.2


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

  parent reply	other threads:[~2013-07-10 10:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10 10:51 [PATCH] Allow configuration from the devicetree Sascha Hauer
2013-07-10 10:52 ` [PATCH 1/9] devfs: let devfs_add_partition return the new partition Sascha Hauer
2013-07-10 10:52 ` [PATCH 2/9] of: export of_default_bus_match_table Sascha Hauer
2013-07-10 10:52 ` [PATCH 3/9] of: partitions: factor out function to parse a single partition Sascha Hauer
2013-07-10 10:52 ` [PATCH 4/9] cdev: introduce partition names Sascha Hauer
2013-07-10 10:52 ` Sascha Hauer [this message]
2013-07-10 10:52 ` [PATCH 6/9] cdev: add device_find_partition Sascha Hauer
2013-07-10 10:52 ` [PATCH 7/9] mci: set partnames of eMMC boot partitions Sascha Hauer
2013-07-10 10:52 ` [PATCH 8/9] Add configurability via devicetree Sascha Hauer
2013-07-10 13:17   ` Jean-Christophe PLAGNIOL-VILLARD
2013-07-10 13:34     ` Sascha Hauer
2013-07-10 14:33       ` Jean-Christophe PLAGNIOL-VILLARD
2013-07-10 14:42         ` Sascha Hauer
2013-07-10 15:50           ` Jean-Christophe PLAGNIOL-VILLARD
2013-07-10 20:17             ` Sascha Hauer
2013-07-15 10:11               ` Jean-Christophe PLAGNIOL-VILLARD
2013-07-16 14:27                 ` Sascha Hauer
2013-07-10 10:52 ` [PATCH 9/9] ARM: i.MX Datamodul edmqx6: configure environment from devicetree Sascha Hauer
2013-07-11  7:37 ` [PATCH] Allow configuration from the devicetree 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=1373453528-3723-6-git-send-email-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