diff options
| -rw-r--r-- | Documentation/rtc.txt | 5 | ||||
| -rw-r--r-- | drivers/rtc/Kconfig | 10 | ||||
| -rw-r--r-- | drivers/rtc/rtc-proc.c | 24 |
3 files changed, 31 insertions, 8 deletions
diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt index 250160469d83..32aa4002de4a 100644 --- a/Documentation/rtc.txt +++ b/Documentation/rtc.txt | |||
| @@ -119,8 +119,9 @@ three different userspace interfaces: | |||
| 119 | * /sys/class/rtc/rtcN ... sysfs attributes support readonly | 119 | * /sys/class/rtc/rtcN ... sysfs attributes support readonly |
| 120 | access to some RTC attributes. | 120 | access to some RTC attributes. |
| 121 | 121 | ||
| 122 | * /proc/driver/rtc ... the first RTC (rtc0) may expose itself | 122 | * /proc/driver/rtc ... the system clock RTC may expose itself |
| 123 | using a procfs interface. More information is (currently) shown | 123 | using a procfs interface. If there is no RTC for the system clock, |
| 124 | rtc0 is used by default. More information is (currently) shown | ||
| 124 | here than through sysfs. | 125 | here than through sysfs. |
| 125 | 126 | ||
| 126 | The RTC Class framework supports a wide variety of RTCs, ranging from those | 127 | The RTC Class framework supports a wide variety of RTCs, ranging from those |
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index fabc99a75c65..a4a805c273bb 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
| @@ -69,13 +69,15 @@ config RTC_INTF_SYSFS | |||
| 69 | If unsure, say Y. | 69 | If unsure, say Y. |
| 70 | 70 | ||
| 71 | config RTC_INTF_PROC | 71 | config RTC_INTF_PROC |
| 72 | boolean "/proc/driver/rtc (procfs for rtc0)" | 72 | boolean "/proc/driver/rtc (procfs for rtcN)" |
| 73 | depends on PROC_FS | 73 | depends on PROC_FS |
| 74 | default RTC_CLASS | 74 | default RTC_CLASS |
| 75 | help | 75 | help |
| 76 | Say yes here if you want to use your first RTC through the proc | 76 | Say yes here if you want to use your system clock RTC through |
| 77 | interface, /proc/driver/rtc. Other RTCs will not be available | 77 | the proc interface, /proc/driver/rtc. |
| 78 | through that API. | 78 | Other RTCs will not be available through that API. |
| 79 | If there is no RTC for the system clock, then the first RTC(rtc0) | ||
| 80 | is used by default. | ||
| 79 | 81 | ||
| 80 | If unsure, say Y. | 82 | If unsure, say Y. |
| 81 | 83 | ||
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 | } |
