From: Marek Vasut <marex@denx.de>
To: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org, Matt Ranostay <mranostay@gmail.com>,
Jonathan Cameron <jic23@kernel.org>
Subject: Re: [PATCH V2] iio: pressure: hp03: Add Hope RF HP03 sensor support
Date: Thu, 07 Apr 2016 03:39:29 +0200 [thread overview]
Message-ID: <5705BA51.4040808@denx.de> (raw)
In-Reply-To: <alpine.DEB.2.02.1604060153550.1352@pmeerw.net>
On 04/06/2016 08:04 AM, Peter Meerwald-Stadler wrote:
>> Add support for HopeRF pressure and temperature sensor.
>
> some minor comments
Thanks
[...]
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/iio/pressure/hp03.txt
>> @@ -0,0 +1,17 @@
>> +HopeRF HP03 digital pressure/temperature sensors
>> +
>> +Required properties:
>> +- compatible: must be "hoperf,hp03"
>> +- xclr-gpio: must be device tree identifier of the XCLR pin .
>
> remove space before .
> indentation seems wrong
OK, fixed now.
>> + The XCLR pin is a reset of the ADC in the chip,
>> + it must be pulled HI before the conversion and
>> + readout of the value from the ADC registers and
>> + pulled LO afterward.
>> +
>> +Example:
[...]
>> +static int hp03_read_raw(struct iio_dev *indio_dev,
>> + struct iio_chan_spec const *chan,
>> + int *val, int *val2, long mask)
>> +{
>> + struct hp03_priv *priv = iio_priv(indio_dev);
>> + int ret;
>> +
>> + mutex_lock(&priv->lock);
>> + ret = hp03_update_temp_pressure(priv);
>> + mutex_unlock(&priv->lock);
>> +
>> + if (ret)
>> + return ret;
>> +
>> + switch (mask) {
>> + case IIO_CHAN_INFO_RAW:
>> + switch (chan->type) {
>> + case IIO_PRESSURE:
>> + *val = priv->pressure / 100;
>> + *val2 = (priv->pressure % 100) * 10000;
>> + ret = IIO_VAL_INT_PLUS_MICRO;
>
> maybe return directly, here and below
Good point. Looking at the code, I think I will also need to change the
code like the snippet below. The priv->pressure is in 1Pa steps, the
priv->temp is in 0.01C steps. Does it make sense or am I confused ?
switch (mask) {
case IIO_CHAN_INFO_RAW:
switch (chan->type) {
case IIO_PRESSURE:
*val = priv->pressure;
return IIO_VAL_INT;
case IIO_TEMP:
*val = priv->temp;
return IIO_VAL_INT;
default:
return -EINVAL;
}
break;
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_PRESSURE:
*val = 1;
return IIO_VAL_INT;
case IIO_TEMP:
*val = 0;
*val2 = 10000;
return IIO_VAL_INT_PLUS_MICRO;
default:
return -EINVAL;
}
break;
default:
return -EINVAL;
}
>> + break;
>> + case IIO_TEMP:
>> + *val = priv->temp / 100;
>> + *val2 = (priv->temp % 100) * 10000;
>> + ret = IIO_VAL_INT_PLUS_MICRO;
>> + break;
>> + default:
>> + ret = -EINVAL;
>> + break;
>> + }
>> + break;
>> + case IIO_CHAN_INFO_SCALE:
>> + switch (chan->type) {
>> + case IIO_PRESSURE:
>> + case IIO_TEMP:
>> + *val = 0;
>> + *val2 = 10000;
>> + ret = IIO_VAL_INT_PLUS_MICRO;
>> + break;
>> + default:
>> + ret = -EINVAL;
>> + break;
>> + }
>> + break;
>> +
>> + default:
>> + ret = -EINVAL;
>> + break;
>> + }
>> +
>> + return ret;
>> +}
[...]
Best regards,
Marek Vasut
prev parent reply other threads:[~2016-04-07 1:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 23:40 [PATCH V2] iio: pressure: hp03: Add Hope RF HP03 sensor support Marek Vasut
2016-04-06 6:04 ` Peter Meerwald-Stadler
2016-04-07 1:39 ` Marek Vasut [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=5705BA51.4040808@denx.de \
--to=marex@denx.de \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=mranostay@gmail.com \
--cc=pmeerw@pmeerw.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.