diff options
Diffstat (limited to 'drivers/rtc/rtc-wm8350.c')
-rw-r--r-- | drivers/rtc/rtc-wm8350.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c index 5c5e3aa91385..c91edc572eb6 100644 --- a/drivers/rtc/rtc-wm8350.c +++ b/drivers/rtc/rtc-wm8350.c | |||
@@ -122,7 +122,7 @@ static int wm8350_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
122 | do { | 122 | do { |
123 | rtc_ctrl = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL); | 123 | rtc_ctrl = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL); |
124 | schedule_timeout_uninterruptible(msecs_to_jiffies(1)); | 124 | schedule_timeout_uninterruptible(msecs_to_jiffies(1)); |
125 | } while (retries-- && !(rtc_ctrl & WM8350_RTC_STS)); | 125 | } while (--retries && !(rtc_ctrl & WM8350_RTC_STS)); |
126 | 126 | ||
127 | if (!retries) { | 127 | if (!retries) { |
128 | dev_err(dev, "timed out on set confirmation\n"); | 128 | dev_err(dev, "timed out on set confirmation\n"); |
@@ -236,6 +236,17 @@ static int wm8350_rtc_start_alarm(struct wm8350 *wm8350) | |||
236 | return 0; | 236 | return 0; |
237 | } | 237 | } |
238 | 238 | ||
239 | static int wm8350_rtc_alarm_irq_enable(struct device *dev, | ||
240 | unsigned int enabled) | ||
241 | { | ||
242 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | ||
243 | |||
244 | if (enabled) | ||
245 | return wm8350_rtc_start_alarm(wm8350); | ||
246 | else | ||
247 | return wm8350_rtc_stop_alarm(wm8350); | ||
248 | } | ||
249 | |||
239 | static int wm8350_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | 250 | static int wm8350_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) |
240 | { | 251 | { |
241 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | 252 | struct wm8350 *wm8350 = dev_get_drvdata(dev); |
@@ -291,30 +302,15 @@ static int wm8350_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
291 | return ret; | 302 | return ret; |
292 | } | 303 | } |
293 | 304 | ||
294 | /* | 305 | static int wm8350_rtc_update_irq_enable(struct device *dev, |
295 | * Handle commands from user-space | 306 | unsigned int enabled) |
296 | */ | ||
297 | static int wm8350_rtc_ioctl(struct device *dev, unsigned int cmd, | ||
298 | unsigned long arg) | ||
299 | { | 307 | { |
300 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | 308 | struct wm8350 *wm8350 = dev_get_drvdata(dev); |
301 | 309 | ||
302 | switch (cmd) { | 310 | if (enabled) |
303 | case RTC_AIE_OFF: | ||
304 | return wm8350_rtc_stop_alarm(wm8350); | ||
305 | case RTC_AIE_ON: | ||
306 | return wm8350_rtc_start_alarm(wm8350); | ||
307 | |||
308 | case RTC_UIE_OFF: | ||
309 | wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
310 | break; | ||
311 | case RTC_UIE_ON: | ||
312 | wm8350_unmask_irq(wm8350, WM8350_IRQ_RTC_SEC); | 311 | wm8350_unmask_irq(wm8350, WM8350_IRQ_RTC_SEC); |
313 | break; | 312 | else |
314 | 313 | wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC); | |
315 | default: | ||
316 | return -ENOIOCTLCMD; | ||
317 | } | ||
318 | 314 | ||
319 | return 0; | 315 | return 0; |
320 | } | 316 | } |
@@ -345,11 +341,12 @@ static void wm8350_rtc_update_handler(struct wm8350 *wm8350, int irq, | |||
345 | } | 341 | } |
346 | 342 | ||
347 | static const struct rtc_class_ops wm8350_rtc_ops = { | 343 | static const struct rtc_class_ops wm8350_rtc_ops = { |
348 | .ioctl = wm8350_rtc_ioctl, | ||
349 | .read_time = wm8350_rtc_readtime, | 344 | .read_time = wm8350_rtc_readtime, |
350 | .set_time = wm8350_rtc_settime, | 345 | .set_time = wm8350_rtc_settime, |
351 | .read_alarm = wm8350_rtc_readalarm, | 346 | .read_alarm = wm8350_rtc_readalarm, |
352 | .set_alarm = wm8350_rtc_setalarm, | 347 | .set_alarm = wm8350_rtc_setalarm, |
348 | .alarm_irq_enable = wm8350_rtc_alarm_irq_enable, | ||
349 | .update_irq_enable = wm8350_rtc_update_irq_enable, | ||
353 | }; | 350 | }; |
354 | 351 | ||
355 | #ifdef CONFIG_PM | 352 | #ifdef CONFIG_PM |
@@ -440,7 +437,7 @@ static int wm8350_rtc_probe(struct platform_device *pdev) | |||
440 | do { | 437 | do { |
441 | timectl = wm8350_reg_read(wm8350, | 438 | timectl = wm8350_reg_read(wm8350, |
442 | WM8350_RTC_TIME_CONTROL); | 439 | WM8350_RTC_TIME_CONTROL); |
443 | } while (timectl & WM8350_RTC_STS && retries--); | 440 | } while (timectl & WM8350_RTC_STS && --retries); |
444 | 441 | ||
445 | if (retries == 0) { | 442 | if (retries == 0) { |
446 | dev_err(&pdev->dev, "failed to start: timeout\n"); | 443 | dev_err(&pdev->dev, "failed to start: timeout\n"); |