summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-efi.c
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@163.com>2015-11-06 23:00:22 -0500
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2016-01-11 14:19:55 -0500
commit501385f2a783c0a6cc52c8b984892c57175857f9 (patch)
tree27919d1e7f31a9f926ac52d128193990a2f38538 /drivers/rtc/rtc-efi.c
parentb01079be449b895913ce17a47933820af708d5dd (diff)
rtc: efi: add efi_procfs in efi_rtc_ops
Add efi_procfs in efi_rtc_ops to show rtc-efi info in /proc/driver/rtc. Most of the code comes from efi_rtc_proc_show() in efirtc. Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc/rtc-efi.c')
-rw-r--r--drivers/rtc/rtc-efi.c66
1 files changed, 62 insertions, 4 deletions
diff --git a/drivers/rtc/rtc-efi.c b/drivers/rtc/rtc-efi.c
index 3806961b4348..96d38609d803 100644
--- a/drivers/rtc/rtc-efi.c
+++ b/drivers/rtc/rtc-efi.c
@@ -191,11 +191,69 @@ static int efi_set_time(struct device *dev, struct rtc_time *tm)
191 return status == EFI_SUCCESS ? 0 : -EINVAL; 191 return status == EFI_SUCCESS ? 0 : -EINVAL;
192} 192}
193 193
194static int efi_procfs(struct device *dev, struct seq_file *seq)
195{
196 efi_time_t eft, alm;
197 efi_time_cap_t cap;
198 efi_bool_t enabled, pending;
199
200 memset(&eft, 0, sizeof(eft));
201 memset(&alm, 0, sizeof(alm));
202 memset(&cap, 0, sizeof(cap));
203
204 efi.get_time(&eft, &cap);
205 efi.get_wakeup_time(&enabled, &pending, &alm);
206
207 seq_printf(seq,
208 "Time\t\t: %u:%u:%u.%09u\n"
209 "Date\t\t: %u-%u-%u\n"
210 "Daylight\t: %u\n",
211 eft.hour, eft.minute, eft.second, eft.nanosecond,
212 eft.year, eft.month, eft.day,
213 eft.daylight);
214
215 if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
216 seq_puts(seq, "Timezone\t: unspecified\n");
217 else
218 /* XXX fixme: convert to string? */
219 seq_printf(seq, "Timezone\t: %u\n", eft.timezone);
220
221 seq_printf(seq,
222 "Alarm Time\t: %u:%u:%u.%09u\n"
223 "Alarm Date\t: %u-%u-%u\n"
224 "Alarm Daylight\t: %u\n"
225 "Enabled\t\t: %s\n"
226 "Pending\t\t: %s\n",
227 alm.hour, alm.minute, alm.second, alm.nanosecond,
228 alm.year, alm.month, alm.day,
229 alm.daylight,
230 enabled == 1 ? "yes" : "no",
231 pending == 1 ? "yes" : "no");
232
233 if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE)
234 seq_puts(seq, "Timezone\t: unspecified\n");
235 else
236 /* XXX fixme: convert to string? */
237 seq_printf(seq, "Timezone\t: %u\n", alm.timezone);
238
239 /*
240 * now prints the capabilities
241 */
242 seq_printf(seq,
243 "Resolution\t: %u\n"
244 "Accuracy\t: %u\n"
245 "SetstoZero\t: %u\n",
246 cap.resolution, cap.accuracy, cap.sets_to_zero);
247
248 return 0;
249}
250
194static const struct rtc_class_ops efi_rtc_ops = { 251static const struct rtc_class_ops efi_rtc_ops = {
195 .read_time = efi_read_time, 252 .read_time = efi_read_time,
196 .set_time = efi_set_time, 253 .set_time = efi_set_time,
197 .read_alarm = efi_read_alarm, 254 .read_alarm = efi_read_alarm,
198 .set_alarm = efi_set_alarm, 255 .set_alarm = efi_set_alarm,
256 .proc = efi_procfs,
199}; 257};
200 258
201static int __init efi_rtc_probe(struct platform_device *dev) 259static int __init efi_rtc_probe(struct platform_device *dev)