Module: xenomai-forge Branch: next Commit: 39f5b354a088eb006f2e3bf5a3573079fad617d2 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=39f5b354a088eb006f2e3bf5a3573079fad617d2
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 | 40 ++---------------------- include/cobalt/kernel/rtdm/udd.h | 4 +-- kernel/cobalt/rtdm/core.c | 6 ++-- kernel/cobalt/rtdm/device.c | 57 ++++++----------------------------- kernel/cobalt/rtdm/internal.h | 2 +- kernel/drivers/udd/udd.c | 2 +- 7 files changed, 23 insertions(+), 96 deletions(-) diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h index f6b3c92..ebb70cd 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..7598ffb 100644 --- a/include/cobalt/kernel/rtdm/fd.h +++ b/include/cobalt/kernel/rtdm/fd.h @@ -47,43 +47,9 @@ 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. + * + * @note device minors are not supported by Xenomai 2.x. * * @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 b15505f..a1e8efc 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; /* skip common /dev prefix */ if (strncmp(path, "/dev/", 5) == 0) @@ -163,7 +163,7 @@ int __rt_dev_open(struct xnsys_ppd *p, int ufd, const char *path, int oflag) if (strncmp(path, "rtdm/", 5) == 0) path += 5; - device = __rtdm_get_named_device(path, &minor); + device = __rtdm_get_named_device(path); if (device == NULL) return -ENODEV; @@ -175,7 +175,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); diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 39d42b0..246650c 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -56,63 +56,24 @@ 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_named_device(const char *name) { 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; - } + ret = xnregistry_bind(name, 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); diff --git a/kernel/cobalt/rtdm/internal.h b/kernel/cobalt/rtdm/internal.h index 985e01f..68050fc 100644 --- a/kernel/cobalt/rtdm/internal.h +++ b/kernel/cobalt/rtdm/internal.h @@ -42,7 +42,7 @@ 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_named_device(const char *name); struct rtdm_device *__rtdm_get_protocol_device(int protocol_family, int socket_type); static inline void rtdm_dereference_device(struct rtdm_device *device) 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
