devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Marius.Cristea@microchip.com>
To: <jic23@kernel.org>
Cc: <devicetree@vger.kernel.org>, <conor+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <lars@metafoo.de>,
	<linux-iio@vger.kernel.org>, <robh+dt@kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/2] iio: adc: adding support for MCP3564 ADC
Date: Tue, 29 Aug 2023 08:22:15 +0000	[thread overview]
Message-ID: <9e81a4bb1afcf5a36a0a0ec90a149020c9c0cbdf.camel@microchip.com> (raw)
In-Reply-To: <20230828151631.6a60282b@jic23-huawei>

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

      parent reply	other threads:[~2023-08-29  8:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 16:57 [PATCH v4 0/2] Adding support for Microchip MCP3564 ADC family marius.cristea
2023-08-18 16:57 ` [PATCH v4 1/2] dt-bindings: iio: adc: adding MCP3564 ADC marius.cristea
2023-08-19  8:25   ` Conor Dooley
2023-08-18 16:57 ` [PATCH v4 2/2] iio: adc: adding support for " marius.cristea
2023-08-28 14:16   ` Jonathan Cameron
2023-08-29  7:29     ` Marius.Cristea
2023-08-29 11:34       ` Jonathan Cameron
2023-08-29  8:22     ` Marius.Cristea [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9e81a4bb1afcf5a36a0a0ec90a149020c9c0cbdf.camel@microchip.com \
    --to=marius.cristea@microchip.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).