pmic8058-vibrator: Do not call hrtimer_cancel when preemption is disabled
The hrtimer_cancel logic exposes a possible spinlock live-lock
situation, if this call is made when preemption is disabled.
Fix the code to avoid this situation.
CRs-Fixed: 299333
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
diff --git a/drivers/misc/pmic8058-vibrator.c b/drivers/misc/pmic8058-vibrator.c
index 1b15b18..f6284ee 100644
--- a/drivers/misc/pmic8058-vibrator.c
+++ b/drivers/misc/pmic8058-vibrator.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -123,8 +123,13 @@
timed_dev);
unsigned long flags;
+retry:
spin_lock_irqsave(&vib->lock, flags);
- hrtimer_cancel(&vib->vib_timer);
+ if (hrtimer_try_to_cancel(&vib->vib_timer) < 0) {
+ spin_unlock_irqrestore(&vib->lock, flags);
+ cpu_relax();
+ goto retry;
+ }
if (value == 0)
vib->state = 0;