Re: [PATCH v4 2/2] iio: adc: adding support for MCP3564 ADC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jonathan,

Please, see below:


> > +static int mcp3564_update_8bits(struct mcp3564_state *adc, u8 reg,
> > u32 mask, u8 val)
> > +{
> > +     u8 tmp;
> > +     int ret;
> > +
> > +     ret = mcp3564_read_8bits(adc, reg, &tmp);
> > +     if (ret < 0)
> > +             return ret;
> > +
> > +     val &= mask;
> This looks wrong - would expect this to be
>         val &= ~mask; // wipe out the bits in mask.
> > 

Actually am doing the opperation twice (the val is already correct by
using FIELD_PREP when calling mcp3564_update_8bits). I'm making sure
that the value received has only the mask bits valid.


> > +     val |= tmp & ~mask;
> and
>         val |= tmp & mask;  //write the bitss in mask.
> 
> Is the mask the inverse ?  At first glance it doesn't seem to be.
> 
> 

The tmp is the value that was read from the hardware (I need not to
touch/overwrite (~mask) bits). "tmp & ~mask" will clear the mask bits
from the hardware, in order to make the "|" with the val.

Actually my logic is a little bit twisted. I can rewrite it to be more
clear.



Thanks,
Marius




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux