From 636eb9cbaef7989ce7809a0d842bf78470a0a1f4 Mon Sep 17 00:00:00 2001 From: Brian Swetland Date: Mon, 7 Dec 2009 15:28:08 -0800 Subject: [PATCH] msm: smd: provide atomic channel writes 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 Signed-off-by: Daniel Walker --- arch/arm/mach-msm/include/mach/msm_smd.h | 1 + arch/arm/mach-msm/smd.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/arch/arm/mach-msm/include/mach/msm_smd.h b/arch/arm/mach-msm/include/mach/msm_smd.h index bdf7731ab680..aa076e466e4c 100644 --- a/arch/arm/mach-msm/include/mach/msm_smd.h +++ b/arch/arm/mach-msm/include/mach/msm_smd.h @@ -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); diff --git a/arch/arm/mach-msm/smd.c b/arch/arm/mach-msm/smd.c index 655fe42506ca..086fd77dc891 100644 --- a/arch/arm/mach-msm/smd.c +++ b/arch/arm/mach-msm/smd.c @@ -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); -- 2.34.1