Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-3.10.git] / arch / powerpc / kernel / time.c
index 8b278d85ca4ed24b44f8b93f33257f79f6d3294c..85b9244a098c79d76373e4d75eef1cbe54a8a395 100644 (file)
@@ -1041,6 +1041,48 @@ void __init time_init(void)
        set_dec(tb_ticks_per_jiffy);
 }
 
+#ifdef CONFIG_RTC_CLASS
+static int set_rtc_class_time(struct rtc_time *tm)
+{
+       int err;
+       struct class_device *class_dev =
+               rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+
+       if (class_dev == NULL)
+               return -ENODEV;
+
+       err = rtc_set_time(class_dev, tm);
+
+       rtc_class_close(class_dev);
+
+       return 0;
+}
+
+static void get_rtc_class_time(struct rtc_time *tm)
+{
+       int err;
+       struct class_device *class_dev =
+               rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+
+       if (class_dev == NULL)
+               return;
+
+       err = rtc_read_time(class_dev, tm);
+
+       rtc_class_close(class_dev);
+
+       return;
+}
+
+int __init rtc_class_hookup(void)
+{
+       ppc_md.get_rtc_time = get_rtc_class_time;
+       ppc_md.set_rtc_time = set_rtc_class_time;
+
+       return 0;
+}
+#endif /* CONFIG_RTC_CLASS */
+
 
 #define FEBRUARY       2
 #define        STARTOFTIME     1970