Final RTC fixes for 2.6.38
Linus,
Please pull the latest rtc-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git rtc-for-linus
I wish it was samller, but it turned out due to recent bug reports that the UIE emulation is necessary for some of the RTC chips.
Thanks,
tglx
------------------>
John Stultz (2):
RTC: Revert UIE emulation removal
RTC: Re-enable UIE timer/polling emulation
Uwe Kleine-König (1):
RTC: Release mutex in error path of rtc_alarm_irq_enable
drivers/rtc/Kconfig | 12 +++++ drivers/rtc/interface.c | 23 +++++++++-- drivers/rtc/rtc-dev.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/rtc.h | 15 +++++++ 4 files changed, 150 insertions(+), 4 deletions(-)
drivers/rtc/Kconfig +12 -0
@@ -97,6 +97,18 @@ config RTC_INTF_DEV If unsure, say Y. +config RTC_INTF_DEV_UIE_EMUL + bool "RTC UIE emulation on dev interface" + depends on RTC_INTF_DEV + help + Provides an emulation for RTC_UIE if the underlying rtc chip + driver does not expose RTC_UIE ioctls. Those requests generate + once-per-second update interrupts, used for synchronization. + + The emulation code will read the time from the hardware + clock several times per second, please enable this option + only if you know that you really need it. + config RTC_DRV_TEST tristate "Test driver/device" help
drivers/rtc/interface.c +19 -4
@@ -209,9 +209,8 @@ int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled) }if (err) -return err; - -if (!rtc->ops) +/* nothing */ ; +else if (!rtc->ops) err = -ENODEV ;else if (!rtc->ops->alarm_irq_enable) err = -EINVAL ;
@@ -229,6 +228,12 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)if (err)return err; +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL +if (enabled ==0 && rtc->uie_irq_active) { +mutex_unlock (&rtc->ops_lock); +return rtc_dev_update_irq_enable_emul (rtc,0 ); + } +#endif /* make sure we're changing state */ if (rtc->uie_rtctimer.enabled == enabled) goto out;
@@ -248,6 +253,16 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled) out:mutex_unlock (&rtc->ops_lock); +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL +/* +* Enable emulation if the driver did not provide +* the update_irq_enable function pointer or if returned +* -EINVAL to signal that it has been configured without +* interrupts or that are not available at the moment. +*/ +if (err == -EINVAL ) + err =rtc_dev_update_irq_enable_emul (rtc, enabled); +#endif return err; }
@@ -263,7 +278,7 @@ EXPORT_SYMBOL_GPL(rtc_update_irq_enable);* * Triggers the registered irq_task function callback. */ -static void rtc_handle_legacy_irq (struct rtc_device *rtc,int num,int mode) +void rtc_handle_legacy_irq (struct rtc_device *rtc,int num,int mode) {unsigned long flags;
drivers/rtc/rtc-dev.c +104 -0
116 lines not on this page · raw message
include/linux/rtc.h +15 -0
@@ -203,6 +203,18 @@ struct rtc_devicestruct hrtimer pie_timer;/* sub second exp, so needs hrtimer */ int pie_enabled;struct work_struct irqwork; + + +#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL +struct work_struct uie_task; +struct timer_list uie_timer; +/* Those fields are protected by rtc->irq_lock */ +unsigned int oldsecs; + unsigned int uie_irq_active:1; + unsigned int stop_uie_polling:1; + unsigned int uie_task_active:1; + unsigned int uie_timer_active:1; +#endif };#define to_rtc_device (d) container_of(d, struct rtc_device, dev)
@@ -235,7 +247,10 @@ extern int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, 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, +unsigned int enabled); +void rtc_handle_legacy_irq (struct rtc_device *rtc,int num,int mode);void rtc_aie_update_irq (void *private);void rtc_uie_update_irq (void *private);enum hrtimer_restart rtc_pie_update_irq (struct hrtimer *timer);