Module: xenomai-abe
Branch: analogy
Commit: fd94953ecc91fde7ec1e9bf1605bd6b209bbfd73
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=fd94953ecc91fde7ec1e9bf1605bd6b209bbfd73

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Sat Jun 19 00:33:01 2010 +0200

analogy: [fake - loop] remove volatile keywords

Remove the volatile keyword in front of concurrently accessed
variables and use, instead, RTDM_EXECUTE_ATOMICALLY. Maybe it is a bit
nicer even for some testing drivers.

---

 ksrc/drivers/analogy/testing/fake.c |   12 ++++++++----
 ksrc/drivers/analogy/testing/loop.c |   16 +++++++++++-----
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/ksrc/drivers/analogy/testing/fake.c 
b/ksrc/drivers/analogy/testing/fake.c
index 27d6d88..878a28f 100644
--- a/ksrc/drivers/analogy/testing/fake.c
+++ b/ksrc/drivers/analogy/testing/fake.c
@@ -29,7 +29,7 @@ struct ai_priv {
        /* Misc fields */
        unsigned long amplitude_div;
        unsigned long quanta_cnt;
-       volatile int timer_running;
+       int timer_running;
 
 };
 
@@ -115,7 +115,11 @@ static void ai_task_proc(void *arg)
        uint64_t now_ns, elapsed_ns=0;
 
        while(1) {
-               if(priv->timer_running != 0)
+               int running;
+
+               RTDM_EXECUTE_ATOMICALLY(running = priv->timer_running);
+
+               if(running)
                {
                        int i = 0;
 
@@ -168,7 +172,7 @@ static int ai_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd)
        priv->current_ns = ((unsigned long)priv->last_ns);
        priv->reminder_ns = 0;
   
-       priv->timer_running = 1;
+       RTDM_EXECUTE_ATOMICALLY(priv->timer_running = 1);
   
        return 0;
   
@@ -193,7 +197,7 @@ static int ai_cancel(a4l_subd_t *subd)
 {
        struct ai_priv *priv = (struct ai_priv *)subd->priv;
 
-       priv->timer_running = 0;
+       RTDM_EXECUTE_ATOMICALLY(priv->timer_running = 0);
 
        return 0;
 }
diff --git a/ksrc/drivers/analogy/testing/loop.c 
b/ksrc/drivers/analogy/testing/loop.c
index 72748d8..f9c4bf8 100644
--- a/ksrc/drivers/analogy/testing/loop.c
+++ b/ksrc/drivers/analogy/testing/loop.c
@@ -44,7 +44,7 @@ struct loop_priv {
        a4l_task_t loop_task;
 
        /* Misc fields */
-       volatile int loop_running:1;
+       int loop_running;
        uint16_t loop_insn_value;
 };
 typedef struct loop_priv lpprv_t;
@@ -78,8 +78,12 @@ static void loop_task_proc(void *arg)
        }
 
        while (1) {
+
+               int running;
+
+               RTDM_EXECUTE_ATOMICALLY(running = priv->loop_running);
        
-               if (priv->loop_running) {
+               if (running) {
                        uint16_t value;
                        int ret=0;
            
@@ -87,7 +91,6 @@ static void loop_task_proc(void *arg)
                
                                ret = a4l_buf_get(output_subd, 
                                                  &value, sizeof(uint16_t));
-
                                if (ret == 0) {
 
                                        a4l_info(dev, 
@@ -116,6 +119,7 @@ static void loop_task_proc(void *arg)
 int loop_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd)
 {
        a4l_info(subd->dev, "loop_cmd: (subd=%d)\n", subd->idx);  
+
        return 0;
   
 }
@@ -127,7 +131,8 @@ int loop_trigger(a4l_subd_t *subd, lsampl_t trignum)
 
        a4l_info(subd->dev, "loop_trigger: (subd=%d)\n", subd->idx);  
 
-       priv->loop_running = 1;
+       RTDM_EXECUTE_ATOMICALLY(priv->loop_running = 1);
+
        return 0;
 }
 
@@ -138,7 +143,7 @@ int loop_cancel(a4l_subd_t *subd)
 
        a4l_info(subd->dev, "loop_cancel: (subd=%d)\n", subd->idx);
 
-       priv->loop_running = 0;
+       RTDM_EXECUTE_ATOMICALLY(priv->loop_running = 0);
 
        return 0;
 }
@@ -201,6 +206,7 @@ void setup_output_subd(a4l_subd_t *subd)
        subd->rng_desc = &loop_rngdesc;
        subd->chan_desc = &loop_chandesc;
        subd->do_cmd = loop_cmd;
+       subd->cancel = loop_cancel;
        subd->trigger = loop_trigger;
        subd->cmd_mask = &loop_cmd_mask;
        subd->insn_read = loop_insn_read;


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

Reply via email to