Commit e28c0bf7 authored by Yu Liao's avatar Yu Liao Committed by Xiongfeng Wang
Browse files

rtc: Cleanup for UIE timer/polling emulation support

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBV6W4



--------------------------------

Split out a function that does not acquire ops_lock from
rtc_update_irq_enable, in preparation for fixing RTC_RD_TIME
and RTC_UIE_ON race problem.

Fixes: 7e7c005b ("rtc: disable uie before setting time and enable after")
Signed-off-by: default avatarYu Liao <liaoyu15@huawei.com>
Conflicts:
	drivers/rtc/interface.c
[wxf: Backport from OLK-5.10. Fix context conflicts]
Signed-off-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
parent d54ba3f5
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -554,18 +554,10 @@ int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
}
EXPORT_SYMBOL_GPL(rtc_alarm_irq_enable);

int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
int __rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
{
	int err = mutex_lock_interruptible(&rtc->ops_lock);
	if (err)
		return err;
	int err = 0;

#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;
@@ -589,6 +581,24 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
		rtc_timer_remove(rtc, &rtc->uie_rtctimer);

out:
	return err;

}

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, 0);
	}
#endif

	err = __rtc_update_irq_enable(rtc, enabled);
	mutex_unlock(&rtc->ops_lock);
#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
	/*
+1 −0
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ extern void rtc_class_close(struct rtc_device *rtc);
extern int rtc_irq_set_state(struct rtc_device *rtc, int enabled);
extern int rtc_irq_set_freq(struct rtc_device *rtc, int freq);
extern int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled);
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);