for(i=0;i<n_ranges;i++){
range = comedi_get_range(dev,subdev,0,i);
if( is_bipolar( dev, subdev, 0, i ) == 0 ) continue;
+ if(range->unit == UNIT_none ) continue;
if(range->max>max){
ret = i;
max=range->max;
for(i=0;i<n_ranges;i++){
range = comedi_get_range(dev,subdev,0,i);
if( is_bipolar( dev, subdev, 0, i ) == 0 ) continue;
+ if(range->unit == UNIT_none ) continue;
if(range->max<min){
ret = i;
min=range->max;
for(i=0;i<n_ranges;i++){
range = comedi_get_range(dev,subdev,0,i);
if( is_unipolar( dev, subdev, 0, i ) == 0 ) continue;
+ if(range->unit == UNIT_none ) continue;
if(range->max>max){
ret = i;
max=range->max;
for(i=0;i<n_ranges;i++){
range = comedi_get_range(dev,subdev,0,i);
if( is_unipolar( dev, subdev, 0, i ) == 0 ) continue;
+ if(range->unit == UNIT_none ) continue;
if(range->max < max){
ret = i;
max=range->max;