From: Greg Gallagher <greg@embeddedgreg.com>
To: xenomai@xenomai.org
Subject: [Xenomai] [PATCH 2/3] Handle device paths from the device tree that start with a forward slash
Date: Tue, 30 Jan 2018 21:36:20 -0500 [thread overview]
Message-ID: <1517366181-6547-2-git-send-email-greg@embeddedgreg.com> (raw)
In-Reply-To: <1517366181-6547-1-git-send-email-greg@embeddedgreg.com>
If the device name from the device tree starts with a forward slash (/) the
rtdm device stores it in the registry including the forward slash. When we
go to use that device and do the registry lookup we use a relative path from
/dev/rtdm which doesn't contain the forward slash and fails to find a match.
Open won't return an error but IO calls will fail. To fix this when we
register an RTDM device skip the first character if it's a forward slash.
In my case the path from the device tree is
/amba_pl/gpio@41200000/gpio905
which gets stored in the registry. When we want to use the device and look up
the device path in the registry we use
amba_pl/gpio@41200000/gpio905
which won't find a match in the registry.
Tested on Zynq7000 gpio drivers
---
kernel/cobalt/rtdm/device.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 4533dfb..89e0815 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -91,9 +91,12 @@ struct rtdm_device *__rtdm_get_namedev(const char *path)
if (strncmp(path, "rtdm/", 5) == 0)
path += 5;
+ printk(KERN_ERR "path to bind %s\n", path);
ret = xnregistry_bind(path, XN_NONBLOCK, XN_RELATIVE, &handle);
- if (ret)
+ if (ret) {
+ printk(KERN_ERR "xnreg bind fail %d\n", ret);
return NULL;
+ }
mutex_lock(®ister_lock);
@@ -394,6 +397,7 @@ int rtdm_dev_register(struct rtdm_device *dev)
int ret, major, minor;
xnkey_t id;
dev_t rdev;
+ const char *dev_name;
secondary_mode_only();
@@ -446,8 +450,12 @@ int rtdm_dev_register(struct rtdm_device *dev)
ret = -ENOMEM;
goto fail;
}
-
- ret = xnregistry_enter(dev->name, dev,
+ if (dev->name[0] == '/') {
+ dev_name = dev->name+1;
+ } else {
+ dev_name = dev->name;
+ }
+ ret = xnregistry_enter(dev_name, dev,
&dev->named.handle, NULL);
if (ret)
goto fail;
--
2.7.4
next prev parent reply other threads:[~2018-01-31 2:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-31 2:36 [Xenomai] [PATCH 1/3] Add Xilinx AXI gpio driver Greg Gallagher
2018-01-31 2:36 ` Greg Gallagher [this message]
2018-02-01 10:29 ` [Xenomai] [PATCH 2/3] Handle device paths from the device tree that start with a forward slash Philippe Gerum
2018-02-01 15:21 ` Greg Gallagher
2018-01-31 2:36 ` [Xenomai] [PATCH 3/3] Allow for more then one rt gpio driver to be built and loaded at the same build Greg Gallagher
2018-02-01 10:30 ` Philippe Gerum
2018-02-01 15:20 ` Greg Gallagher
2018-02-01 10:26 ` [Xenomai] [PATCH 1/3] Add Xilinx AXI gpio driver Philippe Gerum
-- strict thread matches above, loose matches on Subject: below --
2018-02-02 2:23 Greg Gallagher
2018-02-02 2:23 ` [Xenomai] [PATCH 2/3] Handle device paths from the device tree that start with a forward slash Greg Gallagher
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=1517366181-6547-2-git-send-email-greg@embeddedgreg.com \
--to=greg@embeddedgreg.com \
--cc=xenomai@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.