14 #include <linux/module.h>
15 #include <linux/rtc.h>
16 #include <linux/sched.h>
19 static dev_t rtc_devt;
21 #define RTC_DEV_MAX 16
49 #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
65 if (rtc->stop_uie_polling || err) {
66 rtc->uie_task_active = 0;
67 }
else if (rtc->oldsecs !=
tm.
tm_sec) {
68 num = (
tm.
tm_sec + 60 - rtc->oldsecs) % 60;
71 rtc->uie_timer_active = 1;
72 rtc->uie_task_active = 0;
75 rtc->uie_task_active = 0;
81 static void rtc_uie_timer(
unsigned long data)
87 rtc->uie_timer_active = 0;
88 rtc->uie_task_active = 1;
90 rtc->uie_task_active = 0;
91 spin_unlock_irqrestore(&rtc->
irq_lock, flags);
97 if (rtc->uie_irq_active) {
98 rtc->stop_uie_polling = 1;
99 if (rtc->uie_timer_active) {
103 rtc->uie_timer_active = 0;
105 if (rtc->uie_task_active) {
110 rtc->uie_irq_active = 0;
125 if (!rtc->uie_irq_active) {
126 rtc->uie_irq_active = 1;
127 rtc->stop_uie_polling = 0;
129 rtc->uie_task_active = 1;
131 rtc->uie_task_active = 0;
143 return clear_uie(rtc);
150 rtc_dev_read(
struct file *
file,
char __user *
buf,
size_t count, loff_t *ppos)
158 if (count !=
sizeof(
unsigned int) && count <
sizeof(
unsigned long))
189 if (rtc->
ops->read_callback)
190 data = rtc->
ops->read_callback(rtc->
dev.parent,
193 if (
sizeof(
int) !=
sizeof(
long) &&
194 count ==
sizeof(
unsigned int))
195 ret =
put_user(data, (
unsigned int __user *)buf) ?:
196 sizeof(
unsigned int);
198 ret =
put_user(data, (
unsigned long __user *)buf) ?:
199 sizeof(
unsigned long);
204 static unsigned int rtc_dev_poll(
struct file *file,
poll_table *
wait)
216 static long rtc_dev_ioctl(
struct file *file,
217 unsigned int cmd,
unsigned long arg)
287 alarm.time.tm_wday = -1;
288 alarm.time.tm_yday = -1;
289 alarm.time.tm_isdst = -1;
305 unsigned long now, then;
398 err =
put_user(rtc_epoch, (
unsigned long __user *)uarg);
421 err = ops->
ioctl(rtc->
dev.parent, cmd, arg);
434 static int rtc_dev_fasync(
int fd,
struct file *file,
int on)
440 static int rtc_dev_release(
struct inode *
inode,
struct file *file)
458 if (rtc->
ops->release)
459 rtc->
ops->release(rtc->
dev.parent);
468 .read = rtc_dev_read,
469 .poll = rtc_dev_poll,
470 .unlocked_ioctl = rtc_dev_ioctl,
471 .open = rtc_dev_open,
472 .release = rtc_dev_release,
473 .fasync = rtc_dev_fasync,
490 #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
492 setup_timer(&rtc->uie_timer, rtc_uie_timer, (
unsigned long)rtc);
495 cdev_init(&rtc->char_dev, &rtc_dev_fops);
496 rtc->char_dev.owner = rtc->owner;