Module: xenomai-forge
Branch: next
Commit: a2773c49c590dff3bf683842df8b499ad3044d06
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=a2773c49c590dff3bf683842df8b499ad3044d06

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Sep 22 12:21:32 2014 +0200

cobalt/rtdm: cope with legacy sysfs attribute definition

---

 .../cobalt/include/asm-generic/xenomai/wrappers.h  |   16 ++++++++++-
 kernel/cobalt/rtdm/device.c                        |   28 +++++++++++++++++---
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index b954406..ccebb48 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -28,9 +28,23 @@
 #error "CONFIG_IPIPE_LEGACY must be switched off"
 #endif
 
+/*
+ * To keep the #ifdefery as readable as possible, please:
+ *
+ * - keep the conditional structure flat, no nesting (e.g. do not nest
+ *   the pre-3.11 conditions into the pre-3.14 ones).
+ * - group all wrappers which share the same condition.
+ */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
+#define DEVICE_ATTR_RW(_name)  __ATTR_RW(_name)
+#define DEVICE_ATTR_RO(_name)  __ATTR_RO(_name)
+#define DEVICE_ATTR_WO(_name)  __ATTR_WO(_name)
+#endif /* < 3.11 */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,14,0)
 #define get_current_uuid() current_uid()
-#else
+#else /* >= 3.14 */
 #define get_current_uuid() from_kuid_munged(current_user_ns(), current_uid())
 #endif
 
diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index 9697be9..40df644 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -148,7 +148,6 @@ static ssize_t profile_show(struct device *kdev,
                       dev->driver->profile_info.class_id,
                       dev->driver->profile_info.subclass_id);
 }
-static DEVICE_ATTR_RO(profile);
 
 static ssize_t refcount_show(struct device *kdev,
                             struct device_attribute *attr, char *buf)
@@ -157,7 +156,6 @@ static ssize_t refcount_show(struct device *kdev,
 
        return sprintf(buf, "%d\n", atomic_read(&dev->refcount));
 }
-static DEVICE_ATTR_RO(refcount);
 
 #define cat_count(__buf, __str)                        \
        ({                                      \
@@ -175,7 +173,6 @@ static ssize_t flags_show(struct device *kdev,
        return sprintf(buf, "%#x\n", drv->device_flags);
 
 }
-static DEVICE_ATTR_RO(flags);
 
 static ssize_t type_show(struct device *kdev,
                         struct device_attribute *attr, char *buf)
@@ -192,6 +189,12 @@ static ssize_t type_show(struct device *kdev,
        return ret;
 
 }
+
+#ifdef ATTRIBUTE_GROUPS
+
+static DEVICE_ATTR_RO(profile);
+static DEVICE_ATTR_RO(refcount);
+static DEVICE_ATTR_RO(flags);
 static DEVICE_ATTR_RO(type);
 
 static struct attribute *rtdm_attrs[] = {
@@ -203,6 +206,25 @@ static struct attribute *rtdm_attrs[] = {
 };
 ATTRIBUTE_GROUPS(rtdm);
 
+#else /* !ATTRIBUTE_GROUPS */
+
+/*
+ * Cope with legacy sysfs attributes. Scheduled for removal when 3.10
+ * is at EOL for us.
+ */
+static struct device_attribute rtdm_attrs[] = {
+       DEVICE_ATTR_RO(profile),
+       DEVICE_ATTR_RO(refcount),
+       DEVICE_ATTR_RO(flags),
+       DEVICE_ATTR_RO(type),
+       __ATTR_NULL 
+};
+
+#define dev_groups   dev_attrs
+#define rtdm_groups  rtdm_attrs
+
+#endif /* !ATTRIBUTE_GROUPS */
+
 static int register_driver(struct rtdm_driver *drv)
 {
        dev_t rdev;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to