aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/class.c')
-rw-r--r--drivers/rtc/class.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index ac93b76f2b11..0f492b0940b3 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * RTC subsystem, base class 3 * RTC subsystem, base class
3 * 4 *
@@ -5,11 +6,7 @@
5 * Author: Alessandro Zummo <a.zummo@towertech.it> 6 * Author: Alessandro Zummo <a.zummo@towertech.it>
6 * 7 *
7 * class skeleton from drivers/hwmon/hwmon.c 8 * class skeleton from drivers/hwmon/hwmon.c
8 * 9 */
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 10
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15 12
@@ -23,13 +20,13 @@
23 20
24#include "rtc-core.h" 21#include "rtc-core.h"
25 22
26
27static DEFINE_IDA(rtc_ida); 23static DEFINE_IDA(rtc_ida);
28struct class *rtc_class; 24struct class *rtc_class;
29 25
30static void rtc_device_release(struct device *dev) 26static void rtc_device_release(struct device *dev)
31{ 27{
32 struct rtc_device *rtc = to_rtc_device(dev); 28 struct rtc_device *rtc = to_rtc_device(dev);
29
33 ida_simple_remove(&rtc_ida, rtc->id); 30 ida_simple_remove(&rtc_ida, rtc->id);
34 kfree(rtc); 31 kfree(rtc);
35} 32}
@@ -47,7 +44,6 @@ int rtc_hctosys_ret = -ENODEV;
47 44
48static struct timespec64 old_rtc, old_system, old_delta; 45static struct timespec64 old_rtc, old_system, old_delta;
49 46
50
51static int rtc_suspend(struct device *dev) 47static int rtc_suspend(struct device *dev)
52{ 48{
53 struct rtc_device *rtc = to_rtc_device(dev); 49 struct rtc_device *rtc = to_rtc_device(dev);
@@ -71,7 +67,6 @@ static int rtc_suspend(struct device *dev)
71 ktime_get_real_ts64(&old_system); 67 ktime_get_real_ts64(&old_system);
72 old_rtc.tv_sec = rtc_tm_to_time64(&tm); 68 old_rtc.tv_sec = rtc_tm_to_time64(&tm);
73 69
74
75 /* 70 /*
76 * To avoid drift caused by repeated suspend/resumes, 71 * To avoid drift caused by repeated suspend/resumes,
77 * which each can add ~1 second drift error, 72 * which each can add ~1 second drift error,
@@ -83,7 +78,7 @@ static int rtc_suspend(struct device *dev)
83 if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) { 78 if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) {
84 /* 79 /*
85 * if delta_delta is too large, assume time correction 80 * if delta_delta is too large, assume time correction
86 * has occured and set old_delta to the current delta. 81 * has occurred and set old_delta to the current delta.
87 */ 82 */
88 old_delta = delta; 83 old_delta = delta;
89 } else { 84 } else {
@@ -136,7 +131,7 @@ static int rtc_resume(struct device *dev)
136 * to keep things accurate. 131 * to keep things accurate.
137 */ 132 */
138 sleep_time = timespec64_sub(sleep_time, 133 sleep_time = timespec64_sub(sleep_time,
139 timespec64_sub(new_system, old_system)); 134 timespec64_sub(new_system, old_system));
140 135
141 if (sleep_time.tv_sec >= 0) 136 if (sleep_time.tv_sec >= 0)
142 timekeeping_inject_sleeptime64(&sleep_time); 137 timekeeping_inject_sleeptime64(&sleep_time);
@@ -397,9 +392,9 @@ EXPORT_SYMBOL_GPL(__rtc_register_device);
397 * rtc_register_device instead 392 * rtc_register_device instead
398 */ 393 */
399struct rtc_device *devm_rtc_device_register(struct device *dev, 394struct rtc_device *devm_rtc_device_register(struct device *dev,
400 const char *name, 395 const char *name,
401 const struct rtc_class_ops *ops, 396 const struct rtc_class_ops *ops,
402 struct module *owner) 397 struct module *owner)
403{ 398{
404 struct rtc_device *rtc; 399 struct rtc_device *rtc;
405 int err; 400 int err;