diff options
author | Kim, Milo <Milo.Kim@ti.com> | 2012-10-04 20:13:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-05 14:05:01 -0400 |
commit | 92589c986b3360ce15d239fd5113a856412a0b3f (patch) | |
tree | 8d15272df2c445c6ccbb7b1cd79847cf89b8d94d /drivers/rtc/rtc-proc.c | |
parent | 5fa44f86910ca9ee477cbd944c18f9349cdca30d (diff) |
rtc-proc: permit the /proc/driver/rtc device to use other devices
To get time information via /proc/driver/rtc, only the first device (rtc0)
is used. If the rtcN (eg. rtc1 or rtc2) is used for the system clock,
there is no way to get information of rtcN via /proc/driver/rtc. With
this patch, the time data can be retrieved from the system clock RTC.
If the RTC_HCTOSYS_DEVICE is not defined, then rtc0 is used by default.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-proc.c')
-rw-r--r-- | drivers/rtc/rtc-proc.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c index 0a59fda5c09d..e96236ac2e78 100644 --- a/drivers/rtc/rtc-proc.c +++ b/drivers/rtc/rtc-proc.c | |||
@@ -18,6 +18,26 @@ | |||
18 | 18 | ||
19 | #include "rtc-core.h" | 19 | #include "rtc-core.h" |
20 | 20 | ||
21 | #define NAME_SIZE 10 | ||
22 | |||
23 | #if defined(CONFIG_RTC_HCTOSYS_DEVICE) | ||
24 | static bool is_rtc_hctosys(struct rtc_device *rtc) | ||
25 | { | ||
26 | int size; | ||
27 | char name[NAME_SIZE]; | ||
28 | |||
29 | size = scnprintf(name, NAME_SIZE, "rtc%d", rtc->id); | ||
30 | if (size > NAME_SIZE) | ||
31 | return false; | ||
32 | |||
33 | return !strncmp(name, CONFIG_RTC_HCTOSYS_DEVICE, NAME_SIZE); | ||
34 | } | ||
35 | #else | ||
36 | static bool is_rtc_hctosys(struct rtc_device *rtc) | ||
37 | { | ||
38 | return (rtc->id == 0); | ||
39 | } | ||
40 | #endif | ||
21 | 41 | ||
22 | static int rtc_proc_show(struct seq_file *seq, void *offset) | 42 | static int rtc_proc_show(struct seq_file *seq, void *offset) |
23 | { | 43 | { |
@@ -117,12 +137,12 @@ static const struct file_operations rtc_proc_fops = { | |||
117 | 137 | ||
118 | void rtc_proc_add_device(struct rtc_device *rtc) | 138 | void rtc_proc_add_device(struct rtc_device *rtc) |
119 | { | 139 | { |
120 | if (rtc->id == 0) | 140 | if (is_rtc_hctosys(rtc)) |
121 | proc_create_data("driver/rtc", 0, NULL, &rtc_proc_fops, rtc); | 141 | proc_create_data("driver/rtc", 0, NULL, &rtc_proc_fops, rtc); |
122 | } | 142 | } |
123 | 143 | ||
124 | void rtc_proc_del_device(struct rtc_device *rtc) | 144 | void rtc_proc_del_device(struct rtc_device *rtc) |
125 | { | 145 | { |
126 | if (rtc->id == 0) | 146 | if (is_rtc_hctosys(rtc)) |
127 | remove_proc_entry("driver/rtc", NULL); | 147 | remove_proc_entry("driver/rtc", NULL); |
128 | } | 148 | } |