Module: xenomai-head
Branch: master
Commit: 2102fc0a479de828ab77e5b8134d270982f37566
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=2102fc0a479de828ab77e5b8134d270982f37566

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Tue Feb 15 22:30:38 2011 +0100

nucleus: switch completely to DEFINE_SEMAPHORE

Fix compilation issue introduced by support for 2.6.37 based I-pipe.

---

 include/asm-generic/wrappers.h |    5 +--
 ksrc/arch/generic/compat.c     |    2 +-
 ksrc/drivers/can/rtcan_dev.c   |   70 ++++++++++++++++++++--------------------
 ksrc/skins/rtdm/device.c       |    2 +-
 4 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/include/asm-generic/wrappers.h b/include/asm-generic/wrappers.h
index 69ec0e5..3554002 100644
--- a/include/asm-generic/wrappers.h
+++ b/include/asm-generic/wrappers.h
@@ -604,10 +604,9 @@ static inline void wrap_proc_dir_entry_owner(struct 
proc_dir_entry *entry)
 #define unlocked_ioctl ioctl
 #endif
 
-#ifndef DECLARE_MUTEX
+#ifndef DEFINE_SEMAPHORE
 /* Legacy DECLARE_MUTEX vanished in 2.6.37 */
-#define DECLARE_MUTEX(sem) DEFINE_SEMAPHORE(sem)
-#define init_MUTEX(sem)           sema_init((sem), 1)
+#define DEFINE_SEMAPHORE(sem) DECLARE_MUTEX(sem)
 #endif
 
 #ifdef CONFIG_GENERIC_HARDIRQS
diff --git a/ksrc/arch/generic/compat.c b/ksrc/arch/generic/compat.c
index d45a363..57d6a51 100644
--- a/ksrc/arch/generic/compat.c
+++ b/ksrc/arch/generic/compat.c
@@ -20,7 +20,7 @@ struct kthread_stop_block {
     int ret;
 };
 
-static DECLARE_MUTEX(kthread_stop_sem);
+static DEFINE_SEMAPHORE(kthread_stop_sem);
 
 static struct kthread_stop_block kthread_stop_info;
 
diff --git a/ksrc/drivers/can/rtcan_dev.c b/ksrc/drivers/can/rtcan_dev.c
index 262c1e8..c3e9e5e 100644
--- a/ksrc/drivers/can/rtcan_dev.c
+++ b/ksrc/drivers/can/rtcan_dev.c
@@ -36,9 +36,9 @@
 static struct rtcan_device *rtcan_devices[RTCAN_MAX_DEVICES];
 static rtdm_lock_t rtcan_devices_rt_lock = RTDM_LOCK_UNLOCKED;
 
-static int rtcan_global_init_done; 
+static int rtcan_global_init_done;
 
-DECLARE_MUTEX(rtcan_devices_nrt_lock);
+DEFINE_SEMAPHORE(rtcan_devices_nrt_lock);
 
 /* Spinlock for all reception lists and also for some members in
  * struct rtcan_socket */
@@ -67,9 +67,9 @@ static inline struct rtcan_device 
*__rtcan_dev_get_by_name(const char *name)
 
 
     for (i = 0; i < RTCAN_MAX_DEVICES; i++) {
-        dev = rtcan_devices[i];
-        if ((dev != NULL) && (strncmp(dev->name, name, IFNAMSIZ) == 0))
-            return dev;
+       dev = rtcan_devices[i];
+       if ((dev != NULL) && (strncmp(dev->name, name, IFNAMSIZ) == 0))
+           return dev;
     }
     return NULL;
 }
@@ -91,7 +91,7 @@ struct rtcan_device *rtcan_dev_get_by_name(const char *name)
 
 #ifdef RTCAN_USE_REFCOUNT
     if (dev != NULL)
-        atomic_inc(&dev->refcount);
+       atomic_inc(&dev->refcount);
     rtdm_lock_put_irqrestore(&rtcan_devices_rt_lock, context);
 #endif
 
@@ -114,7 +114,7 @@ struct rtcan_device *rtcan_dev_get_by_index(int ifindex)
 
 
     if ((ifindex <= 0) || (ifindex > RTCAN_MAX_DEVICES))
-        return NULL;
+       return NULL;
 
 #ifdef RTCAN_USE_REFCOUNT
     rtdm_lock_get_irqsave(&rtcan_devices_rt_lock, context);
@@ -124,7 +124,7 @@ struct rtcan_device *rtcan_dev_get_by_index(int ifindex)
 
 #ifdef RTCAN_USE_REFCOUNT
     if (dev != NULL)
-        atomic_inc(&dev->refcount);
+       atomic_inc(&dev->refcount);
     rtdm_lock_put_irqrestore(&rtcan_devices_rt_lock, context);
 #endif
 
@@ -140,14 +140,14 @@ void rtcan_dev_alloc_name(struct rtcan_device *dev, const 
char *mask)
 
 
     for (i = 0; i < RTCAN_MAX_DEVICES; i++) {
-        snprintf(buf, IFNAMSIZ, mask, i);
-        if ((tmp = rtcan_dev_get_by_name(buf)) == NULL) {
-            strncpy(dev->name, buf, IFNAMSIZ);
-            break;
-        }
+       snprintf(buf, IFNAMSIZ, mask, i);
+       if ((tmp = rtcan_dev_get_by_name(buf)) == NULL) {
+           strncpy(dev->name, buf, IFNAMSIZ);
+           break;
+       }
 #ifdef RTCAN_USE_REFCOUNT
-        else
-            rtcan_dev_dereference(tmp);
+       else
+           rtcan_dev_dereference(tmp);
 #endif
     }
 }
@@ -165,8 +165,8 @@ struct rtcan_device *rtcan_dev_alloc(int sizeof_priv, int 
sizeof_board_priv)
 
     dev = (struct rtcan_device *)kmalloc(alloc_size, GFP_KERNEL);
     if (dev == NULL) {
-        printk(KERN_ERR "rtcan: cannot allocate rtcan device\n");
-        return NULL;
+       printk(KERN_ERR "rtcan: cannot allocate rtcan device\n");
+       return NULL;
     }
 
     memset(dev, 0, alloc_size);
@@ -200,8 +200,8 @@ struct rtcan_device *rtcan_dev_alloc(int sizeof_priv, int 
sizeof_board_priv)
 void rtcan_dev_free (struct rtcan_device *dev)
 {
     if (dev != NULL) {
-        rtdm_sem_destroy(&dev->tx_sem);
-        kfree(dev);
+       rtdm_sem_destroy(&dev->tx_sem);
+       kfree(dev);
     }
 }
 
@@ -212,8 +212,8 @@ static inline int __rtcan_dev_new_index(void)
 
 
     for (i = 0; i < RTCAN_MAX_DEVICES; i++)
-        if (rtcan_devices[i] == NULL)
-             return i+1;
+       if (rtcan_devices[i] == NULL)
+            return i+1;
 
     return -ENOMEM;
 }
@@ -229,17 +229,17 @@ int rtcan_dev_register(struct rtcan_device *dev)
     rtcan_global_init();
 
     if ((ret = __rtcan_dev_new_index()) < 0) {
-        up(&rtcan_devices_nrt_lock);
-        return ret;    
+       up(&rtcan_devices_nrt_lock);
+       return ret;
     }
     dev->ifindex = ret;
 
     if (strchr(dev->name,'%') != NULL)
-        rtcan_dev_alloc_name(dev, dev->name);
+       rtcan_dev_alloc_name(dev, dev->name);
 
     if (__rtcan_dev_get_by_name(dev->name) != NULL) {
-        up(&rtcan_devices_nrt_lock);
-        return -EEXIST;
+       up(&rtcan_devices_nrt_lock);
+       return -EEXIST;
     }
 
     rtdm_lock_get_irqsave(&rtcan_devices_rt_lock, context);
@@ -263,12 +263,12 @@ int rtcan_dev_unregister(struct rtcan_device *dev)
 
 
     RTCAN_ASSERT(dev->ifindex != 0,
-                printk("RTCAN: device %s/%p was not registered\n", 
+                printk("RTCAN: device %s/%p was not registered\n",
                        dev->name, dev); return -ENODEV;);
 
     /* If device is running, close it first. */
     if (CAN_STATE_OPERATING(dev->state))
-        return -EBUSY;
+       return -EBUSY;
 
     down(&rtcan_devices_nrt_lock);
 
@@ -278,16 +278,16 @@ int rtcan_dev_unregister(struct rtcan_device *dev)
 
 #ifdef RTCAN_USE_REFCOUNT
     while (atomic_read(&dev->refcount) > 0) {
-        rtdm_lock_put_irqrestore(&rtcan_devices_rt_lock, context);
-        up(&rtcan_devices_nrt_lock);
+       rtdm_lock_put_irqrestore(&rtcan_devices_rt_lock, context);
+       up(&rtcan_devices_nrt_lock);
 
-        RTCAN_DBG("RTCAN: unregistering %s deferred (refcount = %d)\n",
+       RTCAN_DBG("RTCAN: unregistering %s deferred (refcount = %d)\n",
                  dev->name, atomic_read(&dev->refcount));
-        set_current_state(TASK_UNINTERRUPTIBLE);
-        schedule_timeout(1*HZ); /* wait a second */
+       set_current_state(TASK_UNINTERRUPTIBLE);
+       schedule_timeout(1*HZ); /* wait a second */
 
-        down(&rtcan_devices_nrt_lock);
-        rtdm_lock_get_irqsave(&rtcan_devices_rt_lock, context);
+       down(&rtcan_devices_nrt_lock);
+       rtdm_lock_get_irqsave(&rtcan_devices_rt_lock, context);
     }
 #endif
     rtcan_devices[dev->ifindex - 1] = NULL;
diff --git a/ksrc/skins/rtdm/device.c b/ksrc/skins/rtdm/device.c
index 3acc5ee..be367ed 100644
--- a/ksrc/skins/rtdm/device.c
+++ b/ksrc/skins/rtdm/device.c
@@ -61,7 +61,7 @@ static int proto_hashkey_mask;
 int rtdm_apc;
 EXPORT_SYMBOL(rtdm_apc);
 
-DECLARE_MUTEX(nrt_dev_lock);
+DEFINE_SEMAPHORE(nrt_dev_lock);
 DEFINE_XNLOCK(rt_dev_lock);
 
 #ifndef MODULE


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to