* the best guess is to add 0.5s.
*/
-static int rtc_hctosys(void)
+static void rtc_hctosys(struct rtc_device *rtc)
{
int err = -ENODEV;
struct rtc_time tm;
struct timespec64 tv64 = {
.tv_nsec = NSEC_PER_SEC >> 1,
};
- struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
-
- if (!rtc) {
- pr_info("unable to open rtc device (%s)\n",
- CONFIG_RTC_HCTOSYS_DEVICE);
- goto err_open;
- }
err = rtc_read_time(rtc, &tm);
if (err) {
&tm, (long long)tv64.tv_sec);
err_read:
- rtc_class_close(rtc);
-
-err_open:
rtc_hctosys_ret = err;
-
- return err;
}
#endif
#ifdef CONFIG_RTC_HCTOSYS_DEVICE
if (!strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE))
- rtc_hctosys();
+ rtc_hctosys(rtc);
#endif
return 0;