mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 10:49:28 +00:00
rtc: add alarm/update irq interfaces
Add standard interfaces for alarm/update irqs enabling. Drivers are no more required to implement equivalent ioctl code as rtc-dev will provide it. UIE emulation should now be handled correctly and will work even for those RTC drivers who cannot be configured to do both UIE and AIE. Signed-off-by: Alessandro Zummo <a.zummo@towertech.it> Cc: David Brownell <david-b@pacbell.net> Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Cc: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
54566b2c15
commit
099e657625
4 changed files with 101 additions and 18 deletions
|
@ -307,6 +307,60 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(rtc_set_alarm);
|
||||
|
||||
int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
|
||||
{
|
||||
int err = mutex_lock_interruptible(&rtc->ops_lock);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!rtc->ops)
|
||||
err = -ENODEV;
|
||||
else if (!rtc->ops->alarm_irq_enable)
|
||||
err = -EINVAL;
|
||||
else
|
||||
err = rtc->ops->alarm_irq_enable(rtc->dev.parent, enabled);
|
||||
|
||||
mutex_unlock(&rtc->ops_lock);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rtc_alarm_irq_enable);
|
||||
|
||||
int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
|
||||
{
|
||||
int err = mutex_lock_interruptible(&rtc->ops_lock);
|
||||
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, enabled);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!rtc->ops)
|
||||
err = -ENODEV;
|
||||
else if (!rtc->ops->update_irq_enable)
|
||||
err = -EINVAL;
|
||||
else
|
||||
err = rtc->ops->update_irq_enable(rtc->dev.parent, enabled);
|
||||
|
||||
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;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rtc_update_irq_enable);
|
||||
|
||||
/**
|
||||
* rtc_update_irq - report RTC periodic, alarm, and/or update irqs
|
||||
* @rtc: the rtc device
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue