Module: xenomai-forge Branch: next Commit: dfc9e081c676ff892bb7c932d1b4bb70d68846dc URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=dfc9e081c676ff892bb7c932d1b4bb70d68846dc
Author: Philippe Gerum <[email protected]> Date: Wed Sep 17 17:15:24 2014 +0200 cobalt/rtdm, lib/cobalt: drop support for @minor specifier in pathnames Now that every named device is backed by a regular chrdev, we need no virtual minor specification. We may just use the dev_t assigned to the associated devnode. --- include/cobalt/kernel/rtdm/driver.h | 8 ++-- include/cobalt/kernel/rtdm/fd.h | 38 +--------------- include/cobalt/kernel/rtdm/udd.h | 4 +- kernel/cobalt/rtdm/core.c | 6 +-- kernel/cobalt/rtdm/device.c | 81 ++++++++--------------------------- kernel/cobalt/rtdm/internal.h | 5 +-- kernel/drivers/udd/udd.c | 2 +- 7 files changed, 31 insertions(+), 113 deletions(-) diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h index fc0f056..9a0ace5 100644 --- a/include/cobalt/kernel/rtdm/driver.h +++ b/include/cobalt/kernel/rtdm/driver.h @@ -69,9 +69,6 @@ enum rtdm_selecttype; * application. */ #define RTDM_EXCLUSIVE 0x0001 -/** If set, the device supports minor specification. */ -#define RTDM_MINOR 0x0002 - /** If set, the device is addressed via a clear-text name. */ #define RTDM_NAMED_DEVICE 0x0010 @@ -267,7 +264,10 @@ struct rtdm_device_class { const char *provider_name; /** I/O operation handlers */ struct rtdm_fd_ops ops; - /** Count of devices which belong to this class. */ + /** + * Count of devices which belong to this class. This value is + * used to allocate a chrdev region for named devices. + */ int device_count; /** Reserved area */ struct { diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h index de440cf..6b50cef 100644 --- a/include/cobalt/kernel/rtdm/fd.h +++ b/include/cobalt/kernel/rtdm/fd.h @@ -47,43 +47,7 @@ struct xnsys_ppd; * The file descriptor carries a device minor information which can be * retrieved by a call to rtdm_fd_minor(fd). The minor number can be * used for distinguishing several instances of the same rtdm_device - * type. Prior to entering this handler, the device minor information - * may have been extracted from the path name passed to the @a open() - * call, according to the following rules: - * - * - RTDM first attempts to match the path name exactly as passed by - * the application, against the registered rtdm_device descriptors. On - * success, the special minor -1 is assigned to @a fd and this handler - * is called. - * - * - if the original path name does not match any device descriptor, - * it is scanned backward for a \<minor> suffix, which starts after - * the first non-digit character found. If present, a second lookup is - * performed in the device registry for the radix portion of the path - * name (i.e. stripping the \<minor>), looking for a device bearing - * the RTDM_MINOR flag. If found, the file descriptor is assigned the - * minor value retrieved earlier on success, at which point the - * binding succeeds and the open() handler is called. - * - * When present, \<minor> must be a positive or null decimal value, - * otherwise the open() call fails. - * - * For disambiguation, the special \@ character can be used as an - * explicit separator between the radix and the \<minor>, which is - * ignored in the final lookup for the path name. - * - * For instance, with two distinct registered devices bearing the - * RTDM_MINOR flag, namely "foo" and "foo42", lookups would resolve as - * follows: - * - * @code - * fd = open("/dev/foo0", ...); // dev = foo, rtdm_fd_minor(fd) = 0 - * fd = open("/dev/foo", ...); // dev = foo, rtdm_fd_minor(fd) = -1 - * fd = open("/dev/foo42@7", ...); // dev = foo42, rtdm_fd_minor(fd) = 7 - * fd = open("/dev/foo42", ...); // dev = foo42, rtdm_fd_minor(fd) = -1 - * @endcode - * - * @note the device minor scheme is not supported by Xenomai 2.x. + * class. * * @return 0 on success. On failure, a negative error code is returned. * diff --git a/include/cobalt/kernel/rtdm/udd.h b/include/cobalt/kernel/rtdm/udd.h index 8fae461..780c373 100644 --- a/include/cobalt/kernel/rtdm/udd.h +++ b/include/cobalt/kernel/rtdm/udd.h @@ -195,8 +195,8 @@ struct udd_device { */ const char *device_name; /** - * Additional device flags (e.g. RTDM_EXCLUSIVE, - * RTDM_MINOR. RTDM_NAMED_DEVICE may be omitted). + * Additional device flags (e.g. RTDM_EXCLUSIVE) + * RTDM_NAMED_DEVICE may be omitted). */ int device_flags; /** diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c index d46e7a0..3bf9778 100644 --- a/kernel/cobalt/rtdm/core.c +++ b/kernel/cobalt/rtdm/core.c @@ -153,7 +153,7 @@ int __rt_dev_open(struct xnsys_ppd *p, int ufd, const char *path, int oflag) { struct rtdm_dev_context *context; struct rtdm_device *device; - int ret, minor; + int ret; device = __rtdm_get_namedev(path); if (device == NULL) @@ -167,7 +167,7 @@ int __rt_dev_open(struct xnsys_ppd *p, int ufd, const char *path, int oflag) if (device->class->device_flags & RTDM_NAMED_DEVICE) context->fd.minor = device->named.minor; else - context->fd.minor = minor; + context->fd.minor = 0; trace_cobalt_fd_open(current, &context->fd, ufd, oflag); @@ -197,7 +197,7 @@ int __rt_dev_socket(struct xnsys_ppd *p, int ufd, int protocol_family, struct rtdm_device *device; int ret; - device = __rtdm_get_protocol_device(protocol_family, socket_type); + device = __rtdm_get_protodev(protocol_family, socket_type); if (device == NULL) return -EAFNOSUPPORT; diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index bbe5be0..a28699f 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -56,71 +56,39 @@ static inline void rtdm_reference_device(struct rtdm_device *device) atomic_inc(&device->refcount); } -struct rtdm_device *__rtdm_get_named_device(const char *name, int *minor_r) +struct rtdm_device *__rtdm_get_namedev(const char *path) { struct rtdm_device *device; - const char *p = NULL; - int ret, minor = -1; xnhandle_t handle; - char *base = NULL; + int ret; spl_t s; - /* - * First we look for an exact match. If this fails, we look - * for a device minor specification. If we find one, we redo - * the search only looking for the device base name. The - * default minor value if unspecified is -1. - */ - for (;;) { - ret = xnregistry_bind(name, XN_NONBLOCK, XN_RELATIVE, &handle); - if (base) - kfree(base); - if (ret != -EWOULDBLOCK) - break; - if (p) /* Look for minor only once. */ - return NULL; - p = name + strlen(name); - while (--p >= name) { - if (!isdigit(*p)) - break; - } - if (p < name) /* no minor spec. */ - return NULL; - if (p[1] == '\0') - return NULL; - ret = kstrtoint(p + 1, 10, &minor); - if (ret || minor < 0) - return NULL; - base = kstrdup(name, GFP_KERNEL); - if (base == NULL) - return NULL; - if (*p == '@') - base[p - name] = '\0'; - else - base[p - name + 1] = '\0'; - name = base; - } + /* skip common /dev prefix */ + if (strncmp(path, "/dev/", 5) == 0) + path += 5; + + /* skip RTDM devnode root */ + if (strncmp(path, "rtdm/", 5) == 0) + path += 5; + + ret = xnregistry_bind(path, XN_NONBLOCK, XN_RELATIVE, &handle); + if (ret) + return NULL; xnlock_get_irqsave(&rt_dev_lock, s); device = xnregistry_lookup(handle, NULL); - if (device) { - if (device->magic == RTDM_DEVICE_MAGIC && - ((device->class->device_flags & RTDM_MINOR) != 0 || - minor < 0)) { - rtdm_reference_device(device); - *minor_r = minor; - } else - device = NULL; - } + if (device && device->magic == RTDM_DEVICE_MAGIC) + rtdm_reference_device(device); + else + device = NULL; xnlock_put_irqrestore(&rt_dev_lock, s); return device; } -struct rtdm_device * -__rtdm_get_protocol_device(int protocol_family, int socket_type) +struct rtdm_device *__rtdm_get_protodev(int protocol_family, int socket_type) { struct rtdm_device *device = NULL; struct xnid *xnid; @@ -142,19 +110,6 @@ __rtdm_get_protocol_device(int protocol_family, int socket_type) return device; } -struct rtdm_device *__rtdm_get_namedev(const char *path) -{ - /* skip common /dev prefix */ - if (strncmp(path, "/dev/", 5) == 0) - path += 5; - - /* skip RTDM devnode root */ - if (strncmp(path, "rtdm/", 5) == 0) - path += 5; - - return __rtdm_get_named_device(path); -} - /** * @ingroup rtdm_driver_interface * @defgroup rtdm_device_register Device Registration Services diff --git a/kernel/cobalt/rtdm/internal.h b/kernel/cobalt/rtdm/internal.h index f6ab158..06c78a6 100644 --- a/kernel/cobalt/rtdm/internal.h +++ b/kernel/cobalt/rtdm/internal.h @@ -42,9 +42,6 @@ extern struct semaphore nrt_dev_lock; extern struct list_head rtdm_named_devices; extern struct rb_root rtdm_protocol_devices; -struct rtdm_device *__rtdm_get_named_device(const char *name, int *minor_r); -struct rtdm_device *__rtdm_get_protocol_device(int protocol_family, int socket_type); - static inline void rtdm_dereference_device(struct rtdm_device *device) { atomic_dec(&device->refcount); @@ -79,6 +76,8 @@ int __rtdm_mmap_from_fdop(struct rtdm_fd *fd, size_t len, off_t offset, struct rtdm_device *__rtdm_get_namedev(const char *path); +struct rtdm_device *__rtdm_get_protodev(int protocol_family, int socket_type); + int rtdm_init(void); void rtdm_cleanup(void); diff --git a/kernel/drivers/udd/udd.c b/kernel/drivers/udd/udd.c index 894e3f5..59420b9 100644 --- a/kernel/drivers/udd/udd.c +++ b/kernel/drivers/udd/udd.c @@ -291,7 +291,7 @@ static inline int register_mapper(struct udd_device *udd) class->profile_info = (struct rtdm_profile_info) RTDM_PROFILE_INFO("mapper", RTDM_CLASS_MEMORY, RTDM_SUBCLASS_GENERIC, 0); - class->device_flags = RTDM_NAMED_DEVICE|RTDM_MINOR; + class->device_flags = RTDM_NAMED_DEVICE; class->device_count = UDD_NR_MAPS; class->ops = (struct rtdm_fd_ops){ .open = mapper_open, _______________________________________________ Xenomai-git mailing list [email protected] http://www.xenomai.org/mailman/listinfo/xenomai-git
