lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9e81a4bb1afcf5a36a0a0ec90a149020c9c0cbdf.camel@microchip.com>
Date:   Tue, 29 Aug 2023 08:22:15 +0000
From:   <Marius.Cristea@...rochip.com>
To:     <jic23@...nel.org>
CC:     <devicetree@...r.kernel.org>, <conor+dt@...nel.org>,
        <krzysztof.kozlowski+dt@...aro.org>, <lars@...afoo.de>,
        <linux-iio@...r.kernel.org>, <robh+dt@...nel.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 2/2] iio: adc: adding support for MCP3564 ADC

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ