summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/class.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2020-03-23 22:30:39 +0100
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2020-03-24 22:48:04 +0100
commit5614a4a3ca0e8806e144419536f52df419caa14f (patch)
tree19941f71dc728d551ce7dc5b1e33c572ff48c0bf /drivers/rtc/class.c
parentdt-bindings: rtc: Convert and update jz4740-rtc doc to YAML (diff)
downloadlinux-5614a4a3ca0e8806e144419536f52df419caa14f.tar.xz
linux-5614a4a3ca0e8806e144419536f52df419caa14f.zip
rtc: class: avoid unnecessary lookup in hctosys
rtc_hctosys is only called when the relevant RTC is found, avoid looking it up while we already have a pinter to the proper struct rtc_device. Link: https://lore.kernel.org/r/20200323213039.297458-1-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to '')
-rw-r--r--drivers/rtc/class.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 8793b2b8cf9d..03d6516941a8 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -46,20 +46,13 @@ int rtc_hctosys_ret = -ENODEV;
* the best guess is to add 0.5s.
*/
-static int rtc_hctosys(void)
+static void rtc_hctosys(struct rtc_device *rtc)
{
int err = -ENODEV;
struct rtc_time tm;
struct timespec64 tv64 = {
.tv_nsec = NSEC_PER_SEC >> 1,
};
- struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
-
- if (!rtc) {
- pr_info("unable to open rtc device (%s)\n",
- CONFIG_RTC_HCTOSYS_DEVICE);
- goto err_open;
- }
err = rtc_read_time(rtc, &tm);
if (err) {
@@ -83,12 +76,7 @@ static int rtc_hctosys(void)
&tm, (long long)tv64.tv_sec);
err_read:
- rtc_class_close(rtc);
-
-err_open:
rtc_hctosys_ret = err;
-
- return err;
}
#endif
@@ -433,7 +421,7 @@ int __rtc_register_device(struct module *owner, struct rtc_device *rtc)
#ifdef CONFIG_RTC_HCTOSYS_DEVICE
if (!strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE))
- rtc_hctosys();
+ rtc_hctosys(rtc);
#endif
return 0;