summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/proc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-01-01 16:24:31 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-01-01 16:24:31 -0500
commit28e8c4bc8eb483c22d977e147a0b98fc63efadf7 (patch)
tree8006dd759601c70d4dd1fc644ed817e9597cec55 /drivers/rtc/proc.c
parentc9bef4a651769927445900564781a9c99fdf6258 (diff)
parent36e14f5fdfdf7cec8887b7ff69cd9bb5051ecf62 (diff)
Merge tag 'rtc-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni: "Subsystem: - new %ptR printk format - rename core files - allow registration of multiple nvmem devices New driver: - i.MX system controller RTC Driver updates: - abx80x: handle voltage ioctls, correct binding doc - m41t80: correct month in alarm reads - pcf85363: add pcf85263 support - pcf8523: properly handle battery low flag - s3c: limit alarm to one year in the future as ALMYEAR is broken - sun6i: rework clock output binding" * tag 'rtc-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (54 commits) rtc: rename core files rtc: nvmem: fix possible use after free rtc: add i.MX system controller RTC support dt-bindings: fsl: scu: add rtc binding rtc: pcf2123: Add Microcrystal rv2123 rtc: class: reimplement devm_rtc_device_register rtc: enforce rtc_timer_init private_data type rtc: abx80x: Implement RTC_VL_READ,CLR ioctls rtc: pcf85363: Add support for NXP pcf85263 rtc dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock rtc: pcf8523: don't return invalid date when battery is low dt-bindings: rtc: use a generic node name for ds1307 PM: Switch to use %ptR m68k/mac: Switch to use %ptR Input: hp_sdc_rtc - Switch to use %ptR rtc: tegra: Switch to use %ptR rtc: s5m: Switch to use %ptR rtc: s3c: Switch to use %ptR rtc: rx8025: Switch to use %ptR rtc: rx6110: Switch to use %ptR ...
Diffstat (limited to 'drivers/rtc/proc.c')
-rw-r--r--drivers/rtc/proc.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/drivers/rtc/proc.c b/drivers/rtc/proc.c
new file mode 100644
index 000000000000..4d74e4f4ff30
--- /dev/null
+++ b/drivers/rtc/proc.c
@@ -0,0 +1,95 @@
1/*
2 * RTC subsystem, proc interface
3 *
4 * Copyright (C) 2005-06 Tower Technologies
5 * Author: Alessandro Zummo <a.zummo@towertech.it>
6 *
7 * based on arch/arm/common/rtctime.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#include <linux/module.h>
15#include <linux/rtc.h>
16#include <linux/proc_fs.h>
17#include <linux/seq_file.h>
18
19#include "rtc-core.h"
20
21#define NAME_SIZE 10
22
23#if defined(CONFIG_RTC_HCTOSYS_DEVICE)
24static 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
36static bool is_rtc_hctosys(struct rtc_device *rtc)
37{
38 return (rtc->id == 0);
39}
40#endif
41
42static int rtc_proc_show(struct seq_file *seq, void *offset)
43{
44 int err;
45 struct rtc_device *rtc = seq->private;
46 const struct rtc_class_ops *ops = rtc->ops;
47 struct rtc_wkalrm alrm;
48 struct rtc_time tm;
49
50 err = rtc_read_time(rtc, &tm);
51 if (err == 0) {
52 seq_printf(seq,
53 "rtc_time\t: %ptRt\n"
54 "rtc_date\t: %ptRd\n",
55 &tm, &tm);
56 }
57
58 err = rtc_read_alarm(rtc, &alrm);
59 if (err == 0) {
60 seq_printf(seq, "alrm_time\t: %ptRt\n", &alrm.time);
61 seq_printf(seq, "alrm_date\t: %ptRd\n", &alrm.time);
62 seq_printf(seq, "alarm_IRQ\t: %s\n",
63 alrm.enabled ? "yes" : "no");
64 seq_printf(seq, "alrm_pending\t: %s\n",
65 alrm.pending ? "yes" : "no");
66 seq_printf(seq, "update IRQ enabled\t: %s\n",
67 (rtc->uie_rtctimer.enabled) ? "yes" : "no");
68 seq_printf(seq, "periodic IRQ enabled\t: %s\n",
69 (rtc->pie_enabled) ? "yes" : "no");
70 seq_printf(seq, "periodic IRQ frequency\t: %d\n",
71 rtc->irq_freq);
72 seq_printf(seq, "max user IRQ frequency\t: %d\n",
73 rtc->max_user_freq);
74 }
75
76 seq_printf(seq, "24hr\t\t: yes\n");
77
78 if (ops->proc)
79 ops->proc(rtc->dev.parent, seq);
80
81 return 0;
82}
83
84void rtc_proc_add_device(struct rtc_device *rtc)
85{
86 if (is_rtc_hctosys(rtc))
87 proc_create_single_data("driver/rtc", 0, NULL, rtc_proc_show,
88 rtc);
89}
90
91void rtc_proc_del_device(struct rtc_device *rtc)
92{
93 if (is_rtc_hctosys(rtc))
94 remove_proc_entry("driver/rtc", NULL);
95}