···15#include <linux/mc146818rtc.h>16#include <linux/rtc.h>17#include <linux/bcd.h>01819#define RTC_PIE 0x40 /* periodic interrupt enable */20#define RTC_AIE 0x20 /* alarm interrupt enable */···4445static inline unsigned int get_rtc_time(struct rtc_time *time)46{47- unsigned long uip_watchdog = jiffies;48 unsigned char ctrl;49 unsigned long flags;50···5354 /*55 * read RTC once any update in progress is done. The update56- * can take just over 2ms. We wait 10 to 20ms. There is no need to57 * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP.58 * If you need to know *exactly* when a second has started, enable59 * periodic update complete interrupts, (via ioctl) and then 60 * immediately read /dev/rtc which will block until you get the IRQ.61 * Once the read clears, read the RTC time (again via ioctl). Easy.62 */63-64- if (rtc_is_updating() != 0)65- while (jiffies - uip_watchdog < 2*HZ/100) {66- barrier();67- cpu_relax();68- }6970 /*71 * Only the values that we read from the RTC are set. We leave
···15#include <linux/mc146818rtc.h>16#include <linux/rtc.h>17#include <linux/bcd.h>18+#include <linux/delay.h>1920#define RTC_PIE 0x40 /* periodic interrupt enable */21#define RTC_AIE 0x20 /* alarm interrupt enable */···4344static inline unsigned int get_rtc_time(struct rtc_time *time)45{046 unsigned char ctrl;47 unsigned long flags;48···5354 /*55 * read RTC once any update in progress is done. The update56+ * can take just over 2ms. We wait 20ms. There is no need to57 * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP.58 * If you need to know *exactly* when a second has started, enable59 * periodic update complete interrupts, (via ioctl) and then 60 * immediately read /dev/rtc which will block until you get the IRQ.61 * Once the read clears, read the RTC time (again via ioctl). Easy.62 */63+ if (rtc_is_updating())64+ mdelay(20);00006566 /*67 * Only the values that we read from the RTC are set. We leave