comedi_find_range() should skip ranges that don't match specified units.
authorIan Abbott <abbotti@mev.co.uk>
Wed, 17 Feb 2010 18:28:15 +0000 (18:28 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Wed, 17 Feb 2010 18:28:15 +0000 (18:28 +0000)
lib/range.c

index 361ac6802555cddb3dd14ebc5f73e6f88a9fffca..d3f74be9e21657ebecf6c47c8d1efcb401952a7f 100644 (file)
@@ -111,7 +111,7 @@ int _comedi_find_range(comedi_t *it,unsigned int subd,unsigned int chan,unsigned
        best_ptr=NULL;
        for(i=0;i<RANGE_LENGTH(range_type);i++){
                range_ptr=comedi_get_range(it,subd,chan,i);
-               if(range_ptr->min<=min && range_ptr->max>=max){
+               if(range_ptr->unit==unit && range_ptr->min<=min && range_ptr->max>=max){
                        if(best<0 || (range_ptr->max-range_ptr->min) < 
                           (best_ptr->max-best_ptr->min)){
                                best=i;