During shutdown/reboot process, its better to
finish any pending irqwork so that the work is
not scheduled after devices like i2c are shutdown.
This patch provides hook to be called from rtc driver after disabling
rtc irq. Also any further request to access rtc_class_ops will
be prohibited.
Bug
200072946
Change-Id: I8eb20e5214a31fbc8a280ccfff8e190a5fabbb96
Signed-off-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-on: http://git-master/r/677758
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
rtc->dev.parent = dev;
rtc->dev.class = rtc_class;
rtc->dev.release = rtc_device_release;
+ rtc->system_shutting = false;
mutex_init(&rtc->ops_lock);
spin_lock_init(&rtc->irq_lock);
}
EXPORT_SYMBOL_GPL(rtc_device_unregister);
+/**
+ * rtc_device_shutdown - flush any pending irq workqueue
+ *
+ * @rtc: the RTC class device to cancel pending work
+ */
+void rtc_device_shutdown(struct rtc_device *rtc)
+{
+ cancel_work_sync(&rtc->irqwork);
+ rtc->system_shutting = true;
+}
+EXPORT_SYMBOL_GPL(rtc_device_shutdown);
+
static void devm_rtc_device_release(struct device *dev, void *res)
{
struct rtc_device *rtc = *(struct rtc_device **)res;
{
int err;
+ if (unlikely(rtc->system_shutting))
+ return -ESHUTDOWN;
err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
return err;
{
int err;
+ if (unlikely(rtc->system_shutting))
+ return -ESHUTDOWN;
err = rtc_valid_tm(tm);
if (err != 0)
return err;
{
int err;
+ if (unlikely(rtc->system_shutting))
+ return -ESHUTDOWN;
err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
return err;
{
int err;
+ if (unlikely(rtc->system_shutting))
+ return -ESHUTDOWN;
err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
return err;
{
int err;
+ if (unlikely(rtc->system_shutting))
+ return -ESHUTDOWN;
err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
return err;
{
int err;
+ if (unlikely(rtc->system_shutting))
+ return -ESHUTDOWN;
err = rtc_valid_tm(&alarm->time);
if (err != 0)
return err;
int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
{
- int err = mutex_lock_interruptible(&rtc->ops_lock);
+ int err;
+
+ if (unlikely(rtc->system_shutting))
+ return -ESHUTDOWN;
+ err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
return err;
int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
{
- int err = mutex_lock_interruptible(&rtc->ops_lock);
+ int err;
+
+ if (unlikely(rtc->system_shutting))
+ return -ESHUTDOWN;
+ err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
return err;
struct work_struct irqwork;
/* Some hardware can't support UIE mode */
int uie_unsupported;
+ bool system_shutting;
#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
struct work_struct uie_task;
extern void rtc_device_unregister(struct rtc_device *rtc);
extern void devm_rtc_device_unregister(struct device *dev,
struct rtc_device *rtc);
+void rtc_device_shutdown(struct rtc_device *rtc);
extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm);
extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm);