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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Apr 10 11:41:15 2014 +0200

drivers/can: move to new-style atomic sections

---

 kernel/drivers/can/rtcan_raw.c    |   13 ++++++++-----
 kernel/drivers/can/rtcan_socket.c |   13 ++++++-------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/kernel/drivers/can/rtcan_raw.c b/kernel/drivers/can/rtcan_raw.c
index 960b7a6..d3cb88a 100644
--- a/kernel/drivers/can/rtcan_raw.c
+++ b/kernel/drivers/can/rtcan_raw.c
@@ -800,6 +800,7 @@ ssize_t rtcan_raw_sendmsg(struct rtdm_dev_context *context,
     struct rtcan_device *dev;
     int ifindex = 0;
     int ret  = 0;
+    spl_t s;
 
 
     if (flags & MSG_OOB)   /* Mirror BSD error message compatibility */
@@ -912,8 +913,9 @@ ssize_t rtcan_raw_sendmsg(struct rtdm_dev_context *context,
     /* If socket was not closed recently, register the task at the
      * socket's TX wait queue and decrement the TX semaphore. This must be
      * atomic. Finally, the task must be deregistered again (also atomic). */
-    RTDM_EXECUTE_ATOMICALLY(
-       if (likely(!test_bit(RTDM_CLOSING, &context->context_flags))) {
+    cobalt_atomic_enter(s);
+
+    if (likely(!test_bit(RTDM_CLOSING, &context->context_flags))) {
 
            list_add(&tx_wait.tx_wait_list, &sock->tx_wait_head);
 
@@ -929,10 +931,11 @@ ssize_t rtcan_raw_sendmsg(struct rtdm_dev_context 
*context,
                /* The socket was closed. */
                ret = -EBADF;
 
-       } else
+    } else
        /* The socket was closed. */
-       ret = -EBADF;
-       );
+           ret = -EBADF;
+
+    cobalt_atomic_leave(s);
 
     /* Error code returned? */
     if (ret != 0) {
diff --git a/kernel/drivers/can/rtcan_socket.c 
b/kernel/drivers/can/rtcan_socket.c
index d78d1f6..141a8bf 100644
--- a/kernel/drivers/can/rtcan_socket.c
+++ b/kernel/drivers/can/rtcan_socket.c
@@ -74,12 +74,11 @@ void rtcan_socket_cleanup(struct rtdm_dev_context *context)
 
     /* Wake up sleeping senders. This is re-entrant-safe. */
     do {
-       RTDM_EXECUTE_ATOMICALLY(
-           /* Is someone there? */
-           if (list_empty(&sock->tx_wait_head))
+       cobalt_atomic_enter(lock_ctx);
+       /* Is someone there? */
+       if (list_empty(&sock->tx_wait_head))
                tx_list_empty = 1;
-
-           else {
+       else {
                tx_list_empty = 0;
 
                /* Get next entry pointing to a waiting task */
@@ -91,8 +90,8 @@ void rtcan_socket_cleanup(struct rtdm_dev_context *context)
 
                /* Wake task up (atomic section is left implicitly) */
                rtdm_task_unblock(tx_waiting->rt_task);
-           }
-       );
+       }
+       cobalt_atomic_leave(lock_ctx);
     } while (!tx_list_empty);
 
     rtdm_sem_destroy(&sock->recv_sem);


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

Reply via email to