msm: smd: Add smd_tiocmset api without spinlocks
tiocmset can be called from client drivers in smd callbacks which
could result in dead-lock as most of the call-backs holds spinlock
which is used by tiocmset. Add tiocmset call which does not use
spinlocks so that it can be used from smd callbacks.
Signed-off-by: Vamsi Krishna <vskrishn@codeaurora.org>
diff --git a/arch/arm/mach-msm/smd.c b/arch/arm/mach-msm/smd.c
index 3c41afc..4b75d9c 100644
--- a/arch/arm/mach-msm/smd.c
+++ b/arch/arm/mach-msm/smd.c
@@ -1688,11 +1688,10 @@
}
EXPORT_SYMBOL(smd_tiocmget);
-int smd_tiocmset(smd_channel_t *ch, unsigned int set, unsigned int clear)
+/* this api will be called while holding smd_lock */
+int
+smd_tiocmset_from_cb(smd_channel_t *ch, unsigned int set, unsigned int clear)
{
- unsigned long flags;
-
- spin_lock_irqsave(&smd_lock, flags);
if (set & TIOCM_DTR)
ch->send->fDSR = 1;
@@ -1708,6 +1707,17 @@
ch->send->fSTATE = 1;
barrier();
ch->notify_other_cpu();
+
+ return 0;
+}
+EXPORT_SYMBOL(smd_tiocmset_from_cb);
+
+int smd_tiocmset(smd_channel_t *ch, unsigned int set, unsigned int clear)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&smd_lock, flags);
+ smd_tiocmset_from_cb(ch, set, clear);
spin_unlock_irqrestore(&smd_lock, flags);
return 0;