diff options
author | Len Brown <len.brown@intel.com> | 2009-01-09 03:39:43 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-01-09 03:39:43 -0500 |
commit | b2576e1d4408e134e2188c967b1f28af39cd79d4 (patch) | |
tree | 004f3c82faab760f304ce031d6d2f572e7746a50 /drivers/rtc/interface.c | |
parent | 3cc8a5f4ba91f67bbdb81a43a99281a26aab8d77 (diff) | |
parent | 2150edc6c5cf00f7adb54538b9ea2a3e9cedca3f (diff) |
Merge branch 'linus' into release
Diffstat (limited to 'drivers/rtc/interface.c')
-rw-r--r-- | drivers/rtc/interface.c | 70 |
1 files changed, 63 insertions, 7 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index a04c1b6b1575..4348c4b0d453 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -50,10 +50,15 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) | |||
50 | 50 | ||
51 | if (!rtc->ops) | 51 | if (!rtc->ops) |
52 | err = -ENODEV; | 52 | err = -ENODEV; |
53 | else if (!rtc->ops->set_time) | 53 | else if (rtc->ops->set_time) |
54 | err = -EINVAL; | ||
55 | else | ||
56 | err = rtc->ops->set_time(rtc->dev.parent, tm); | 54 | err = rtc->ops->set_time(rtc->dev.parent, tm); |
55 | else if (rtc->ops->set_mmss) { | ||
56 | unsigned long secs; | ||
57 | err = rtc_tm_to_time(tm, &secs); | ||
58 | if (err == 0) | ||
59 | err = rtc->ops->set_mmss(rtc->dev.parent, secs); | ||
60 | } else | ||
61 | err = -EINVAL; | ||
57 | 62 | ||
58 | mutex_unlock(&rtc->ops_lock); | 63 | mutex_unlock(&rtc->ops_lock); |
59 | return err; | 64 | return err; |
@@ -307,6 +312,60 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
307 | } | 312 | } |
308 | EXPORT_SYMBOL_GPL(rtc_set_alarm); | 313 | EXPORT_SYMBOL_GPL(rtc_set_alarm); |
309 | 314 | ||
315 | int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled) | ||
316 | { | ||
317 | int err = mutex_lock_interruptible(&rtc->ops_lock); | ||
318 | if (err) | ||
319 | return err; | ||
320 | |||
321 | if (!rtc->ops) | ||
322 | err = -ENODEV; | ||
323 | else if (!rtc->ops->alarm_irq_enable) | ||
324 | err = -EINVAL; | ||
325 | else | ||
326 | err = rtc->ops->alarm_irq_enable(rtc->dev.parent, enabled); | ||
327 | |||
328 | mutex_unlock(&rtc->ops_lock); | ||
329 | return err; | ||
330 | } | ||
331 | EXPORT_SYMBOL_GPL(rtc_alarm_irq_enable); | ||
332 | |||
333 | int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled) | ||
334 | { | ||
335 | int err = mutex_lock_interruptible(&rtc->ops_lock); | ||
336 | if (err) | ||
337 | return err; | ||
338 | |||
339 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL | ||
340 | if (enabled == 0 && rtc->uie_irq_active) { | ||
341 | mutex_unlock(&rtc->ops_lock); | ||
342 | return rtc_dev_update_irq_enable_emul(rtc, enabled); | ||
343 | } | ||
344 | #endif | ||
345 | |||
346 | if (!rtc->ops) | ||
347 | err = -ENODEV; | ||
348 | else if (!rtc->ops->update_irq_enable) | ||
349 | err = -EINVAL; | ||
350 | else | ||
351 | err = rtc->ops->update_irq_enable(rtc->dev.parent, enabled); | ||
352 | |||
353 | mutex_unlock(&rtc->ops_lock); | ||
354 | |||
355 | #ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL | ||
356 | /* | ||
357 | * Enable emulation if the driver did not provide | ||
358 | * the update_irq_enable function pointer or if returned | ||
359 | * -EINVAL to signal that it has been configured without | ||
360 | * interrupts or that are not available at the moment. | ||
361 | */ | ||
362 | if (err == -EINVAL) | ||
363 | err = rtc_dev_update_irq_enable_emul(rtc, enabled); | ||
364 | #endif | ||
365 | return err; | ||
366 | } | ||
367 | EXPORT_SYMBOL_GPL(rtc_update_irq_enable); | ||
368 | |||
310 | /** | 369 | /** |
311 | * rtc_update_irq - report RTC periodic, alarm, and/or update irqs | 370 | * rtc_update_irq - report RTC periodic, alarm, and/or update irqs |
312 | * @rtc: the rtc device | 371 | * @rtc: the rtc device |
@@ -335,7 +394,7 @@ static int __rtc_match(struct device *dev, void *data) | |||
335 | { | 394 | { |
336 | char *name = (char *)data; | 395 | char *name = (char *)data; |
337 | 396 | ||
338 | if (strncmp(dev->bus_id, name, BUS_ID_SIZE) == 0) | 397 | if (strcmp(dev_name(dev), name) == 0) |
339 | return 1; | 398 | return 1; |
340 | return 0; | 399 | return 0; |
341 | } | 400 | } |
@@ -450,9 +509,6 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq) | |||
450 | if (rtc->ops->irq_set_freq == NULL) | 509 | if (rtc->ops->irq_set_freq == NULL) |
451 | return -ENXIO; | 510 | return -ENXIO; |
452 | 511 | ||
453 | if (!is_power_of_2(freq)) | ||
454 | return -EINVAL; | ||
455 | |||
456 | spin_lock_irqsave(&rtc->irq_task_lock, flags); | 512 | spin_lock_irqsave(&rtc->irq_task_lock, flags); |
457 | if (rtc->irq_task != NULL && task == NULL) | 513 | if (rtc->irq_task != NULL && task == NULL) |
458 | err = -EBUSY; | 514 | err = -EBUSY; |