mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 17:41:44 +00:00
28e8c4bc8e
Subsystem: - new %ptR printk format - rename core files - allow registration of multiple nvmem devices New driver: - i.MX system controller RTC Drivers: - 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 -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEXx9Viay1+e7J/aM4AyWl4gNJNJIFAlwqU44ACgkQAyWl4gNJ NJJjGxAAgQMTkarMx16icKpN35iuXgwZdIKKmWIHGyCJeB1ykHS8TgwkP+4pE1aN UwTw6x9TBxa9KpuexCgrx8/zppM0i1jacaxJkDbrj1OBPAlGrbJrwcSH029qHAu6 N1Oo0GvAIPlEmIJkKVWkgZhGqUwvMvcy2amk06S92PPOIfr5zJsRzNmduEE7bpcl 86EckuFOp9c1p4IayeQhIT+GHPtum4WkmGVw3+j0j/E6aCUD3thLohT+KuGfzzKn jHbtZ+/d17etKtxxI26YrmixH603t66ZSuc64rSvKRKYR8u/qqR3ZTotYVonsPHj NNQsWiNRzwkpiN9n1Big0tLJyXJ6qbYQIrJLMc19Jr10tS815WF5rjmNinfdSazX 4xucIJpMh7VgA3W5BpvN1+UEahiznp2QGiLjauoruMrB7XUUSLPv6VohFiKAfd9S 7SyV2moPWVnj4pJPH6Af2zVLE9YyPoWGvUSwosLZKhpoFNLOnVZAU0vo32M/23wv ejv4YPhtqxqT94XUyrWKE1DaTpxMqBHcHj2ThV+NGCWe4C0+KfW0zmbKm1X588UJ ZhmGODV9acU+46It5mFoE2Zb9WPyEwljjxbvXKQZhdONKIoZ6lz1i7nzy6C2qerQ ZW5baiaCvQ5e/NyWLxEZwvHukBo2OBxkXe8isuk/wz+7Qyw3l34= =5He5 -----END PGP SIGNATURE----- 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 ...
74 lines
1.8 KiB
C
74 lines
1.8 KiB
C
/*
|
|
* RTC subsystem, initialize system time on startup
|
|
*
|
|
* Copyright (C) 2005 Tower Technologies
|
|
* Author: Alessandro Zummo <a.zummo@towertech.it>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
#include <linux/rtc.h>
|
|
|
|
/* IMPORTANT: the RTC only stores whole seconds. It is arbitrary
|
|
* whether it stores the most close value or the value with partial
|
|
* seconds truncated. However, it is important that we use it to store
|
|
* the truncated value. This is because otherwise it is necessary,
|
|
* in an rtc sync function, to read both xtime.tv_sec and
|
|
* xtime.tv_nsec. On some processors (i.e. ARM), an atomic read
|
|
* of >32bits is not possible. So storing the most close value would
|
|
* slow down the sync API. So here we have the truncated value and
|
|
* the best guess is to add 0.5s.
|
|
*/
|
|
|
|
static int __init rtc_hctosys(void)
|
|
{
|
|
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 == NULL) {
|
|
pr_info("unable to open rtc device (%s)\n",
|
|
CONFIG_RTC_HCTOSYS_DEVICE);
|
|
goto err_open;
|
|
}
|
|
|
|
err = rtc_read_time(rtc, &tm);
|
|
if (err) {
|
|
dev_err(rtc->dev.parent,
|
|
"hctosys: unable to read the hardware clock\n");
|
|
goto err_read;
|
|
|
|
}
|
|
|
|
tv64.tv_sec = rtc_tm_to_time64(&tm);
|
|
|
|
#if BITS_PER_LONG == 32
|
|
if (tv64.tv_sec > INT_MAX) {
|
|
err = -ERANGE;
|
|
goto err_read;
|
|
}
|
|
#endif
|
|
|
|
err = do_settimeofday64(&tv64);
|
|
|
|
dev_info(rtc->dev.parent, "setting system clock to %ptR UTC (%lld)\n",
|
|
&tm, (long long)tv64.tv_sec);
|
|
|
|
err_read:
|
|
rtc_class_close(rtc);
|
|
|
|
err_open:
|
|
rtc_hctosys_ret = err;
|
|
|
|
return err;
|
|
}
|
|
|
|
late_initcall(rtc_hctosys);
|