[PATCH linux dev-4.10 2/2] drivers/iio: dps310 Use previous value if new reading not available yet

Christopher Bostic cbostic at linux.vnet.ibm.com
Tue Jul 25 12:19:43 AEST 2017

On 7/24/17 8:31 PM, Joel Stanley wrote:
> 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.

I had thought there was consensus in the Sunday night (Central US time) 
meeting on using the old value in case where a new measurement wasn't 
ready.  I see your point that we'd not know if the last measurement was 
days old.   Maybe we can take some time in Tuesday night's meeting to 
discuss further.

> 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