static int ds1553_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) { struct platform_device *pdev = to_platform_device(dev); struct rtc_plat_data *pdata = platform_get_drvdata(pdev); if (pdata->irq < 0) return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */ switch (cmd) { case RTC_AIE_OFF: pdata->irqen &= ~RTC_AF; ds1553_rtc_update_alarm(pdata); break; case RTC_AIE_ON: pdata->irqen |= RTC_AF; ds1553_rtc_update_alarm(pdata); break; case RTC_UIE_OFF: pdata->irqen &= ~RTC_UF; ds1553_rtc_update_alarm(pdata); break; case RTC_UIE_ON: pdata->irqen |= RTC_UF; ds1553_rtc_update_alarm(pdata); break; default: return -ENOIOCTLCMD; } return 0; }
static void ds1553_rtc_release(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct rtc_plat_data *pdata = platform_get_drvdata(pdev); if (pdata->irq >= 0) { pdata->irqen = 0; ds1553_rtc_update_alarm(pdata); } }
static int ds1553_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) { struct platform_device *pdev = to_platform_device(dev); struct rtc_plat_data *pdata = platform_get_drvdata(pdev); if (pdata->irq <= 0) return -EINVAL; if (enabled) pdata->irqen |= RTC_AF; else pdata->irqen &= ~RTC_AF; ds1553_rtc_update_alarm(pdata); return 0; }
static int ds1553_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) { struct platform_device *pdev = to_platform_device(dev); struct rtc_plat_data *pdata = platform_get_drvdata(pdev); if (pdata->irq <= 0) return -EINVAL; pdata->alrm_mday = alrm->time.tm_mday; pdata->alrm_hour = alrm->time.tm_hour; pdata->alrm_min = alrm->time.tm_min; pdata->alrm_sec = alrm->time.tm_sec; if (alrm->enabled) pdata->irqen |= RTC_AF; ds1553_rtc_update_alarm(pdata); return 0; }