diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2007-03-15 17:13:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-03-17 01:03:28 +0000 |
commit | bc4809e939b91c9642f1ddaea732e2d432ee6af6 (patch) | |
tree | 0536fee2c956f0caa2379041a46bdc8db66a6d74 /arch | |
parent | 61dcc6f4d9ed5db71f4f0be9026bdd09f1a7dc06 (diff) | |
download | kernel-crypto-bc4809e939b91c9642f1ddaea732e2d432ee6af6.tar.gz kernel-crypto-bc4809e939b91c9642f1ddaea732e2d432ee6af6.tar.xz kernel-crypto-bc4809e939b91c9642f1ddaea732e2d432ee6af6.zip |
[MIPS] RTLX: Protect rtlx_{read,write} with mutex.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/kernel/rtlx.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c index 0441c7c1e44..745649e15ad 100644 --- a/arch/mips/kernel/rtlx.c +++ b/arch/mips/kernel/rtlx.c @@ -54,6 +54,7 @@ static struct chan_waitqueues { wait_queue_head_t rt_queue; wait_queue_head_t lx_queue; atomic_t in_open; + struct mutex mutex; } channel_wqs[RTLX_CHANNELS]; static struct irqaction irq; @@ -314,6 +315,7 @@ ssize_t rtlx_read(int index, void *buff, size_t count, int user) lx = &rtlx->channel[index]; + mutex_lock(&channel_wqs[index].mutex); smp_rmb(); lx_write = lx->lx_write; @@ -334,6 +336,7 @@ ssize_t rtlx_read(int index, void *buff, size_t count, int user) smp_wmb(); lx->lx_read = (lx->lx_read + count) % lx->buffer_size; smp_wmb(); + mutex_unlock(&channel_wqs[index].mutex); return count; } @@ -349,6 +352,7 @@ ssize_t rtlx_write(int index, void *buffer, size_t count, int user) rt = &rtlx->channel[index]; + mutex_lock(&channel_wqs[index].mutex); smp_rmb(); rt_read = rt->rt_read; @@ -368,6 +372,7 @@ ssize_t rtlx_write(int index, void *buffer, size_t count, int user) smp_wmb(); rt->rt_write = (rt->rt_write + count) % rt->buffer_size; smp_wmb(); + mutex_unlock(&channel_wqs[index].mutex); return count; } @@ -486,6 +491,7 @@ static int rtlx_module_init(void) init_waitqueue_head(&channel_wqs[i].rt_queue); init_waitqueue_head(&channel_wqs[i].lx_queue); atomic_set(&channel_wqs[i].in_open, 0); + mutex_init(&channel_wqs[i].mutex); dev = device_create(mt_class, NULL, MKDEV(major, i), "%s%d", module_name, i); |