headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / drivers / rtc / interface.c
index 43276f2..a0c8162 100644 (file)
@@ -12,6 +12,7 @@
 */
 
 #include <linux/rtc.h>
+#include <linux/sched.h>
 #include <linux/log2.h>
 
 int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
@@ -50,10 +51,15 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
 
        if (!rtc->ops)
                err = -ENODEV;
-       else if (!rtc->ops->set_time)
-               err = -EINVAL;
-       else
+       else if (rtc->ops->set_time)
                err = rtc->ops->set_time(rtc->dev.parent, tm);
+       else if (rtc->ops->set_mmss) {
+               unsigned long secs;
+               err = rtc_tm_to_time(tm, &secs);
+               if (err == 0)
+                       err = rtc->ops->set_mmss(rtc->dev.parent, secs);
+       } else
+               err = -EINVAL;
 
        mutex_unlock(&rtc->ops_lock);
        return err;
@@ -366,19 +372,21 @@ EXPORT_SYMBOL_GPL(rtc_update_irq_enable);
  * @rtc: the rtc device
  * @num: how many irqs are being reported (usually one)
  * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF
- * Context: in_interrupt(), irqs blocked
+ * Context: any
  */
 void rtc_update_irq(struct rtc_device *rtc,
                unsigned long num, unsigned long events)
 {
-       spin_lock(&rtc->irq_lock);
+       unsigned long flags;
+
+       spin_lock_irqsave(&rtc->irq_lock, flags);
        rtc->irq_data = (rtc->irq_data + (num << 8)) | events;
-       spin_unlock(&rtc->irq_lock);
+       spin_unlock_irqrestore(&rtc->irq_lock, flags);
 
-       spin_lock(&rtc->irq_task_lock);
+       spin_lock_irqsave(&rtc->irq_task_lock, flags);
        if (rtc->irq_task)
                rtc->irq_task->func(rtc->irq_task->private_data);
-       spin_unlock(&rtc->irq_task_lock);
+       spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
 
        wake_up_interruptible(&rtc->irq_queue);
        kill_fasync(&rtc->async_queue, SIGIO, POLL_IN);
@@ -504,9 +512,6 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
        if (rtc->ops->irq_set_freq == NULL)
                return -ENXIO;
 
-       if (!is_power_of_2(freq))
-               return -EINVAL;
-
        spin_lock_irqsave(&rtc->irq_task_lock, flags);
        if (rtc->irq_task != NULL && task == NULL)
                err = -EBUSY;