linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Puranjay Mohan <puranjay12@gmail.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: alexandru.ardelean@analog.com,
	Jonathan Cameron <jic23@kernel.org>,
	devicetree@vger.kernel.org, knaack.h@gmx.de,
	linux-iio <linux-iio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: Re: [PATCH v3 2/2] iio: temperature: add driver support for ti tmp117
Date: Wed, 7 Apr 2021 10:43:15 +0530	[thread overview]
Message-ID: <CANk7y0gK-ObGY_u+W_15i7Lo0CjBc1+-XMaVorhJZFJW0YaVrg@mail.gmail.com> (raw)
In-Reply-To: <3d840334-2c26-5748-8370-54cef6262e02@metafoo.de>

On Wed, Apr 7, 2021 at 10:26 AM Lars-Peter Clausen <lars@metafoo.de> wrote:
>
> On 4/6/21 8:28 PM, Puranjay Mohan wrote:
> > +
> > +static int tmp117_write_raw(struct iio_dev *indio_dev,
> > +             struct iio_chan_spec const *channel, int val,
> > +             int val2, long mask)
> > +{
> > +     struct tmp117_data *data = iio_priv(indio_dev);
> > +     s16 off;
> > +
> > +     switch (mask) {
> > +     case IIO_CHAN_INFO_CALIBBIAS:
> > +             off = clamp(val, -32768, 32767);
> > +             if (off == data->calibbias)
>
> data->calibbias is only set in probe() and always 0. I'm not sure we
> need to cache the value. Reading it back from the device seems fine.
I forgot to update it, thanks for finding the bug.
Actually, I wanted to update the calibbias register only if a
different value is being written.
If the same value is written to the device repeatedly then we can save
some I2C writes using this.

and while reading the calibbias, it is read from the device only.
I will fix the bug in the next revision.

>
> > +                     return 0;
> > +             return i2c_smbus_write_word_swapped(data->client,
> > +                                             TMP117_REG_TEMP_OFFSET, off);
> > +
> > +     default:
> > +             return -EINVAL;
> > +     }
> > +}
> > +
>


-- 
Thanks and Regards

Yours Truly,

Puranjay Mohan

      reply	other threads:[~2021-04-07  5:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06 18:28 [PATCH v3 0/2] iio: temperature: add support for tmp117 Puranjay Mohan
2021-04-06 18:28 ` [PATCH v3 1/2] dt-bindings: iio: temperature: Add DT bindings for TMP117 Puranjay Mohan
2021-04-06 18:28 ` [PATCH v3 2/2] iio: temperature: add driver support for ti tmp117 Puranjay Mohan
2021-04-07  4:56   ` Lars-Peter Clausen
2021-04-07  5:13     ` Puranjay Mohan [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=CANk7y0gK-ObGY_u+W_15i7Lo0CjBc1+-XMaVorhJZFJW0YaVrg@mail.gmail.com \
    --to=puranjay12@gmail.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.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).