All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] Staging: olpc_dcon: Replace timespec with ktime_t
@ 2015-10-02 17:24 Ksenija Stanojevic
  2015-10-03  5:59 ` [Outreachy kernel] " Sudip Mukherjee
  0 siblings, 1 reply; 5+ messages in thread
From: Ksenija Stanojevic @ 2015-10-02 17:24 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: y2038, Ksenija Stanojevic

Struct timespec will overflow in year 2038, here it will not cause an
overflow because it is used with timespec_sub, but still has to be
removed as part of y2038 changes. Replace it with ktime_t. Also use
monotonic instead of real-time by replacing functions getnstimeofday
with ktime_get.

Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
Changes in v4:
	-fix checkpatch.pl errors/warnings introduced by changes made
	 in v3.

Changes in v3:
        -fix commit message (ktime_sub -> ktime_get)

Changes in v2:
        -use ktime_t instead timespec64
        -use ktime_sub instead timespec64_sub
        -use monotonic instead real-time.

 drivers/staging/olpc_dcon/olpc_dcon.c | 27 +++++++++++++--------------
 drivers/staging/olpc_dcon/olpc_dcon.h |  4 ++--
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index d115f5c..9038e0b 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -238,13 +238,12 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep)
  */
 static void dcon_load_holdoff(struct dcon_priv *dcon)
 {
-	struct timespec delta_t, now;
+	ktime_t delta_t, now;
 
 	while (1) {
-		getnstimeofday(&now);
-		delta_t = timespec_sub(now, dcon->load_time);
-		if (delta_t.tv_sec != 0 ||
-			delta_t.tv_nsec > NSEC_PER_MSEC * 20) {
+		now = ktime_get();
+		delta_t = ktime_sub(now, dcon->load_time);
+		if (ktime_to_ns(delta_t) > NSEC_PER_MSEC * 20) {
 			break;
 		}
 		mdelay(4);
@@ -325,19 +324,19 @@ static void dcon_source_switch(struct work_struct *work)
 
 		/* And turn off the DCON */
 		pdata->set_dconload(1);
-		getnstimeofday(&dcon->load_time);
+		dcon->load_time = ktime_get();
 
 		pr_info("The CPU has control\n");
 		break;
 	case DCON_SOURCE_DCON:
 	{
-		struct timespec delta_t;
+		ktime_t 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);
+		dcon->load_time = ktime_get();
 
 		wait_event_timeout(dcon->waitq, dcon->switched, HZ/2);
 
@@ -355,14 +354,14 @@ 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);
-			if (dcon->switched && delta_t.tv_sec == 0 &&
-					delta_t.tv_nsec < NSEC_PER_MSEC * 20) {
+			delta_t = ktime_sub(dcon->irq_time, dcon->load_time);
+			if (dcon->switched && ktime_to_ns(delta_t)
+			    < NSEC_PER_MSEC * 20) {
 				pr_err("missed loading, retrying\n");
 				pdata->set_dconload(1);
 				mdelay(41);
 				pdata->set_dconload(0);
-				getnstimeofday(&dcon->load_time);
+				dcon->load_time = ktime_get();
 				mdelay(41);
 			}
 		}
@@ -742,7 +741,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);
+		dcon->irq_time = ktime_get();
 		wake_up(&dcon->waitq);
 		break;
 
@@ -756,7 +755,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);
+			dcon->irq_time = ktime_get();
 			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..215e7ec 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;
+	ktime_t irq_time;
+	ktime_t load_time;
 
 	/* Current output type; true == mono, false == color */
 	bool mono;
-- 
1.9.1



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

* Re: [Outreachy kernel] [PATCH v4] Staging: olpc_dcon: Replace timespec with ktime_t
  2015-10-02 17:24 [PATCH v4] Staging: olpc_dcon: Replace timespec with ktime_t Ksenija Stanojevic
@ 2015-10-03  5:59 ` Sudip Mukherjee
  2015-10-03  6:05   ` Ksenija Stanojević
  0 siblings, 1 reply; 5+ messages in thread
From: Sudip Mukherjee @ 2015-10-03  5:59 UTC (permalink / raw)
  To: Ksenija Stanojevic; +Cc: outreachy-kernel, y2038

On Fri, Oct 02, 2015 at 07:24:05PM +0200, Ksenija Stanojevic wrote:
> Struct timespec will overflow in year 2038, here it will not cause an
> overflow because it is used with timespec_sub, but still has to be
> removed as part of y2038 changes. Replace it with ktime_t. Also use
> monotonic instead of real-time by replacing functions getnstimeofday
> with ktime_get.
> 
> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Changes in v4:
> 	-fix checkpatch.pl errors/warnings introduced by changes made
You missed one more checkpatch warning.
> 	 in v3.
<snip>
> +		delta_t = ktime_sub(now, dcon->load_time);
> +		if (ktime_to_ns(delta_t) > NSEC_PER_MSEC * 20) {
>  			break;
>  		}
braces are not required for single statement if block.

regards
sudip


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

* Re: [Outreachy kernel] [PATCH v4] Staging: olpc_dcon: Replace timespec with ktime_t
  2015-10-03  5:59 ` [Outreachy kernel] " Sudip Mukherjee
@ 2015-10-03  6:05   ` Ksenija Stanojević
  2015-10-03  6:18     ` Julia Lawall
  2015-10-03  6:39     ` Sudip Mukherjee
  0 siblings, 2 replies; 5+ messages in thread
From: Ksenija Stanojević @ 2015-10-03  6:05 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: outreachy-kernel, y2038

Hi Sudip,

On Sat, Oct 3, 2015 at 7:59 AM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> On Fri, Oct 02, 2015 at 07:24:05PM +0200, Ksenija Stanojevic wrote:
>> Struct timespec will overflow in year 2038, here it will not cause an
>> overflow because it is used with timespec_sub, but still has to be
>> removed as part of y2038 changes. Replace it with ktime_t. Also use
>> monotonic instead of real-time by replacing functions getnstimeofday
>> with ktime_get.
>>
>> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
>> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>> Changes in v4:
>>       -fix checkpatch.pl errors/warnings introduced by changes made
> You missed one more checkpatch warning.
>>        in v3.
> <snip>
>> +             delta_t = ktime_sub(now, dcon->load_time);
>> +             if (ktime_to_ns(delta_t) > NSEC_PER_MSEC * 20) {
>>                       break;
>>               }
> braces are not required for single statement if block.

I didn't know whether snould I change that or not, because that change is maybe
for another  patch?
Should I fix it  and resend?

Thanks,
Ksenija

> regards
> sudip


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

* Re: [Outreachy kernel] [PATCH v4] Staging: olpc_dcon: Replace timespec with ktime_t
  2015-10-03  6:05   ` Ksenija Stanojević
@ 2015-10-03  6:18     ` Julia Lawall
  2015-10-03  6:39     ` Sudip Mukherjee
  1 sibling, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2015-10-03  6:18 UTC (permalink / raw)
  To: Ksenija Stanojević; +Cc: Sudip Mukherjee, outreachy-kernel, y2038

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1250 bytes --]

On Sat, 3 Oct 2015, Ksenija Stanojević wrote:

> Hi Sudip,
> 
> On Sat, Oct 3, 2015 at 7:59 AM, Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> > On Fri, Oct 02, 2015 at 07:24:05PM +0200, Ksenija Stanojevic wrote:
> >> Struct timespec will overflow in year 2038, here it will not cause an
> >> overflow because it is used with timespec_sub, but still has to be
> >> removed as part of y2038 changes. Replace it with ktime_t. Also use
> >> monotonic instead of real-time by replacing functions getnstimeofday
> >> with ktime_get.
> >>
> >> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> >> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> >> ---
> >> Changes in v4:
> >>       -fix checkpatch.pl errors/warnings introduced by changes made
> > You missed one more checkpatch warning.
> >>        in v3.
> > <snip>
> >> +             delta_t = ktime_sub(now, dcon->load_time);
> >> +             if (ktime_to_ns(delta_t) > NSEC_PER_MSEC * 20) {
> >>                       break;
> >>               }
> > braces are not required for single statement if block.
> 
> I didn't know whether snould I change that or not, because that change is maybe
> for another  patch?
> Should I fix it  and resend?

I think it would be OK.

julia

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

* Re: [Outreachy kernel] [PATCH v4] Staging: olpc_dcon: Replace timespec with ktime_t
  2015-10-03  6:05   ` Ksenija Stanojević
  2015-10-03  6:18     ` Julia Lawall
@ 2015-10-03  6:39     ` Sudip Mukherjee
  1 sibling, 0 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2015-10-03  6:39 UTC (permalink / raw)
  To: Ksenija Stanojević; +Cc: outreachy-kernel, y2038

On Sat, Oct 03, 2015 at 08:05:16AM +0200, Ksenija Stanojević wrote:
> Hi Sudip,
> 
> On Sat, Oct 3, 2015 at 7:59 AM, Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> > On Fri, Oct 02, 2015 at 07:24:05PM +0200, Ksenija Stanojevic wrote:
> >> Struct timespec will overflow in year 2038, here it will not cause an
> >> overflow because it is used with timespec_sub, but still has to be
> >> removed as part of y2038 changes. Replace it with ktime_t. Also use
> >> monotonic instead of real-time by replacing functions getnstimeofday
> >> with ktime_get.
> >>
> >> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> >> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> >> ---
> >> Changes in v4:
> >>       -fix checkpatch.pl errors/warnings introduced by changes made
> > You missed one more checkpatch warning.
> >>        in v3.
> > <snip>
> >> +             delta_t = ktime_sub(now, dcon->load_time);
> >> +             if (ktime_to_ns(delta_t) > NSEC_PER_MSEC * 20) {
> >>                       break;
> >>               }
> > braces are not required for single statement if block.
> 
> I didn't know whether snould I change that or not, because that change is maybe
> for another  patch?
> Should I fix it  and resend?
Not required. Just pointed that out. Resend if Greg asks for it.

regards
sudip


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

end of thread, other threads:[~2015-10-03  6:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-02 17:24 [PATCH v4] Staging: olpc_dcon: Replace timespec with ktime_t Ksenija Stanojevic
2015-10-03  5:59 ` [Outreachy kernel] " Sudip Mukherjee
2015-10-03  6:05   ` Ksenija Stanojević
2015-10-03  6:18     ` Julia Lawall
2015-10-03  6:39     ` Sudip Mukherjee

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.