Skip to content

Commit

Permalink
msm: smd: provide atomic channel writes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Brian Swetland authored and Daniel Walker committed May 12, 2010
1 parent 1207bab commit 636eb9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/arm/mach-msm/include/mach/msm_smd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions arch/arm/mach-msm/smd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 636eb9c

Please sign in to comment.