diff mbox

[v2] hwmon: (sht3x) set initial jiffies to last_update

Message ID 1469405132-7044-1-git-send-email-mranostay@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Matt Ranostay July 25, 2016, 12:05 a.m. UTC
Handling the wraparound requires the data->last_update to be set to an
initial jiffies value. Otherwise on 32-bit systems you will not be able
to request a reading till the 5 minute jiffies rollover happens.

Cc: Guenter Roeck <linux@roeck-us.net>
Cc: David Frey <david.frey@sensirion.com>
Signed-off-by: Matt Ranostay <mranostay@gmail.com>
---

Changes from v1:
 * document more in commit message the reason for the patch
 * mark last sample before driver load so initial reading can happen
   shortly after boot

 drivers/hwmon/sht3x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jean Delvare July 25, 2016, 8:49 a.m. UTC | #1
On Sun, 24 Jul 2016 17:05:32 -0700, Matt Ranostay wrote:
> Handling the wraparound requires the data->last_update to be set to an
> initial jiffies value. Otherwise on 32-bit systems you will not be able
> to request a reading till the 5 minute jiffies rollover happens.
> 
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: David Frey <david.frey@sensirion.com>
> Signed-off-by: Matt Ranostay <mranostay@gmail.com>
> ---
> 
> Changes from v1:
>  * document more in commit message the reason for the patch
>  * mark last sample before driver load so initial reading can happen
>    shortly after boot
> 
>  drivers/hwmon/sht3x.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
> index b73a48832732..6ea99cd6ae79 100644
> --- a/drivers/hwmon/sht3x.c
> +++ b/drivers/hwmon/sht3x.c
> @@ -720,7 +720,7 @@ static int sht3x_probe(struct i2c_client *client,
>  	data->setup.blocking_io = false;
>  	data->setup.high_precision = true;
>  	data->mode = 0;
> -	data->last_update = 0;
> +	data->last_update = jiffies - msecs_to_jiffies(3000);
>  	data->client = client;
>  	crc8_populate_msb(sht3x_crc8_table, SHT3X_CRC8_POLYNOMIAL);
>  

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Guenter Roeck July 25, 2016, 2:42 p.m. UTC | #2
On 07/24/2016 05:05 PM, Matt Ranostay wrote:
> Handling the wraparound requires the data->last_update to be set to an
> initial jiffies value. Otherwise on 32-bit systems you will not be able
> to request a reading till the 5 minute jiffies rollover happens.
>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: David Frey <david.frey@sensirion.com>
> Signed-off-by: Matt Ranostay <mranostay@gmail.com>

Applied.

Thanks,
Guenter

> ---
>
> Changes from v1:
>   * document more in commit message the reason for the patch
>   * mark last sample before driver load so initial reading can happen
>     shortly after boot
>
>   drivers/hwmon/sht3x.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
> index b73a48832732..6ea99cd6ae79 100644
> --- a/drivers/hwmon/sht3x.c
> +++ b/drivers/hwmon/sht3x.c
> @@ -720,7 +720,7 @@ static int sht3x_probe(struct i2c_client *client,
>   	data->setup.blocking_io = false;
>   	data->setup.high_precision = true;
>   	data->mode = 0;
> -	data->last_update = 0;
> +	data->last_update = jiffies - msecs_to_jiffies(3000);
>   	data->client = client;
>   	crc8_populate_msb(sht3x_crc8_table, SHT3X_CRC8_POLYNOMIAL);
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
index b73a48832732..6ea99cd6ae79 100644
--- a/drivers/hwmon/sht3x.c
+++ b/drivers/hwmon/sht3x.c
@@ -720,7 +720,7 @@  static int sht3x_probe(struct i2c_client *client,
 	data->setup.blocking_io = false;
 	data->setup.high_precision = true;
 	data->mode = 0;
-	data->last_update = 0;
+	data->last_update = jiffies - msecs_to_jiffies(3000);
 	data->client = client;
 	crc8_populate_msb(sht3x_crc8_table, SHT3X_CRC8_POLYNOMIAL);