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;
}
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;
}