]> git.karo-electronics.de Git - linux-beck.git/commitdiff
msm: smd: provide atomic channel writes
authorBrian Swetland <swetland@google.com>
Mon, 7 Dec 2009 23:28:08 +0000 (15:28 -0800)
committerDaniel Walker <dwalker@codeaurora.org>
Wed, 12 May 2010 16:15:31 +0000 (09:15 -0700)
Some smd clients may write from multiple threads, in which case it's
not safe to call smd_write without holding a lock.  smd_write_atomic()
provides the same functionality as smd_write() but obtains the smd
lock first.

Signed-off-by: Brian Swetland <swetland@google.com>
Signed-off-by: Daniel Walker <dwalker@codeaurora.org>
arch/arm/mach-msm/include/mach/msm_smd.h
arch/arm/mach-msm/smd.c

index bdf7731ab6800f583d46903551e12aba7779d91f..aa076e466e4c6f2d893fe31fbbfcbf13844e8175 100644 (file)
@@ -38,6 +38,7 @@ int smd_read(smd_channel_t *ch, void *data, int len);
 ** it will return the requested length written or an error.
 */
 int smd_write(smd_channel_t *ch, const void *data, int len);
+int smd_write_atomic(smd_channel_t *ch, const void *data, int len);
 
 int smd_write_avail(smd_channel_t *ch);
 int smd_read_avail(smd_channel_t *ch);
index 655fe42506cad87846b1046913822ad755810d99..086fd77dc8912b432970dce2aa59d7b8bc3d050f 100644 (file)
@@ -804,6 +804,16 @@ int smd_write(smd_channel_t *ch, const void *data, int len)
        return ch->write(ch, data, len);
 }
 
+int smd_write_atomic(smd_channel_t *ch, const void *data, int len)
+{
+       unsigned long flags;
+       int res;
+       spin_lock_irqsave(&smd_lock, flags);
+       res = ch->write(ch, data, len);
+       spin_unlock_irqrestore(&smd_lock, flags);
+       return res;
+}
+
 int smd_read_avail(smd_channel_t *ch)
 {
        return ch->read_avail(ch);