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

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Tue Jan  5 01:27:05 2010 +0100

analogy: do not check the range if no range descriptor is found

---

 ksrc/drivers/analogy/subdevice.c |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/ksrc/drivers/analogy/subdevice.c b/ksrc/drivers/analogy/subdevice.c
index b1ea01d..2d7811d 100644
--- a/ksrc/drivers/analogy/subdevice.c
+++ b/ksrc/drivers/analogy/subdevice.c
@@ -82,16 +82,13 @@ a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int 
rngidx)
 int a4l_check_chanlist(a4l_subd_t * subd,
                       unsigned char nb_chan, unsigned int *chans)
 {
-       int i;
+       int i, j;
 
        if (nb_chan > subd->chan_desc->length)
                return -EINVAL;
 
        for (i = 0; i < nb_chan; i++) {
-               int j = (subd->rng_desc->mode != 
-                        A4L_RNG_GLOBAL_RNGDESC) ? i : 0;
-               int k = (subd->chan_desc->mode !=
-                        A4L_CHAN_GLOBAL_CHANDESC) ? i : 0;
+               j = (subd->chan_desc->mode != A4L_CHAN_GLOBAL_CHANDESC) ? i : 0;
 
                if (CR_CHAN(chans[i]) >= subd->chan_desc->length) {
                        __a4l_err("a4l_check_chanlist: "
@@ -99,6 +96,21 @@ int a4l_check_chanlist(a4l_subd_t * subd,
                                  CR_CHAN(chans[i]), subd->chan_desc->length);
                        return -EINVAL;
                }
+               if (CR_AREF(chans[i]) != 0 &&
+                   (CR_AREF(chans[i]) & subd->chan_desc->chans[j].flags) == 0)
+               {
+                       __a4l_err("a4l_check_chanlist: "
+                                 "bad channel type\n");
+                       return -EINVAL;
+               }
+       }
+
+       if (subd->rng_desc == NULL)
+               return 0;
+
+       for (i = 0; i < nb_chan; i++) {
+               j = (subd->rng_desc->mode != A4L_RNG_GLOBAL_RNGDESC) ? i : 0;
+
                if (CR_RNG(chans[i]) > subd->rng_desc->rngtabs[j]->length) {
                        __a4l_err("a4l_check_chanlist: "
                                  "rng idx out_of range (%u>=%u)\n",
@@ -106,13 +118,6 @@ int a4l_check_chanlist(a4l_subd_t * subd,
                                  subd->rng_desc->rngtabs[j]->length);
                        return -EINVAL;
                }
-               if (CR_AREF(chans[i]) != 0 &&
-                   (CR_AREF(chans[i]) & subd->chan_desc->chans[k].flags) == 0)
-               {
-                       __a4l_err("a4l_check_chanlist: "
-                                 "bad channel type\n");
-                       return -EINVAL;
-               }
        }
 
        return 0;


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

Reply via email to