linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] misc: bmp085: Handle jiffies overflow correctly
@ 2012-02-19 17:28 Bernhard Walle
  2012-02-20 12:10 ` Arnd Bergmann
  2012-02-24 22:18 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Bernhard Walle @ 2012-02-19 17:28 UTC (permalink / raw)
  To: christoph.mair; +Cc: arnd, gregkh, linux-kernel

By using the time_is_before_jiffies() macro instead of normal
arithmetic, the jiffies overflow is handled correctly.

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
---
 drivers/misc/bmp085.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index b29a2be..7cfc598 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -234,7 +234,8 @@ static s32 bmp085_get_pressure(struct bmp085_data *data, int *pressure)
 	int status;
 
 	/* alt least every second force an update of the ambient temperature */
-	if (data->last_temp_measurement + 1*HZ < jiffies) {
+	if (data->last_temp_measurement == 0 ||
+			time_is_before_jiffies(data->last_temp_measurement + 1*HZ)) {
 		status = bmp085_get_temperature(data, NULL);
 		if (status != 0)
 			goto exit;
-- 
1.7.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] misc: bmp085: Handle jiffies overflow correctly
  2012-02-19 17:28 [PATCH] misc: bmp085: Handle jiffies overflow correctly Bernhard Walle
@ 2012-02-20 12:10 ` Arnd Bergmann
  2012-02-24 22:18 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2012-02-20 12:10 UTC (permalink / raw)
  To: Bernhard Walle; +Cc: christoph.mair, gregkh, linux-kernel

On Sunday 19 February 2012, Bernhard Walle wrote:
> By using the time_is_before_jiffies() macro instead of normal
> arithmetic, the jiffies overflow is handled correctly.
> 
> Signed-off-by: Bernhard Walle <bernhard@bwalle.de>

Acked-by: Arnd Bergmann <arnd@arndb.de>

BTW, what is the future of this driver? Are there
plans to move it over to the the industrial I/O
framework?

	Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] misc: bmp085: Handle jiffies overflow correctly
  2012-02-19 17:28 [PATCH] misc: bmp085: Handle jiffies overflow correctly Bernhard Walle
  2012-02-20 12:10 ` Arnd Bergmann
@ 2012-02-24 22:18 ` Greg KH
  2012-02-25  9:28   ` [PATCH] misc: bmp085: Use unsigned long to store jiffies Bernhard Walle
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2012-02-24 22:18 UTC (permalink / raw)
  To: Bernhard Walle; +Cc: christoph.mair, arnd, linux-kernel

On Sun, Feb 19, 2012 at 06:28:01PM +0100, Bernhard Walle wrote:
> By using the time_is_before_jiffies() macro instead of normal
> arithmetic, the jiffies overflow is handled correctly.
> 
> Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/misc/bmp085.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
> index b29a2be..7cfc598 100644
> --- a/drivers/misc/bmp085.c
> +++ b/drivers/misc/bmp085.c
> @@ -234,7 +234,8 @@ static s32 bmp085_get_pressure(struct bmp085_data *data, int *pressure)
>  	int status;
>  
>  	/* alt least every second force an update of the ambient temperature */
> -	if (data->last_temp_measurement + 1*HZ < jiffies) {
> +	if (data->last_temp_measurement == 0 ||
> +			time_is_before_jiffies(data->last_temp_measurement + 1*HZ)) {

This causes a complier warning:
drivers/misc/bmp085.c: In function ‘bmp085_get_pressure’:
drivers/misc/bmp085.c:238:4: warning: comparison of distinct pointer types lacks a cast [enabled by default]

Care to send me a follow-on patch that fixes this?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] misc: bmp085: Use unsigned long to store jiffies
  2012-02-24 22:18 ` Greg KH
@ 2012-02-25  9:28   ` Bernhard Walle
  0 siblings, 0 replies; 4+ messages in thread
From: Bernhard Walle @ 2012-02-25  9:28 UTC (permalink / raw)
  To: gregkh; +Cc: christoph.mair, arnd, linux-kernel

This fixes following compilation warning:

drivers/misc/bmp085.c: In function ‘bmp085_get_pressure’:
drivers/misc/bmp085.c:238:4: warning: comparison of distinct pointer
         types lacks a cast [enabled by default]

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
---
 drivers/misc/bmp085.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index b088abc..76c3064 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -87,7 +87,7 @@ struct bmp085_data {
 	u32 raw_temperature;
 	u32 raw_pressure;
 	unsigned char oversampling_setting;
-	u32 last_temp_measurement;
+	unsigned long last_temp_measurement;
 	s32 b6; /* calculated temperature correction coefficient */
 };
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-25  9:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-19 17:28 [PATCH] misc: bmp085: Handle jiffies overflow correctly Bernhard Walle
2012-02-20 12:10 ` Arnd Bergmann
2012-02-24 22:18 ` Greg KH
2012-02-25  9:28   ` [PATCH] misc: bmp085: Use unsigned long to store jiffies Bernhard Walle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).