rtc: cleanup task handling
Subsystems (2)
Alexandre Belloni
maintainercover rtc: cleanup task handling
Hi,
This series drops the now unused periodic task handling. It has been used in total by 3 drivers that were dropped and mainly replaced by kernel timers.
This allows to also remove a few rtc_device struct members and struct rtc_task.
Tested using rtcpie and rtctest.
Alexandre Belloni (8):
rtc: sa1100: don't set PIE frequency
rtc: sh: remove dead code
rtc: remove rtc_irq_register/rtc_irq_unregister
rtc: remove irq_task and irq_task_lock
rtc: simplify rtc_irq_set_state/rtc_irq_set_freq
rtc: unexport rtc_irq_set_*
char: rtc: remove task handling
rtc: remove struct rtc_task
drivers/char/rtc.c | 13 ------ drivers/rtc/class.c | 1 - drivers/rtc/interface.c | 97 +++++++--------------------------------- drivers/rtc/rtc-dev.c | 8 ++-- drivers/rtc/rtc-sa1100.c | 1 - drivers/rtc/rtc-sh.c | 89 +----------------------------------- include/linux/rtc.h | 21 ++------- 7 files changed, 25 insertions(+), 205 deletions(-)
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH 1/8 rtc: sa1100: don't set PIE frequency
It doesn't make sense to set the PIE frequency from the driver. Let userspace do its job.
--- drivers/rtc/rtc-sa1100.c | 1 - 1 file changed, 1 deletion(-)
drivers/rtc/rtc-sa1100.c +0 -1
@@ -224,7 +224,6 @@ int sa1100_rtc_init(struct platform_device *pdev, struct sa1100_rtc *info) info->rtc = rtc; rtc->max_user_freq =RTC_FREQ ; -rtc_irq_set_freq (rtc,NULL ,RTC_FREQ );/* Fix for a nasty initialization problem the in SA11xx RTSR register. * See also the comments in sa1100_rtc_interrupt().
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH 4/8 rtc: remove irq_task and irq_task_lock
In reply to Alexandre BelloniThere is no way to set a periodic task anymore, remove task pointer and lock.
--- drivers/rtc/class.c | 1 - drivers/rtc/interface.c | 50 +++++++++-------------------------------- include/linux/rtc.h | 2 -- 3 files changed, 10 insertions(+), 43 deletions(-)
drivers/rtc/class.c +0 -1
@@ -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 */
drivers/rtc/interface.c +10 -40
82 lines not on this page · raw message
include/linux/rtc.h +0 -2
@@ -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;
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH 6/8 rtc: unexport rtc_irq_set_*
In reply to Alexandre BelloniMake the rtc_irq_set interface internale to the RTC subsystem.
--- drivers/rtc/interface.c | 2 -- 1 file changed, 2 deletions(-)
drivers/rtc/interface.c +0 -2
@@ -758,7 +758,6 @@ int rtc_irq_set_state(struct rtc_device *rtc, int 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
@@ -784,7 +783,6 @@ int rtc_irq_set_freq(struct rtc_device *rtc, int freq)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
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH 7/8 char: rtc: remove task handling
In reply to Alexandre BelloniSince commit 9e7002a70e42 ("char: rtc: remove unused rtc_control() API"), it is not possible to set a callback anymore, remove its handling from the interrupt handler.
---
Hi,
My plan is to take that patch through the RTC tree because the next patch relies on the rtc_task_t *rtc_callback removal.
drivers/char/rtc.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/char/rtc.c +0 -13
@@ -193,14 +193,6 @@ static unsigned long rtc_freq; /* Current periodic IRQ rate */static unsigned long rtc_irq_data;/* our output to the world */ static unsigned long rtc_max_user_freq =64 ;/* > this, need CAP_SYS_RESOURCE */ -#ifdef RTC_IRQ -/* -* rtc_task_lock nests inside rtc_lock. -*/ -static DEFINE_SPINLOCK (rtc_task_lock); -static rtc_task_t *rtc_callback; -#endif -/* * If this driver ever becomes modularised, it will be really nice * to make the epoch retain its value across module reload...
@@ -264,11 +256,6 @@ static irqreturn_t rtc_interrupt(int irq, void *dev_id)spin_unlock (&rtc_lock); -/* Now do the rest of the actions */ -spin_lock (&rtc_task_lock); -if (rtc_callback) - rtc_callback->func (rtc_callback->private_data); -spin_unlock (&rtc_task_lock);wake_up_interruptible (&rtc_wait);kill_fasync (&rtc_async_queue,SIGIO ,POLL_IN );
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH 8/8 rtc: remove struct rtc_task
In reply to Alexandre BelloniInclude rtc_task members directly in rtc_timer member.
--- drivers/rtc/interface.c | 8 ++++---- include/linux/rtc.h | 9 ++------- 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/rtc/interface.c +4 -4
@@ -912,8 +912,8 @@ void rtc_timer_do_work(struct work_struct *work)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
include/linux/rtc.h +2 -7
@@ -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; };
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH 5/8 rtc: simplify rtc_irq_set_state/rtc_irq_set_freq
In reply to Alexandre BelloniThe PIE doesn't handle tasks anymore, remove the pointer from the interface.
--- drivers/rtc/interface.c | 4 ++-- drivers/rtc/rtc-dev.c | 8 ++++---- include/linux/rtc.h | 6 ++---- 3 files changed, 8 insertions(+), 10 deletions(-)
drivers/rtc/interface.c +2 -2
@@ -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 ;
drivers/rtc/rtc-dev.c +4 -4
@@ -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 ;
include/linux/rtc.h +2 -4
@@ -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,
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH 2/8 rtc: sh: remove dead code
In reply to Alexandre BelloniSince commit 80d4bb515b78 ("RTC: Cleanup rtc_class_ops->irq_set_state") and commit 696160fec162 ("RTC: Cleanup rtc_class_ops->irq_set_freq()"), sh_rtc_irq_set_state and sh_rtc_irq_set_freq are never called. Remove them along with task handling.
--- drivers/rtc/rtc-sh.c | 89 +------------------------------------------- 1 file changed, 1 insertion(+), 88 deletions(-)
drivers/rtc/rtc-sh.c +1 -88
@@ -143,7 +143,6 @@ static int __sh_rtc_alarm(struct sh_rtc *rtc)static int __sh_rtc_periodic (struct sh_rtc *rtc) {struct rtc_device *rtc_dev = rtc->rtc_dev; -struct rtc_task *irq_task;unsigned int tmp, pending; tmp =readb (rtc->regbase +RCR2 );
@@ -160,14 +159,7 @@ static int __sh_rtc_periodic(struct sh_rtc *rtc)else {if (rtc->periodic_freq &PF_HP ) rtc->periodic_freq |=PF_COUNT ; -if (rtc->periodic_freq &PF_KOU ) { -spin_lock (&rtc_dev->irq_task_lock); - irq_task = rtc_dev->irq_task; -if (irq_task) - irq_task->func (irq_task->private_data); -spin_unlock (&rtc_dev->irq_task_lock); - }else -rtc_update_irq (rtc->rtc_dev,1 ,RTC_PF |RTC_IRQF ); +rtc_update_irq (rtc->rtc_dev,1 ,RTC_PF |RTC_IRQF ); }return pending;
@@ -223,81 +215,6 @@ static irqreturn_t sh_rtc_shared(int irq, void *dev_id)return IRQ_RETVAL (ret); } -static int sh_rtc_irq_set_state (struct device *dev,int enable) -{ -struct sh_rtc *rtc =dev_get_drvdata (dev); -unsigned int tmp; - -spin_lock_irq (&rtc->lock); - - tmp =readb (rtc->regbase +RCR2 ); - -if (enable) { - rtc->periodic_freq |=PF_KOU ; - tmp &= ~RCR2_PEF ;/* Clear PES bit */ - tmp |= (rtc->periodic_freq & ~PF_HP );/* Set PES2-0 */ - }else { - rtc->periodic_freq &= ~PF_KOU ; - tmp &= ~(RCR2_PESMASK |RCR2_PEF ); - } - -writeb (tmp, rtc->regbase +RCR2 ); - -spin_unlock_irq (&rtc->lock); - -return 0 ; -} - -static int sh_rtc_irq_set_freq (struct device *dev,int freq) -{ -struct sh_rtc *rtc =dev_get_drvdata (dev); -int tmp, ret =0 ; - -spin_lock_irq (&rtc->lock); - tmp = rtc->periodic_freq &PF_MASK ; - -switch (freq) { -case 0 : - rtc->periodic_freq =0x00 ; -break ; -case 1 : - rtc->periodic_freq =0x60 ; -break ; -case 2 : - rtc->periodic_freq =0x50 ; -break ; -case 4 : - rtc->periodic_freq =0x40 ; -break ; -case 8 : - rtc->periodic_freq =0x30 |PF_HP ; -break ; -case 16 : - rtc->periodic_freq =0x30 ; -break ; -case 32 : - rtc->periodic_freq =0x20 |PF_HP ; -break ; -case 64 : - rtc->periodic_freq =0x20 ; -break ; -case 128 : - rtc->periodic_freq =0x10 |PF_HP ; -break ; -case 256 : - rtc->periodic_freq =0x10 ; -break ; -default : - ret = -ENOTSUPP ; - } - -if (ret ==0 ) - rtc->periodic_freq |= tmp; - -spin_unlock_irq (&rtc->lock); -return ret; -} -static inline void sh_rtc_setaie (struct device *dev,unsigned int enable) {struct sh_rtc *rtc =dev_get_drvdata (dev);
@@ -674,8 +591,6 @@ static int __init sh_rtc_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rtc);/* everything disabled by default */ -sh_rtc_irq_set_freq (&pdev->dev,0 ); -sh_rtc_irq_set_state (&pdev->dev,0 );sh_rtc_setaie (&pdev->dev,0 );sh_rtc_setcie (&pdev->dev,0 );
@@ -707,8 +622,6 @@ static int __exit sh_rtc_remove(struct platform_device *pdev) {struct sh_rtc *rtc =platform_get_drvdata (pdev); -sh_rtc_irq_set_state (&pdev->dev,0 ); -sh_rtc_setaie (&pdev->dev,0 );sh_rtc_setcie (&pdev->dev,0 );
Signature · 1 line
2.18.0
Alexandre Belloni
maintainerPATCH 3/8 rtc: remove rtc_irq_register/rtc_irq_unregister
In reply to Alexandre BelloniThe rtc_irq_* interface is not used from outside the RTC subsytem since 2016.
--- drivers/rtc/interface.c | 33 --------------------------------- include/linux/rtc.h | 4 ---- 2 files changed, 37 deletions(-)
drivers/rtc/interface.c +0 -33
@@ -719,39 +719,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) {/*
include/linux/rtc.h +0 -4
@@ -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,
Signature · 1 line
2.18.0
Re: [PATCH 7/8] char: rtc: remove task handling
In reply to Alexandre BelloniQuoted 4 lines · Alexandre Belloni
Since commit
9e7002a70e42("char: rtc: remove unusedrtc_control()API"), it is not possible to set a callback anymore, remove its handling from the interrupt handler.
Quoted 8 lines
Cc Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Signed-off-by Alexandre Belloni <[email protected]>---
Hi,My plan is to take that patch through the RTC tree because the next patch relies on the
rtc_task_t*rtc_callbackremoval.
Arnd Bergmann
maintainerRe: [PATCH 8/8] rtc: remove struct rtc_task
In reply to Alexandre BelloniQuoted 25 lines · Alexandre Belloni
Include
rtc_taskmembers directly inrtc_timermember.Signed-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/interface.c | 8 ++++---- include/linux/rtc.h | 9 ++------- 2 files changed, 6 insertions(+), 11 deletions(-)drivers/rtc/interface.c +2
-2@@ -912,8 +912,8 @@ void rtc_timer_do_work(struct work_struct *work)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 */
drivers/rtc/interface.c void rtc_timer_init(struct rtc_timer *timer, void (*f)(void *p), void *data) · line 973
Quoted 8 lines
drivers/rtc/interface.c +2
-2@@ -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; }
From what I can see, all remaining users pass the rtc_device pointer as 'private_data', so maybe make that explicit now instead of the void pointer?
Arnd