Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 166619
b: refs/heads/master
c: 36ac829
h: refs/heads/master
i:
  166617: 45796d4
  166615: d66333c
v: v3
  • Loading branch information
Ralf Baechle committed Sep 30, 2009
1 parent 8d76e90 commit 40129a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 553d6d5f5b84f11fad8043688137dac96df1a06d
refs/heads/master: 36ac829e5a6ab29a6fd990588d170438bfb5c7a0
33 changes: 15 additions & 18 deletions trunk/arch/mips/sibyte/common/sb_tbprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,44 +403,39 @@ static int sbprof_zbprof_stop(void)
static int sbprof_tb_open(struct inode *inode, struct file *filp)
{
int minor;
int err = 0;

lock_kernel();
minor = iminor(inode);
if (minor != 0) {
err = -ENODEV;
goto out;
}
if (minor != 0)
return -ENODEV;

if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED) {
err = -EBUSY;
goto out;
}
if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED)
return -EBUSY;

memset(&sbp, 0, sizeof(struct sbprof_tb));
sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES);
if (!sbp.sbprof_tbbuf) {
err = -ENOMEM;
goto out;
sbp.open = SB_CLOSED;
wmb();
return -ENOMEM;
}

memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES);
init_waitqueue_head(&sbp.tb_sync);
init_waitqueue_head(&sbp.tb_read);
mutex_init(&sbp.lock);

sbp.open = SB_OPEN;
wmb();

out:
unlock_kernel();
return err;
return 0;
}

static int sbprof_tb_release(struct inode *inode, struct file *filp)
{
int minor;

minor = iminor(inode);
if (minor != 0 || !sbp.open)
if (minor != 0 || sbp.open != SB_CLOSED)
return -ENODEV;

mutex_lock(&sbp.lock);
Expand All @@ -449,7 +444,8 @@ static int sbprof_tb_release(struct inode *inode, struct file *filp)
sbprof_zbprof_stop();

vfree(sbp.sbprof_tbbuf);
sbp.open = 0;
sbp.open = SB_CLOSED;
wmb();

mutex_unlock(&sbp.lock);

Expand Down Expand Up @@ -583,7 +579,8 @@ static int __init sbprof_tb_init(void)
}
tb_dev = dev;

sbp.open = 0;
sbp.open = SB_CLOSED;
wmb();
tb_period = zbbus_mhz * 10000LL;
pr_info(DEVNAME ": initialized - tb_period = %lld\n",
(long long) tb_period);
Expand Down

0 comments on commit 40129a1

Please sign in to comment.