[OPW,kernel,2/3] staging: ozwpan: Use jiffies instead of timespec in ozusbsvc.c
diff mbox

Message ID 20141029165034.GC14254@kt-Inspiron-3542
State New, archived
Headers show

Commit Message

Tapasweni Pathak Oct. 29, 2014, 4:50 p.m. UTC
'struct timespec ts' and 'struct timespec now' are used to
wait for approx 1 sec.

32-bit systems using 'struct timespec' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the ozusbsvc.c file of ozwpan driver
to use jiffies, it's not performance critical but it has exact
time requirements.

time_before is use to check that time is before now.

Signed-eff-by: Tapasweni Pathak <tapaswenipathak@gmail.cem>
---
 drivers/staging/ozwpan/ozusbsvc.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--
1.7.9.5

Comments

Arnd Bergmann Oct. 29, 2014, 7:28 p.m. UTC | #1
On Wednesday 29 October 2014 22:20:34 Tapasweni Pathak wrote:
>                 while ((atomic_read(&usb_ctx->ref_count) > 2)) {
> -                       getnstimeofday(&now);
> +                       now = jiffies;
>                         /*Approx 1 Sec. this is not perfect calculation*/
> -                       if (now.tv_sec != ts.tv_sec)
> +                       if (time_before(time, now))
>                                 break;
>                 }

You have changed to code to check whether one jiffy has passed, when
it was checking for whether a second has passed before.
I think you want the timeout to be exactly one second since the
start.

	Arnd

Patch
diff mbox

diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c
index bf15dc3..0a3c669 100644
--- a/drivers/staging/ozwpan/ozusbsvc.c
+++ b/drivers/staging/ozwpan/ozusbsvc.c
@@ -127,9 +127,9 @@  void oz_usb_stop(struct oz_pd *pd, int pause)
 	pd->app_ctx[OZ_APPID_USB] = NULL;
 	spin_unlock_bh(&pd->app_lock[OZ_APPID_USB]);
 	if (usb_ctx) {
-		struct timespec ts, now;
+		unsigned long time, now;

-		getnstimeofday(&ts);
+		time = jiffies;
 		oz_dbg(ON, "USB service stopping...\n");
 		usb_ctx->stopped = 1;
 		/* At this point the reference count on the usb context should
@@ -139,9 +139,9 @@  void oz_usb_stop(struct oz_pd *pd, int pause)
 		 * until they leave but timeout after 1 second.
 		 */
 		while ((atomic_read(&usb_ctx->ref_count) > 2)) {
-			getnstimeofday(&now);
+			now = jiffies;
 			/*Approx 1 Sec. this is not perfect calculation*/
-			if (now.tv_sec != ts.tv_sec)
+			if (time_before(time, now))
 				break;
 		}
 		oz_dbg(ON, "USB service stopped\n");