aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/sibyte/common/sb_tbprof.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c
index 637a194e5cd5..15ea778b5e66 100644
--- a/arch/mips/sibyte/common/sb_tbprof.c
+++ b/arch/mips/sibyte/common/sb_tbprof.c
@@ -403,36 +403,31 @@ static int sbprof_zbprof_stop(void)
403static int sbprof_tb_open(struct inode *inode, struct file *filp) 403static int sbprof_tb_open(struct inode *inode, struct file *filp)
404{ 404{
405 int minor; 405 int minor;
406 int err = 0;
407 406
408 lock_kernel();
409 minor = iminor(inode); 407 minor = iminor(inode);
410 if (minor != 0) { 408 if (minor != 0)
411 err = -ENODEV; 409 return -ENODEV;
412 goto out;
413 }
414 410
415 if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED) { 411 if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED)
416 err = -EBUSY; 412 return -EBUSY;
417 goto out;
418 }
419 413
420 memset(&sbp, 0, sizeof(struct sbprof_tb)); 414 memset(&sbp, 0, sizeof(struct sbprof_tb));
421 sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES); 415 sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES);
422 if (!sbp.sbprof_tbbuf) { 416 if (!sbp.sbprof_tbbuf) {
423 err = -ENOMEM; 417 sbp.open = SB_CLOSED;
424 goto out; 418 wmb();
419 return -ENOMEM;
425 } 420 }
421
426 memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES); 422 memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES);
427 init_waitqueue_head(&sbp.tb_sync); 423 init_waitqueue_head(&sbp.tb_sync);
428 init_waitqueue_head(&sbp.tb_read); 424 init_waitqueue_head(&sbp.tb_read);
429 mutex_init(&sbp.lock); 425 mutex_init(&sbp.lock);
430 426
431 sbp.open = SB_OPEN; 427 sbp.open = SB_OPEN;
428 wmb();
432 429
433 out: 430 return 0;
434 unlock_kernel();
435 return err;
436} 431}
437 432
438static int sbprof_tb_release(struct inode *inode, struct file *filp) 433static int sbprof_tb_release(struct inode *inode, struct file *filp)
@@ -440,7 +435,7 @@ static int sbprof_tb_release(struct inode *inode, struct file *filp)
440 int minor; 435 int minor;
441 436
442 minor = iminor(inode); 437 minor = iminor(inode);
443 if (minor != 0 || !sbp.open) 438 if (minor != 0 || sbp.open != SB_CLOSED)
444 return -ENODEV; 439 return -ENODEV;
445 440
446 mutex_lock(&sbp.lock); 441 mutex_lock(&sbp.lock);
@@ -449,7 +444,8 @@ static int sbprof_tb_release(struct inode *inode, struct file *filp)
449 sbprof_zbprof_stop(); 444 sbprof_zbprof_stop();
450 445
451 vfree(sbp.sbprof_tbbuf); 446 vfree(sbp.sbprof_tbbuf);
452 sbp.open = 0; 447 sbp.open = SB_CLOSED;
448 wmb();
453 449
454 mutex_unlock(&sbp.lock); 450 mutex_unlock(&sbp.lock);
455 451
@@ -583,7 +579,8 @@ static int __init sbprof_tb_init(void)
583 } 579 }
584 tb_dev = dev; 580 tb_dev = dev;
585 581
586 sbp.open = 0; 582 sbp.open = SB_CLOSED;
583 wmb();
587 tb_period = zbbus_mhz * 10000LL; 584 tb_period = zbbus_mhz * 10000LL;
588 pr_info(DEVNAME ": initialized - tb_period = %lld\n", 585 pr_info(DEVNAME ": initialized - tb_period = %lld\n",
589 (long long) tb_period); 586 (long long) tb_period);