From c4c4018b04f9b7993e3800dc1f391ac8947764a5 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Fri, 23 Feb 2007 13:40:45 +0000 Subject: [MIPS] RTLX, VPE: Make open actually atomic. Signed-off-by: Ralf Baechle --- arch/mips/kernel/vpe.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'arch/mips/kernel/vpe.c') diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c index 9aca871a307..c9ee9d2d585 100644 --- a/arch/mips/kernel/vpe.c +++ b/arch/mips/kernel/vpe.c @@ -1079,6 +1079,7 @@ static int getcwd(char *buff, int size) static int vpe_open(struct inode *inode, struct file *filp) { int minor, ret; + enum vpe_state state; struct vpe *v; struct vpe_notifications *not; @@ -1093,7 +1094,8 @@ static int vpe_open(struct inode *inode, struct file *filp) return -ENODEV; } - if (v->state != VPE_STATE_UNUSED) { + state = xchg(&v->state, VPE_STATE_INUSE); + if (state != VPE_STATE_UNUSED) { dvpe(); printk(KERN_DEBUG "VPE loader: tc in use dumping regs\n"); @@ -1108,9 +1110,6 @@ static int vpe_open(struct inode *inode, struct file *filp) cleanup_tc(get_tc(minor)); } - // allocate it so when we get write ops we know it's expected. - v->state = VPE_STATE_INUSE; - /* this of-course trashes what was there before... */ v->pbuffer = vmalloc(P_SIZE); v->plen = P_SIZE; -- cgit v1.2.3