Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 74385
b: refs/heads/master
c: 8853c20
h: refs/heads/master
i:
  74383: b1c4a99
v: v3
  • Loading branch information
Jiri Kosina authored and Linus Torvalds committed Nov 29, 2007
1 parent 7ba2669 commit f36bfa7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 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: 08b633070ad5fa17a837428a601c32cf3db6aafd
refs/heads/master: 8853c202b4a91713dbfb4d9b6e1c87cc2aa12392
4 changes: 2 additions & 2 deletions trunk/drivers/rtc/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
return -EINVAL;

/* Cannot register while the char dev is in use */
if (!(mutex_trylock(&rtc->char_lock)))
if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags))
return -EBUSY;

spin_lock_irq(&rtc->irq_task_lock);
Expand All @@ -303,7 +303,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
}
spin_unlock_irq(&rtc->irq_task_lock);

mutex_unlock(&rtc->char_lock);
clear_bit(RTC_DEV_BUSY, &rtc->flags);

return retval;
}
Expand Down
12 changes: 4 additions & 8 deletions trunk/drivers/rtc/rtc-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
struct rtc_device, char_dev);
const struct rtc_class_ops *ops = rtc->ops;

/* We keep the lock as long as the device is in use
* and return immediately if busy
*/
if (!(mutex_trylock(&rtc->char_lock)))
if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags))
return -EBUSY;

file->private_data = rtc;
Expand All @@ -43,8 +40,8 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
return 0;
}

/* something has gone wrong, release the lock */
mutex_unlock(&rtc->char_lock);
/* something has gone wrong */
clear_bit(RTC_DEV_BUSY, &rtc->flags);
return err;
}

Expand Down Expand Up @@ -405,7 +402,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
if (rtc->ops->release)
rtc->ops->release(rtc->dev.parent);

mutex_unlock(&rtc->char_lock);
clear_bit(RTC_DEV_BUSY, &rtc->flags);
return 0;
}

Expand Down Expand Up @@ -440,7 +437,6 @@ void rtc_dev_prepare(struct rtc_device *rtc)

rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id);

mutex_init(&rtc->char_lock);
#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
INIT_WORK(&rtc->uie_task, rtc_uie_task);
setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc);
Expand Down
5 changes: 4 additions & 1 deletion trunk/include/linux/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ struct rtc_class_ops {
#define RTC_DEVICE_NAME_SIZE 20
struct rtc_task;

/* flags */
#define RTC_DEV_BUSY 0

struct rtc_device
{
struct device dev;
Expand All @@ -145,7 +148,7 @@ struct rtc_device
struct mutex ops_lock;

struct cdev char_dev;
struct mutex char_lock;
unsigned long flags;

unsigned long irq_data;
spinlock_t irq_lock;
Expand Down

0 comments on commit f36bfa7

Please sign in to comment.