fixed bug that was preventing read insn from being emulated by insn_emulate_bits()
authorFrank Mori Hess <fmhess@speakeasy.net>
Fri, 30 Mar 2001 20:18:14 +0000 (20:18 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Fri, 30 Mar 2001 20:18:14 +0000 (20:18 +0000)
comedi/drivers.c

index f4b7d980a8846eaa37ba6874bfa2a330f1c356ed..aa82e91bc9e03db2537361235d45c523d074a45d 100644 (file)
@@ -468,7 +468,11 @@ static int insn_emulate_bits(comedi_device *dev,comedi_subdevice *s,
                        return -EINVAL;
                new_data[0] = 1<<chan; /* mask */
                new_data[1] = data[0]?(1<<chan):0; /* bits */
-       }else{
+       }else if(insn->insn == INSN_READ){
+               if(!(s->subdev_flags & SDF_READABLE))
+                       return -EINVAL;
+               data[0] = (new_data[1]>>chan)&1;
+       }else {
                new_data[0] = 0;
                new_data[1] = 0;
        }
@@ -476,12 +480,6 @@ static int insn_emulate_bits(comedi_device *dev,comedi_subdevice *s,
        ret = s->insn_bits(dev,s,&new_insn,new_data);
        if(ret<0)return ret;
 
-       if(insn->insn == INSN_READ){
-               if(!(s->subdev_flags & SDF_WRITEABLE))
-                       return -EINVAL;
-               data[0] = (new_data[1]>>chan)&1;
-       }
-
        return 1;
 }