From 1560d0848a1a84db6c1d9b17c14273c0dae41828 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Wed, 25 Jul 2018 14:34:29 +0200 Subject: rtc: remove rtc_irq_register/rtc_irq_unregister The rtc_irq_* interface is not used from outside the RTC subsytem since 2016. Signed-off-by: Alexandre Belloni --- include/linux/rtc.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 6268208760e9..f868d6b619ab 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -204,10 +204,6 @@ extern void rtc_update_irq(struct rtc_device *rtc, extern struct rtc_device *rtc_class_open(const char *name); extern void rtc_class_close(struct rtc_device *rtc); -extern int rtc_irq_register(struct rtc_device *rtc, - struct rtc_task *task); -extern void rtc_irq_unregister(struct rtc_device *rtc, - struct rtc_task *task); extern int rtc_irq_set_state(struct rtc_device *rtc, struct rtc_task *task, int enabled); extern int rtc_irq_set_freq(struct rtc_device *rtc, -- cgit v1.2.3-70-g09d2 From acecb3ad8b21a519ce4ad728106d45d4e978bb56 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Wed, 25 Jul 2018 14:58:10 +0200 Subject: rtc: remove irq_task and irq_task_lock There is no way to set a periodic task anymore, remove task pointer and lock. Signed-off-by: Alexandre Belloni --- drivers/rtc/class.c | 1 - drivers/rtc/interface.c | 50 ++++++++++--------------------------------------- include/linux/rtc.h | 2 -- 3 files changed, 10 insertions(+), 43 deletions(-) (limited to 'include') diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 7fa32c922617..0fca4d74c76b 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -172,7 +172,6 @@ static struct rtc_device *rtc_allocate_device(void) mutex_init(&rtc->ops_lock); spin_lock_init(&rtc->irq_lock); - spin_lock_init(&rtc->irq_task_lock); init_waitqueue_head(&rtc->irq_queue); /* Init timerqueue */ diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 2b1b9a0b9f8a..ae0d67610c7b 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -605,12 +605,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); } @@ -750,28 +744,16 @@ 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 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; @@ -782,7 +764,7 @@ 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 @@ -791,25 +773,13 @@ EXPORT_SYMBOL_GPL(rtc_irq_set_state); int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, 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; diff --git a/include/linux/rtc.h b/include/linux/rtc.h index f868d6b619ab..8cc23fdfd4ee 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -121,8 +121,6 @@ struct rtc_device { wait_queue_head_t irq_queue; struct fasync_struct *async_queue; - struct rtc_task *irq_task; - spinlock_t irq_task_lock; int irq_freq; int max_user_freq; -- cgit v1.2.3-70-g09d2 From 8719d3c9188b38db462a77ecd8c7a8e25e7e8c4c Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Wed, 25 Jul 2018 15:07:09 +0200 Subject: rtc: simplify rtc_irq_set_state/rtc_irq_set_freq The PIE doesn't handle tasks anymore, remove the pointer from the interface. Signed-off-by: Alexandre Belloni --- drivers/rtc/interface.c | 4 ++-- drivers/rtc/rtc-dev.c | 8 ++++---- include/linux/rtc.h | 6 ++---- 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index ae0d67610c7b..76eb3a2957cc 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -746,7 +746,7 @@ static int rtc_update_hrtimer(struct rtc_device *rtc, int enabled) * Note that rtc_irq_set_freq() should previously have been used to * 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; @@ -770,7 +770,7 @@ EXPORT_SYMBOL_GPL(rtc_irq_set_state); * 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; diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index efa221e8bc22..43d962a9c210 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c @@ -341,11 +341,11 @@ static long rtc_dev_ioctl(struct file *file, return rtc_set_time(rtc, &tm); case RTC_PIE_ON: - err = rtc_irq_set_state(rtc, NULL, 1); + err = rtc_irq_set_state(rtc, 1); break; case RTC_PIE_OFF: - err = rtc_irq_set_state(rtc, NULL, 0); + err = rtc_irq_set_state(rtc, 0); break; case RTC_AIE_ON: @@ -365,7 +365,7 @@ static long rtc_dev_ioctl(struct file *file, return rtc_update_irq_enable(rtc, 0); case RTC_IRQP_SET: - err = rtc_irq_set_freq(rtc, NULL, arg); + err = rtc_irq_set_freq(rtc, arg); break; case RTC_IRQP_READ: @@ -427,7 +427,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file) /* Keep ioctl until all drivers are converted */ rtc_dev_ioctl(file, RTC_UIE_OFF, 0); rtc_update_irq_enable(rtc, 0); - rtc_irq_set_state(rtc, NULL, 0); + rtc_irq_set_state(rtc, 0); clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags); return 0; diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 8cc23fdfd4ee..bf4d375025d1 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -202,10 +202,8 @@ extern void rtc_update_irq(struct rtc_device *rtc, extern struct rtc_device *rtc_class_open(const char *name); extern void rtc_class_close(struct rtc_device *rtc); -extern int rtc_irq_set_state(struct rtc_device *rtc, - struct rtc_task *task, int enabled); -extern int rtc_irq_set_freq(struct rtc_device *rtc, - struct rtc_task *task, int freq); +extern int rtc_irq_set_state(struct rtc_device *rtc, int enabled); +extern int rtc_irq_set_freq(struct rtc_device *rtc, int freq); extern int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled); extern int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled); extern int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc, -- cgit v1.2.3-70-g09d2 From 5a5ba10f44fa1cd081cec38389e1b47f438fe25b Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Thu, 26 Jul 2018 15:40:56 +0200 Subject: rtc: remove struct rtc_task Include rtc_task members directly in rtc_timer member. Signed-off-by: Alexandre Belloni --- drivers/rtc/interface.c | 8 ++++---- include/linux/rtc.h | 9 ++------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index d0983ed6c842..a962540faf2e 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -912,8 +912,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 */ @@ -968,8 +968,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 diff --git a/include/linux/rtc.h b/include/linux/rtc.h index bf4d375025d1..6aedc30003e7 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -87,16 +87,11 @@ struct rtc_class_ops { int (*set_offset)(struct device *, long offset); }; -typedef struct rtc_task { - void (*func)(void *private_data); - void *private_data; -} rtc_task_t; - - struct rtc_timer { - struct rtc_task task; struct timerqueue_node node; ktime_t period; + void (*func)(void *private_data); + void *private_data; int enabled; }; -- cgit v1.2.3-70-g09d2