Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
[firefly-linux-kernel-4.4.55.git] / drivers / rtc / rtc-proc.c
index 0a59fda5c09d176c5fa0af1f90625c04a29232c4..e96236ac2e78a74cc9673f71ef8c07233343277f 100644 (file)
 
 #include "rtc-core.h"
 
+#define NAME_SIZE      10
+
+#if defined(CONFIG_RTC_HCTOSYS_DEVICE)
+static bool is_rtc_hctosys(struct rtc_device *rtc)
+{
+       int size;
+       char name[NAME_SIZE];
+
+       size = scnprintf(name, NAME_SIZE, "rtc%d", rtc->id);
+       if (size > NAME_SIZE)
+               return false;
+
+       return !strncmp(name, CONFIG_RTC_HCTOSYS_DEVICE, NAME_SIZE);
+}
+#else
+static bool is_rtc_hctosys(struct rtc_device *rtc)
+{
+       return (rtc->id == 0);
+}
+#endif
 
 static int rtc_proc_show(struct seq_file *seq, void *offset)
 {
@@ -117,12 +137,12 @@ static const struct file_operations rtc_proc_fops = {
 
 void rtc_proc_add_device(struct rtc_device *rtc)
 {
-       if (rtc->id == 0)
+       if (is_rtc_hctosys(rtc))
                proc_create_data("driver/rtc", 0, NULL, &rtc_proc_fops, rtc);
 }
 
 void rtc_proc_del_device(struct rtc_device *rtc)
 {
-       if (rtc->id == 0)
+       if (is_rtc_hctosys(rtc))
                remove_proc_entry("driver/rtc", NULL);
 }