From: Lars-Peter Clausen <lars@metafoo.de>
To: Puranjay Mohan <puranjay12@gmail.com>,
alexandru.ardelean@analog.com, jic23@kernel.org,
devicetree@vger.kernel.org, knaack.h@gmx.de,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 2/2] iio: temperature: add driver support for ti tmp117
Date: Sun, 21 Mar 2021 06:23:08 +0100 [thread overview]
Message-ID: <8cdd7333-cfeb-d6af-829b-47f45fbc0eb1@metafoo.de> (raw)
In-Reply-To: <760dccc2-b098-71ce-037b-b667dbc05f57@metafoo.de>
On 3/21/21 6:07 AM, Lars-Peter Clausen wrote:
> On 3/20/21 7:45 AM, Puranjay Mohan wrote:
>> TMP117 is a Digital temperature sensor with integrated NV memory.
>>
>> Add support for tmp117 driver in iio subsystem.
>>
>> Datasheet:-https://www.ti.com/lit/gpn/tmp117
>>
>> Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
>
> This looks good to me. Just two small bits I overlooked during the
> first review, sorry for that.
>
>> +};
>> +
>> [...]
>> +static int tmp117_read_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);
>> + u16 tmp, off;
>> +
>> + switch (mask) {
>> + case IIO_CHAN_INFO_RAW:
>> + tmp = tmp117_read_reg(data, TMP117_REG_TEMP);
>> + *val = tmp;
> No need for tmp here. Just directly assign to val.
Actually thinking about this, does the current implementation work
correctly for negative temperatures?
I think there are two options to fix it. Either cast to s16 or use the
sign_extend32() function.
Have a look at how the tmp006 driver handles this. It is a good example,
including the error checking. In general you should check if your I2C
read failed and return an error in that case rather than a bogus value
for the measurement. Same for when reading the calibration offset.
Another thing. IIO reports temperature values in milli degrees Celsius.
I believe in the current implementation the scale is so that it will
report in degrees Celsius instead.
next prev parent reply other threads:[~2021-03-21 5:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-20 6:45 [PATCH v1 0/2] iio: temperature: add support for tmp117 Puranjay Mohan
2021-03-20 6:45 ` [PATCH v1 1/2] dt-bindings: iio: temperature: Add DT bindings for TMP117 Puranjay Mohan
2021-03-20 17:51 ` Jonathan Cameron
2021-03-22 0:15 ` Rob Herring
2021-03-20 6:45 ` [PATCH v1 2/2] iio: temperature: add driver support for ti tmp117 Puranjay Mohan
2021-03-20 18:15 ` Jonathan Cameron
2021-03-21 5:07 ` Lars-Peter Clausen
2021-03-21 5:23 ` Lars-Peter Clausen [this message]
[not found] ` <CAHp75VdYU1VPGEHWii77wXnwp55aUd8FZ54yhO31fs_qzmTBSQ@mail.gmail.com>
2021-03-21 11:27 ` Andy Shevchenko
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=8cdd7333-cfeb-d6af-829b-47f45fbc0eb1@metafoo.de \
--to=lars@metafoo.de \
--cc=alexandru.ardelean@analog.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=puranjay12@gmail.com \
/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).