All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: olpc_dcon: Replace timespec with timespec64
@ 2015-09-29 15:19 Ksenija Stanojevic
  2015-09-29 15:54 ` [Y2038] " Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Ksenija Stanojevic @ 2015-09-29 15:19 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: y2038, Ksenija Stanojevic

Struct timespec will overflow in year 2038, therefore relace it with
struct timespec64. Also replace functions getnstimeofday and timespec_sub,
which uses struct timespec, with getnstimeofday64 and timespec64_sub.

Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
---
 drivers/staging/olpc_dcon/olpc_dcon.c | 21 +++++++++++----------
 drivers/staging/olpc_dcon/olpc_dcon.h |  4 ++--
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index d115f5c..227ae0d 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -238,11 +238,11 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep)
  */
 static void dcon_load_holdoff(struct dcon_priv *dcon)
 {
-	struct timespec delta_t, now;
+	struct timespec64 delta_t, now;
 
 	while (1) {
-		getnstimeofday(&now);
-		delta_t = timespec_sub(now, dcon->load_time);
+		getnstimeofday64(&now);
+		delta_t = timespec64_sub(now, dcon->load_time);
 		if (delta_t.tv_sec != 0 ||
 			delta_t.tv_nsec > NSEC_PER_MSEC * 20) {
 			break;
@@ -325,19 +325,19 @@ static void dcon_source_switch(struct work_struct *work)
 
 		/* And turn off the DCON */
 		pdata->set_dconload(1);
-		getnstimeofday(&dcon->load_time);
+		getnstimeofday64(&dcon->load_time);
 
 		pr_info("The CPU has control\n");
 		break;
 	case DCON_SOURCE_DCON:
 	{
-		struct timespec delta_t;
+		struct timespec64 delta_t;
 
 		pr_info("dcon_source_switch to DCON\n");
 
 		/* Clear DCONLOAD - this implies that the DCON is in control */
 		pdata->set_dconload(0);
-		getnstimeofday(&dcon->load_time);
+		getnstimeofday64(&dcon->load_time);
 
 		wait_event_timeout(dcon->waitq, dcon->switched, HZ/2);
 
@@ -355,14 +355,15 @@ static void dcon_source_switch(struct work_struct *work)
 			 * deassert and reassert, and hope for the best.
 			 * see http://dev.laptop.org/ticket/9664
 			 */
-			delta_t = timespec_sub(dcon->irq_time, dcon->load_time);
+			delta_t = timespec64_sub(dcon->irq_time,
+						 dcon->load_time);
 			if (dcon->switched && delta_t.tv_sec == 0 &&
 					delta_t.tv_nsec < NSEC_PER_MSEC * 20) {
 				pr_err("missed loading, retrying\n");
 				pdata->set_dconload(1);
 				mdelay(41);
 				pdata->set_dconload(0);
-				getnstimeofday(&dcon->load_time);
+				getnstimeofday64(&dcon->load_time);
 				mdelay(41);
 			}
 		}
@@ -742,7 +743,7 @@ irqreturn_t dcon_interrupt(int irq, void *id)
 	case 2:	/* switch to DCON mode */
 	case 1: /* switch to CPU mode */
 		dcon->switched = true;
-		getnstimeofday(&dcon->irq_time);
+		getnstimeofday64(&dcon->irq_time);
 		wake_up(&dcon->waitq);
 		break;
 
@@ -756,7 +757,7 @@ irqreturn_t dcon_interrupt(int irq, void *id)
 		 */
 		if (dcon->curr_src != dcon->pending_src && !dcon->switched) {
 			dcon->switched = true;
-			getnstimeofday(&dcon->irq_time);
+			getnstimeofday64(&dcon->irq_time);
 			wake_up(&dcon->waitq);
 			pr_debug("switching w/ status 0/0\n");
 		} else {
diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h b/drivers/staging/olpc_dcon/olpc_dcon.h
index d06e19d..ccb500b 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.h
+++ b/drivers/staging/olpc_dcon/olpc_dcon.h
@@ -79,8 +79,8 @@ struct dcon_priv {
 
 	/* Variables used during switches */
 	bool switched;
-	struct timespec irq_time;
-	struct timespec load_time;
+	struct timespec64 irq_time;
+	struct timespec64 load_time;
 
 	/* Current output type; true == mono, false == color */
 	bool mono;
-- 
1.9.1



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

* Re: [Y2038] [PATCH] Staging: olpc_dcon: Replace timespec with timespec64
  2015-09-29 15:19 [PATCH] Staging: olpc_dcon: Replace timespec with timespec64 Ksenija Stanojevic
@ 2015-09-29 15:54 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2015-09-29 15:54 UTC (permalink / raw)
  To: y2038; +Cc: Ksenija Stanojevic, outreachy-kernel

On Tuesday 29 September 2015 17:19:14 Ksenija Stanojevic wrote:
> Struct timespec will overflow in year 2038, therefore relace it with
> struct timespec64. Also replace functions getnstimeofday and timespec_sub,
> which uses struct timespec, with getnstimeofday64 and timespec64_sub.
> 
> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>

Same comments as for the fbtbt patch: I'd prefer the use of ktime_get()
with ktime_t and monotonic time, over using getnstimeofday64, but the
patch looks absolutely correct otherwise.

In the changelog, you could mention that this driver does not actually
have an overflow problem, because it only looks at the result of
timespec_sub() and that works find across the overflow.

	Arnd


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

end of thread, other threads:[~2015-09-29 15:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-29 15:19 [PATCH] Staging: olpc_dcon: Replace timespec with timespec64 Ksenija Stanojevic
2015-09-29 15:54 ` [Y2038] " Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.