From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932980AbbDMVCL (ORCPT ); Mon, 13 Apr 2015 17:02:11 -0400 Received: from www.linutronix.de ([62.245.132.108]:33723 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932935AbbDMVCI (ORCPT ); Mon, 13 Apr 2015 17:02:08 -0400 Message-Id: <20150413210035.357448657@linutronix.de> User-Agent: quilt/0.63-1 Date: Mon, 13 Apr 2015 21:02:25 -0000 From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Shigekatsu Tateno , Greg Kroah-Hartman , devel@driverdev.osuosl.org Subject: [patch 5/5] staging: ozwpan: Fix hrtimer wreckage References: <20150413210009.682000343@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=stagin-ozwpan-fix-hrtimer-wreckage.patch X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org oz_timer_add() modifies the expiry value of an active timer, which results in data corruption. Use hrtimer_start() and remove the silly conditional. While at it use the proper helper function to convert milliseconds to ktime. Signed-off-by: Thomas Gleixner Cc: Shigekatsu Tateno Cc: Greg Kroah-Hartman Cc: devel@driverdev.osuosl.org --- drivers/staging/ozwpan/ozproto.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) Index: linux/drivers/staging/ozwpan/ozproto.c =================================================================== --- linux.orig/drivers/staging/ozwpan/ozproto.c +++ linux/drivers/staging/ozwpan/ozproto.c @@ -566,23 +566,14 @@ void oz_timer_add(struct oz_pd *pd, int switch (type) { case OZ_TIMER_TOUT: case OZ_TIMER_STOP: - if (hrtimer_active(&pd->timeout)) { - hrtimer_set_expires(&pd->timeout, ktime_set(due_time / - MSEC_PER_SEC, (due_time % MSEC_PER_SEC) * - NSEC_PER_MSEC)); - hrtimer_start_expires(&pd->timeout, HRTIMER_MODE_REL); - } else { - hrtimer_start(&pd->timeout, ktime_set(due_time / - MSEC_PER_SEC, (due_time % MSEC_PER_SEC) * - NSEC_PER_MSEC), HRTIMER_MODE_REL); - } + hrtimer_start(&pd->timeout, ms_to_ktime(due_time), + HRTIMER_MODE_REL); pd->timeout_type = type; break; case OZ_TIMER_HEARTBEAT: if (!hrtimer_active(&pd->heartbeat)) - hrtimer_start(&pd->heartbeat, ktime_set(due_time / - MSEC_PER_SEC, (due_time % MSEC_PER_SEC) * - NSEC_PER_MSEC), HRTIMER_MODE_REL); + hrtimer_start(&pd->heartbeat, ms_to_ktime(due_time), + HRTIMER_MODE_REL); break; } spin_unlock_bh(&g_polling_lock);