Merge tag 'apparmor-pr-2018-08-23' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / drivers / rtc / interface.c
index bac1eeb..3d577e2 100644 (file)
@@ -607,12 +607,6 @@ void rtc_handle_legacy_irq(struct rtc_device *rtc, int num, int mode)
        rtc->irq_data = (rtc->irq_data + (num << 8)) | (RTC_IRQF|mode);
        spin_unlock_irqrestore(&rtc->irq_lock, flags);
 
-       /* call the task func */
-       spin_lock_irqsave(&rtc->irq_task_lock, flags);
-       if (rtc->irq_task)
-               rtc->irq_task->func(rtc->irq_task->private_data);
-       spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
-
        wake_up_interruptible(&rtc->irq_queue);
        kill_fasync(&rtc->async_queue, SIGIO, POLL_IN);
 }
@@ -721,39 +715,6 @@ void rtc_class_close(struct rtc_device *rtc)
 }
 EXPORT_SYMBOL_GPL(rtc_class_close);
 
-int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
-{
-       int retval = -EBUSY;
-
-       if (task == NULL || task->func == NULL)
-               return -EINVAL;
-
-       /* Cannot register while the char dev is in use */
-       if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
-               return -EBUSY;
-
-       spin_lock_irq(&rtc->irq_task_lock);
-       if (rtc->irq_task == NULL) {
-               rtc->irq_task = task;
-               retval = 0;
-       }
-       spin_unlock_irq(&rtc->irq_task_lock);
-
-       clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
-
-       return retval;
-}
-EXPORT_SYMBOL_GPL(rtc_irq_register);
-
-void rtc_irq_unregister(struct rtc_device *rtc, struct rtc_task *task)
-{
-       spin_lock_irq(&rtc->irq_task_lock);
-       if (rtc->irq_task == task)
-               rtc->irq_task = NULL;
-       spin_unlock_irq(&rtc->irq_task_lock);
-}
-EXPORT_SYMBOL_GPL(rtc_irq_unregister);
-
 static int rtc_update_hrtimer(struct rtc_device *rtc, int enabled)
 {
        /*
@@ -785,71 +746,45 @@ static int rtc_update_hrtimer(struct rtc_device *rtc, int enabled)
  * Context: any
  *
  * Note that rtc_irq_set_freq() should previously have been used to
- * specify the desired frequency of periodic IRQ task->func() callbacks.
+ * specify the desired frequency of periodic IRQ.
  */
-int rtc_irq_set_state(struct rtc_device *rtc, struct rtc_task *task, int enabled)
+int rtc_irq_set_state(struct rtc_device *rtc, int enabled)
 {
        int err = 0;
-       unsigned long flags;
 
-retry:
-       spin_lock_irqsave(&rtc->irq_task_lock, flags);
-       if (rtc->irq_task != NULL && task == NULL)
-               err = -EBUSY;
-       else if (rtc->irq_task != task)
-               err = -EACCES;
-       else {
-               if (rtc_update_hrtimer(rtc, enabled) < 0) {
-                       spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
-                       cpu_relax();
-                       goto retry;
-               }
-               rtc->pie_enabled = enabled;
-       }
-       spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
+       while (rtc_update_hrtimer(rtc, enabled) < 0)
+               cpu_relax();
+
+       rtc->pie_enabled = enabled;
 
        trace_rtc_irq_set_state(enabled, err);
        return err;
 }
-EXPORT_SYMBOL_GPL(rtc_irq_set_state);
 
 /**
  * rtc_irq_set_freq - set 2^N Hz periodic IRQ frequency for IRQ
  * @rtc: the rtc device
  * @task: currently registered with rtc_irq_register()
- * @freq: positive frequency with which task->func() will be called
+ * @freq: positive frequency
  * Context: any
  *
  * Note that rtc_irq_set_state() is used to enable or disable the
  * periodic IRQs.
  */
-int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
+int rtc_irq_set_freq(struct rtc_device *rtc, int freq)
 {
        int err = 0;
-       unsigned long flags;
 
        if (freq <= 0 || freq > RTC_MAX_FREQ)
                return -EINVAL;
-retry:
-       spin_lock_irqsave(&rtc->irq_task_lock, flags);
-       if (rtc->irq_task != NULL && task == NULL)
-               err = -EBUSY;
-       else if (rtc->irq_task != task)
-               err = -EACCES;
-       else {
-               rtc->irq_freq = freq;
-               if (rtc->pie_enabled && rtc_update_hrtimer(rtc, 1) < 0) {
-                       spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
-                       cpu_relax();
-                       goto retry;
-               }
-       }
-       spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
+
+       rtc->irq_freq = freq;
+       while (rtc->pie_enabled && rtc_update_hrtimer(rtc, 1) < 0)
+               cpu_relax();
 
        trace_rtc_irq_set_freq(freq, err);
        return err;
 }
-EXPORT_SYMBOL_GPL(rtc_irq_set_freq);
 
 /**
  * rtc_timer_enqueue - Adds a rtc_timer to the rtc_device timerqueue
@@ -979,8 +914,8 @@ again:
                timerqueue_del(&rtc->timerqueue, &timer->node);
                trace_rtc_timer_dequeue(timer);
                timer->enabled = 0;
-               if (timer->task.func)
-                       timer->task.func(timer->task.private_data);
+               if (timer->func)
+                       timer->func(timer->private_data);
 
                trace_rtc_timer_fired(timer);
                /* Re-add/fwd periodic timers */
@@ -1035,8 +970,8 @@ void rtc_timer_init(struct rtc_timer *timer, void (*f)(void *p), void *data)
 {
        timerqueue_init(&timer->node);
        timer->enabled = 0;
-       timer->task.func = f;
-       timer->task.private_data = data;
+       timer->func = f;
+       timer->private_data = data;
 }
 
 /* rtc_timer_start - Sets an rtc_timer to fire in the future