RTC updates
cover RTC updates
This patch series fixes a bug in the RTC core and adds support for the WM8350 RTC. The bug fix is required for the WM8350 driver since it does not support configuration of the year for alarms, triggering the need to handle year wraparound when reporting the alarm status.
PATCH 1/2 rtc: Fix handling of missing tm_year data when reading alarms
When fixing up invalid years rtc_read_alarm() was calling rtc_valid_tm() as a boolean but rtc_valid_tm() returns zero on success or a negative number if the time is not valid so the test was inverted.
--- drivers/rtc/interface.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/rtc/interface.c +1 -1
@@ -271,7 +271,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)dev_dbg (&rtc->dev,"alarm rollover: %s\n" ,"year" );do { alarm->time.tm_year++; - }while (!rtc_valid_tm (&alarm->time)); + }while (rtc_valid_tm (&alarm->time) !=0 );break ;default :
Signature · 1 line
1.5.6.5
PATCH 2/2 rtc: rtc-wm8350: Add support for WM8350 RTC
This adds support for the RTC provided by the Wolfson Microelectronics WM8350.
This driver was originally written by Graeme Gregory and Liam Girdwood, though it has been modified since then to update it to current mainline coding standards and for API completeness.
--- drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-wm8350.c | 515 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/wm8350/rtc.h | 2 + 4 files changed, 528 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-wm8350.c
drivers/rtc/Kconfig +10 -0
@@ -458,6 +458,16 @@ config RTC_DRV_V3020 This driver can also be built as a module. If so, the module will be called rtc-v3020. +config RTC_DRV_WM8350 + tristate "Wolfson Microelectronics WM8350 RTC" + depends on MFD_WM8350 + help + If you say yes here you will get support for the RTC subsystem + of the Wolfson Microelectronics WM8350. + + This driver can also be built as a module. If so, the module + will be called "rtc-wm8350". + comment "on-CPU RTC drivers" config RTC_DRV_OMAP
drivers/rtc/Makefile +1 -0
@@ -64,4 +64,5 @@ obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
drivers/rtc/rtc-wm8350.c new file +515 -0
515 lines not on this page · raw message
include/linux/mfd/wm8350/rtc.h +2 -0
@@ -261,6 +261,8 @@struct wm8350_rtc {struct platform_device *pdev; +struct rtc_device *rtc; +int alarm_enabled;/* used over suspend/resume */ };#endif
Signature · 1 line
1.5.6.5
Re: [PATCH 2/2] rtc: rtc-wm8350: Add support for WM8350 RTC
Quoted 6 lines · On Mon, 20 Oct 2008 20:35:18 +0100 Mark Brown…
drivers/rtc/rtc-wm8350.c new file +6
-0+static int wm8350_rtc_stop_alarm (struct wm8350 *wm8350) +{ +int retries =WM8350_SET_ALM_RETRIES ; +u16 rtc_ctrl; +int ret; +
drivers/rtc/rtc-wm8350.c line 207
Quoted 10 lines
drivers/rtc/rtc-wm8350.c new file +10
-0+/* Set RTC_SET to stop the clock */ + ret =wm8350_set_bits (wm8350,WM8350_RTC_TIME_CONTROL , +WM8350_RTC_ALMSET ); +if (ret <0 ) +return ret; + +/* Wait until confirmation of stopping */ + do { + rtc_ctrl = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL); + schedule_timeout_interruptible(msecs_to_jiffies(1));
If the calling process has signal_pending() (eg: someone typed ^C) then schedule_timeout_interruptible() will return immediately.
drivers/rtc/rtc-wm8350.c line 211
Quoted 4 lines
drivers/rtc/rtc-wm8350.c new file +4
-0+ }while (retries-- && !(rtc_ctrl &WM8350_RTC_ALMSTS )); + +if (!(rtc_ctrl &WM8350_RTC_ALMSTS )) +return -ETIMEDOUT ;
And the driver will incorrectly return -ETIMEDOUT.
Quoted 12 lines
drivers/rtc/rtc-wm8350.c new file +12
-0+return 0 ; +} + +static int wm8350_rtc_start_alarm (struct wm8350 *wm8350) +{ +int ret; +int retries =WM8350_SET_ALM_RETRIES ; +u16 rtc_ctrl; + + ret =wm8350_clear_bits (wm8350,WM8350_RTC_TIME_CONTROL , +WM8350_RTC_ALMSET ); +if (ret <0 )
drivers/rtc/rtc-wm8350.c line 234
Quoted 10 lines
drivers/rtc/rtc-wm8350.c new file +10
-0+return ret; + +/* Wait until confirmation */ +do { + rtc_ctrl =wm8350_reg_read (wm8350,WM8350_RTC_TIME_CONTROL ); +schedule_timeout_interruptible (msecs_to_jiffies (1 )); + }while (retries-- && rtc_ctrl &WM8350_RTC_ALMSTS ); + +if (rtc_ctrl &WM8350_RTC_ALMSTS ) +return -ETIMEDOUT ;
ditto.
Review
Quoted 2 lines
(quoted diff) +2
-0+ return 0; +}
I'll switch those to schedule_timeout_uninterruptible(), OK?
Re: [PATCH 2/2] rtc: rtc-wm8350: Add support for WM8350 RTC
Quoted 1 line · Andrew Morton
I'll switch those to
schedule_timeout_uninterruptible(), OK?
OK.