Re: [PATCH v2 3/5] hwmon: (tmp102) Improve handling of initial read delay
From: Nishanth Menon
Date: Sun Jun 26 2016 - 09:32:40 EST
On 06/25/2016 09:40 PM, Guenter Roeck wrote:
[...]
> /* convert left adjusted 13-bit TMP102 register value to milliCelsius */
> @@ -78,8 +82,16 @@ static struct tmp102 *tmp102_update_device(struct device *dev)
> struct tmp102 *tmp102 = dev_get_drvdata(dev);
> struct i2c_client *client = tmp102->client;
>
> + /* Is it too early to return a conversion ? */
> + if (time_before(jiffies, tmp102->ready_time)) {
> + unsigned long sleeptime = tmp102->ready_time - jiffies;
> +
> + msleep(jiffies_to_msecs(sleeptime));
> + }
> +
While msleep can indeed work and simplify, in case of usage for
example with thermal framework, if the data is not ready and we return
-EAGAIN, it lets the thermal framework go and read other sensors
instead of being blocked on the tmp102 conversion of data.
Eduardo, Rui: what is your view on this approach?
Patch: https://patchwork.kernel.org/patch/9198961/
--
Regards,
Nishanth Menon