diff options
Diffstat (limited to 'drivers/rtc/rtc-dev.c')
-rw-r--r-- | drivers/rtc/rtc-dev.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 814583bd2fe7..ae1bf177d625 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -26,10 +26,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file) | |||
26 | struct rtc_device, char_dev); | 26 | struct rtc_device, char_dev); |
27 | const struct rtc_class_ops *ops = rtc->ops; | 27 | const struct rtc_class_ops *ops = rtc->ops; |
28 | 28 | ||
29 | /* We keep the lock as long as the device is in use | 29 | if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags)) |
30 | * and return immediately if busy | ||
31 | */ | ||
32 | if (!(mutex_trylock(&rtc->char_lock))) | ||
33 | return -EBUSY; | 30 | return -EBUSY; |
34 | 31 | ||
35 | file->private_data = rtc; | 32 | file->private_data = rtc; |
@@ -43,8 +40,8 @@ static int rtc_dev_open(struct inode *inode, struct file *file) | |||
43 | return 0; | 40 | return 0; |
44 | } | 41 | } |
45 | 42 | ||
46 | /* something has gone wrong, release the lock */ | 43 | /* something has gone wrong */ |
47 | mutex_unlock(&rtc->char_lock); | 44 | clear_bit(RTC_DEV_BUSY, &rtc->flags); |
48 | return err; | 45 | return err; |
49 | } | 46 | } |
50 | 47 | ||
@@ -405,7 +402,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file) | |||
405 | if (rtc->ops->release) | 402 | if (rtc->ops->release) |
406 | rtc->ops->release(rtc->dev.parent); | 403 | rtc->ops->release(rtc->dev.parent); |
407 | 404 | ||
408 | mutex_unlock(&rtc->char_lock); | 405 | clear_bit(RTC_DEV_BUSY, &rtc->flags); |
409 | return 0; | 406 | return 0; |
410 | } | 407 | } |
411 | 408 | ||
@@ -440,7 +437,6 @@ void rtc_dev_prepare(struct rtc_device *rtc) | |||
440 | 437 | ||
441 | rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id); | 438 | rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id); |
442 | 439 | ||
443 | mutex_init(&rtc->char_lock); | ||
444 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL | 440 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL |
445 | INIT_WORK(&rtc->uie_task, rtc_uie_task); | 441 | INIT_WORK(&rtc->uie_task, rtc_uie_task); |
446 | setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc); | 442 | setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc); |