[PATCH linux dev-4.10 2/2] drivers/iio: dps310 Use previous value if new reading not available yet
Joel Stanley
joel at jms.id.au
Tue Jul 25 11:31:45 AEST 2017
On Tue, Jul 25, 2017 at 6:55 AM, Christopher Bostic
<cbostic at linux.vnet.ibm.com> wrote:
> In cases where temperature is queried before the latest value is finished
> reading then use the previously measured value instead of returning error.
>
> Signed-off-by: Christopher Bostic <cbostic at linux.vnet.ibm.com>
> ---
> drivers/iio/pressure/dps310.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c
> index f351c26..c7ee99e 100644
> --- a/drivers/iio/pressure/dps310.c
> +++ b/drivers/iio/pressure/dps310.c
> @@ -202,8 +202,8 @@ static int dps310_read_temp(struct dps310_data *data)
> if (r < 0)
> return r;
> if (!(ready & DPS310_TMP_RDY)) {
> - dev_dbg(dev, "temperature not ready\n");
> - return -EAGAIN;
> + dev_dbg(dev, "temperature not ready, use last temp value\n");
> + return 0;
We can't hide these errors in the kernel driver. The user of this API
will have no way of knowing if it actually has a new value, or if the
value is days old. In the extreme case, the driver may nave never
received a value from the hardware, but we will happily report zero.
If you want to go down the path of using old values, there's a defined
iio API for doing triggered readings that put data into a timestamped
buffer of values. This could be used by userspace when it needs a
reading, regardless of it's age. I've not used this before so it would
require further investigation to decide if it's useful.
Alternatively, if the userspace application doesn't care about the
latest value then it could cache the previously read value and use
that.
Cheers,
Joel
More information about the openbmc
mailing list