Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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
...

+744 -566
+18
Documentation/core-api/printk-formats.rst
··· 412 412 413 413 Passed by reference. 414 414 415 + Time and date (struct rtc_time) 416 + ------------------------------- 417 + 418 + :: 419 + 420 + %ptR YYYY-mm-ddTHH:MM:SS 421 + %ptRd YYYY-mm-dd 422 + %ptRt HH:MM:SS 423 + %ptR[dt][r] 424 + 425 + For printing date and time as represented by struct rtc_time structure in 426 + human readable format. 427 + 428 + By default year will be incremented by 1900 and month by 1. Use %ptRr (raw) 429 + to suppress this behaviour. 430 + 431 + Passed by reference. 432 + 415 433 struct clk 416 434 ---------- 417 435
+10
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt
··· 109 109 [2] Documentation/devicetree/bindings/power/power_domain.txt 110 110 [3] Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt 111 111 112 + RTC bindings based on SCU Message Protocol 113 + ------------------------------------------------------------ 114 + 115 + Required properties: 116 + - compatible: should be "fsl,imx8qxp-sc-rtc"; 117 + 112 118 Example (imx8qxp): 113 119 ------------- 114 120 lsio_mu1: mailbox@5d1c0000 { ··· 156 150 pd: imx8qx-pd { 157 151 compatible = "fsl,imx8qxp-scu-pd"; 158 152 #power-domain-cells = <1>; 153 + }; 154 + 155 + rtc: rtc { 156 + compatible = "fsl,imx8qxp-sc-rtc"; 159 157 }; 160 158 }; 161 159 };
+1 -1
Documentation/devicetree/bindings/rtc/abracon,abx80x.txt
··· 27 27 28 28 - "abracon,tc-diode": should be "standard" (0.6V) or "schottky" (0.3V) 29 29 - "abracon,tc-resistor": should be <0>, <3>, <6> or <11>. 0 disables the output 30 - resistor, the other values are in ohm. 30 + resistor, the other values are in kOhm.
+1
Documentation/devicetree/bindings/rtc/nxp,rtc-2123.txt
··· 2 2 3 3 Required properties: 4 4 - compatible: should be: "nxp,rtc-pcf2123" 5 + or "microcrystal,rv2123" 5 6 - reg: should be the SPI slave chipselect address 6 7 7 8 Optional properties:
+2 -2
Documentation/devicetree/bindings/rtc/pcf85363.txt
··· 1 - NXP PCF85363 Real Time Clock 1 + NXP PCF85263/PCF85363 Real Time Clock 2 2 ============================ 3 3 4 4 Required properties: 5 - - compatible: Should contain "nxp,pcf85363". 5 + - compatible: Should contain "nxp,pcf85263" or "nxp,pcf85363". 6 6 - reg: I2C address for chip. 7 7 8 8 Optional properties:
+1 -1
Documentation/devicetree/bindings/rtc/rtc-ds1307.txt
··· 35 35 Should be given if internal trickle charger diode should be disabled 36 36 37 37 Example: 38 - rtc1: ds1339@68 { 38 + ds1339: rtc@68 { 39 39 compatible = "dallas,ds1339"; 40 40 reg = <0x68>; 41 41 interrupt-parent = <&gpio4>;
+26 -7
Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
··· 3 3 RTC controller for the Allwinner A31 4 4 5 5 Required properties: 6 - - compatible : Should be "allwinner,sun6i-a31-rtc" 6 + - compatible : Should be one of the following combinations: 7 + - "allwinner,sun6i-a31-rtc" 8 + - "allwinner,sun8i-a23-rtc" 9 + - "allwinner,sun8i-h3-rtc" 10 + - "allwinner,sun8i-r40-rtc", "allwinner,sun8i-h3-rtc" 11 + - "allwinner,sun8i-v3-rtc" 12 + - "allwinner,sun50i-a64-rtc", "allwinner,sun8i-h3-rtc" 13 + - "allwinner,sun50i-h5-rtc" 14 + 15 + Where there are two or more compatible strings, this 16 + denotes the hardware covered by the most specific one 17 + is backward-compatible with the latter ones, and the 18 + implementation for the latter ones can be used, albeit 19 + with reduced functionality. 20 + 7 21 - reg : physical base address of the controller and length of 8 22 memory mapped region. 9 23 - interrupts : IRQ lines for the RTC alarm 0 and alarm 1, in that order. 10 24 11 25 Required properties for new device trees 12 26 - clocks : phandle to the 32kHz external oscillator 13 - - clock-output-names : names of the LOSC and its external output clocks created 14 - - #clock-cells : must be equals to 1. The RTC provides two clocks: the 15 - LOSC and its external output, with index 0 and 1 16 - respectively. 27 + - clock-output-names : names of up to three clock outputs. See below. 28 + - #clock-cells : must be equal to 1. 29 + 30 + The RTC provides the following clocks at the given indices: 31 + - 0: LOSC 32 + - 1: LOSC external output, known as X32KFOUT in the datasheet. 33 + This clock is not available on the A31 and is deprecated for old 34 + device trees still using the "allwinner,sun6i-a31-rtc" compatible. 35 + - 2: InternalOSC, or internal RC oscillator (A64/H3/H5 only) 17 36 18 37 Example: 19 38 20 39 rtc: rtc@1f00000 { 21 40 compatible = "allwinner,sun6i-a31-rtc"; 22 - reg = <0x01f00000 0x54>; 41 + reg = <0x01f00000 0x400>; 23 42 interrupts = <0 40 4>, <0 41 4>; 24 - clock-output-names = "osc32k", "osc32k-out"; 43 + clock-output-names = "osc32k"; 25 44 clocks = <&ext_osc32k>; 26 45 #clock-cells = <1>; 27 46 };
+2 -6
arch/m68k/mac/misc.c
··· 605 605 unmktime(now, 0, 606 606 &t->tm_year, &t->tm_mon, &t->tm_mday, 607 607 &t->tm_hour, &t->tm_min, &t->tm_sec); 608 - pr_debug("%s: read %04d-%02d-%-2d %02d:%02d:%02d\n", 609 - __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, 610 - t->tm_hour, t->tm_min, t->tm_sec); 608 + pr_debug("%s: read %ptR\n", __func__, t); 611 609 } else { /* write */ 612 - pr_debug("%s: tried to write %04d-%02d-%-2d %02d:%02d:%02d\n", 613 - __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, 614 - t->tm_hour, t->tm_min, t->tm_sec); 610 + pr_debug("%s: tried to write %ptR\n", __func__, t); 615 611 616 612 switch (macintosh_config->adb_type) { 617 613 case MAC_ADB_IOP:
+1 -3
drivers/base/power/trace.c
··· 118 118 unsigned int val; 119 119 120 120 mc146818_get_time(&time); 121 - pr_info("RTC time: %2d:%02d:%02d, date: %02d/%02d/%02d\n", 122 - time.tm_hour, time.tm_min, time.tm_sec, 123 - time.tm_mon + 1, time.tm_mday, time.tm_year % 100); 121 + pr_info("RTC time: %ptRt, date: %ptRd\n", &time, &time); 124 122 val = time.tm_year; /* 100 years */ 125 123 if (val > 100) 126 124 val -= 100;
+3 -4
drivers/char/rtc.c
··· 1125 1125 * time or for Universal Standard Time (GMT). Probably local though. 1126 1126 */ 1127 1127 seq_printf(seq, 1128 - "rtc_time\t: %02d:%02d:%02d\n" 1129 - "rtc_date\t: %04d-%02d-%02d\n" 1128 + "rtc_time\t: %ptRt\n" 1129 + "rtc_date\t: %ptRd\n" 1130 1130 "rtc_epoch\t: %04lu\n", 1131 - tm.tm_hour, tm.tm_min, tm.tm_sec, 1132 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, epoch); 1131 + &tm, &tm, epoch); 1133 1132 1134 1133 get_rtc_alm_time(&tm); 1135 1134
+3 -5
drivers/input/misc/hp_sdc_rtc.c
··· 441 441 seq_puts(m, "BBRTC\t\t: READ FAILED!\n"); 442 442 } else { 443 443 seq_printf(m, 444 - "rtc_time\t: %02d:%02d:%02d\n" 445 - "rtc_date\t: %04d-%02d-%02d\n" 444 + "rtc_time\t: %ptRt\n" 445 + "rtc_date\t: %ptRd\n" 446 446 "rtc_epoch\t: %04lu\n", 447 - tm.tm_hour, tm.tm_min, tm.tm_sec, 448 - tm.tm_year + 1900, tm.tm_mon + 1, 449 - tm.tm_mday, epoch); 447 + &tm, &tm, epoch); 450 448 } 451 449 452 450 if (hp_sdc_rtc_read_rt(&tv)) {
+7
drivers/rtc/Kconfig
··· 1677 1677 This driver can also be built as a module, if so, the module 1678 1678 will be called "rtc-snvs". 1679 1679 1680 + config RTC_DRV_IMX_SC 1681 + depends on IMX_SCU 1682 + tristate "NXP i.MX System Controller RTC support" 1683 + help 1684 + If you say yes here you get support for the NXP i.MX System 1685 + Controller RTC module. 1686 + 1680 1687 config RTC_DRV_SIRFSOC 1681 1688 tristate "SiRFSOC RTC" 1682 1689 depends on ARCH_SIRF
+5 -4
drivers/rtc/Makefile
··· 5 5 6 6 ccflags-$(CONFIG_RTC_DEBUG) := -DDEBUG 7 7 8 - obj-$(CONFIG_RTC_LIB) += rtc-lib.o 8 + obj-$(CONFIG_RTC_LIB) += lib.o 9 9 obj-$(CONFIG_RTC_HCTOSYS) += hctosys.o 10 10 obj-$(CONFIG_RTC_SYSTOHC) += systohc.o 11 11 obj-$(CONFIG_RTC_CLASS) += rtc-core.o ··· 17 17 endif 18 18 19 19 rtc-core-$(CONFIG_RTC_NVMEM) += nvmem.o 20 - rtc-core-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o 21 - rtc-core-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o 22 - rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o 20 + rtc-core-$(CONFIG_RTC_INTF_DEV) += dev.o 21 + rtc-core-$(CONFIG_RTC_INTF_PROC) += proc.o 22 + rtc-core-$(CONFIG_RTC_INTF_SYSFS) += sysfs.o 23 23 24 24 # Keep the list ordered. 25 25 ··· 75 75 obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o 76 76 obj-$(CONFIG_RTC_DRV_HYM8563) += rtc-hym8563.o 77 77 obj-$(CONFIG_RTC_DRV_IMXDI) += rtc-imxdi.o 78 + obj-$(CONFIG_RTC_DRV_IMX_SC) += rtc-imx-sc.o 78 79 obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o 79 80 obj-$(CONFIG_RTC_DRV_ISL12026) += rtc-isl12026.o 80 81 obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o
+38 -149
drivers/rtc/class.c
··· 178 178 timerqueue_init_head(&rtc->timerqueue); 179 179 INIT_WORK(&rtc->irqwork, rtc_timer_do_work); 180 180 /* Init aie timer */ 181 - rtc_timer_init(&rtc->aie_timer, rtc_aie_update_irq, (void *)rtc); 181 + rtc_timer_init(&rtc->aie_timer, rtc_aie_update_irq, rtc); 182 182 /* Init uie timer */ 183 - rtc_timer_init(&rtc->uie_rtctimer, rtc_uie_update_irq, (void *)rtc); 183 + rtc_timer_init(&rtc->uie_rtctimer, rtc_uie_update_irq, rtc); 184 184 /* Init pie timer */ 185 185 hrtimer_init(&rtc->pie_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 186 186 rtc->pie_timer.function = rtc_pie_update_irq; ··· 278 278 } 279 279 280 280 /** 281 - * rtc_device_register - register w/ RTC class 282 - * @dev: the device to register 283 - * 284 - * rtc_device_unregister() must be called when the class device is no 285 - * longer needed. 286 - * 287 - * Returns the pointer to the new struct class device. 288 - */ 289 - static struct rtc_device *rtc_device_register(const char *name, 290 - struct device *dev, 291 - const struct rtc_class_ops *ops, 292 - struct module *owner) 293 - { 294 - struct rtc_device *rtc; 295 - struct rtc_wkalrm alrm; 296 - int id, err; 297 - 298 - id = rtc_device_get_id(dev); 299 - if (id < 0) { 300 - err = id; 301 - goto exit; 302 - } 303 - 304 - rtc = rtc_allocate_device(); 305 - if (!rtc) { 306 - err = -ENOMEM; 307 - goto exit_ida; 308 - } 309 - 310 - rtc->id = id; 311 - rtc->ops = ops; 312 - rtc->owner = owner; 313 - rtc->dev.parent = dev; 314 - 315 - dev_set_name(&rtc->dev, "rtc%d", id); 316 - 317 - rtc_device_get_offset(rtc); 318 - 319 - /* Check to see if there is an ALARM already set in hw */ 320 - err = __rtc_read_alarm(rtc, &alrm); 321 - 322 - if (!err && !rtc_valid_tm(&alrm.time)) 323 - rtc_initialize_alarm(rtc, &alrm); 324 - 325 - rtc_dev_prepare(rtc); 326 - 327 - err = cdev_device_add(&rtc->char_dev, &rtc->dev); 328 - if (err) { 329 - dev_warn(&rtc->dev, "%s: failed to add char device %d:%d\n", 330 - name, MAJOR(rtc->dev.devt), rtc->id); 331 - 332 - /* This will free both memory and the ID */ 333 - put_device(&rtc->dev); 334 - goto exit; 335 - } else { 336 - dev_dbg(&rtc->dev, "%s: dev (%d:%d)\n", name, 337 - MAJOR(rtc->dev.devt), rtc->id); 338 - } 339 - 340 - rtc_proc_add_device(rtc); 341 - 342 - dev_info(dev, "rtc core: registered %s as %s\n", 343 - name, dev_name(&rtc->dev)); 344 - 345 - return rtc; 346 - 347 - exit_ida: 348 - ida_simple_remove(&rtc_ida, id); 349 - 350 - exit: 351 - dev_err(dev, "rtc core: unable to register %s, err = %d\n", 352 - name, err); 353 - return ERR_PTR(err); 354 - } 355 - 356 - /** 357 281 * rtc_device_unregister - removes the previously registered RTC class device 358 282 * 359 283 * @rtc: the RTC class device to destroy ··· 295 371 mutex_unlock(&rtc->ops_lock); 296 372 put_device(&rtc->dev); 297 373 } 298 - 299 - static void devm_rtc_device_release(struct device *dev, void *res) 300 - { 301 - struct rtc_device *rtc = *(struct rtc_device **)res; 302 - 303 - rtc_nvmem_unregister(rtc); 304 - rtc_device_unregister(rtc); 305 - } 306 - 307 - static int devm_rtc_device_match(struct device *dev, void *res, void *data) 308 - { 309 - struct rtc **r = res; 310 - 311 - return *r == data; 312 - } 313 - 314 - /** 315 - * devm_rtc_device_register - resource managed rtc_device_register() 316 - * @dev: the device to register 317 - * @name: the name of the device 318 - * @ops: the rtc operations structure 319 - * @owner: the module owner 320 - * 321 - * @return a struct rtc on success, or an ERR_PTR on error 322 - * 323 - * Managed rtc_device_register(). The rtc_device returned from this function 324 - * are automatically freed on driver detach. See rtc_device_register() 325 - * for more information. 326 - */ 327 - 328 - struct rtc_device *devm_rtc_device_register(struct device *dev, 329 - const char *name, 330 - const struct rtc_class_ops *ops, 331 - struct module *owner) 332 - { 333 - struct rtc_device **ptr, *rtc; 334 - 335 - ptr = devres_alloc(devm_rtc_device_release, sizeof(*ptr), GFP_KERNEL); 336 - if (!ptr) 337 - return ERR_PTR(-ENOMEM); 338 - 339 - rtc = rtc_device_register(name, dev, ops, owner); 340 - if (!IS_ERR(rtc)) { 341 - *ptr = rtc; 342 - devres_add(dev, ptr); 343 - } else { 344 - devres_free(ptr); 345 - } 346 - 347 - return rtc; 348 - } 349 - EXPORT_SYMBOL_GPL(devm_rtc_device_register); 350 - 351 - /** 352 - * devm_rtc_device_unregister - resource managed devm_rtc_device_unregister() 353 - * @dev: the device to unregister 354 - * @rtc: the RTC class device to unregister 355 - * 356 - * Deallocated a rtc allocated with devm_rtc_device_register(). Normally this 357 - * function will not need to be called and the resource management code will 358 - * ensure that the resource is freed. 359 - */ 360 - void devm_rtc_device_unregister(struct device *dev, struct rtc_device *rtc) 361 - { 362 - int rc; 363 - 364 - rc = devres_release(dev, devm_rtc_device_release, 365 - devm_rtc_device_match, rtc); 366 - WARN_ON(rc); 367 - } 368 - EXPORT_SYMBOL_GPL(devm_rtc_device_unregister); 369 374 370 375 static void devm_rtc_release_device(struct device *dev, void *res) 371 376 { ··· 381 528 return 0; 382 529 } 383 530 EXPORT_SYMBOL_GPL(__rtc_register_device); 531 + 532 + /** 533 + * devm_rtc_device_register - resource managed rtc_device_register() 534 + * @dev: the device to register 535 + * @name: the name of the device (unused) 536 + * @ops: the rtc operations structure 537 + * @owner: the module owner 538 + * 539 + * @return a struct rtc on success, or an ERR_PTR on error 540 + * 541 + * Managed rtc_device_register(). The rtc_device returned from this function 542 + * are automatically freed on driver detach. 543 + * This function is deprecated, use devm_rtc_allocate_device and 544 + * rtc_register_device instead 545 + */ 546 + struct rtc_device *devm_rtc_device_register(struct device *dev, 547 + const char *name, 548 + const struct rtc_class_ops *ops, 549 + struct module *owner) 550 + { 551 + struct rtc_device *rtc; 552 + int err; 553 + 554 + rtc = devm_rtc_allocate_device(dev); 555 + if (IS_ERR(rtc)) 556 + return rtc; 557 + 558 + rtc->ops = ops; 559 + 560 + err = __rtc_register_device(owner, rtc); 561 + if (err) 562 + return ERR_PTR(err); 563 + 564 + return rtc; 565 + } 566 + EXPORT_SYMBOL_GPL(devm_rtc_device_register); 384 567 385 568 static int __init rtc_init(void) 386 569 {
+2 -6
drivers/rtc/hctosys.c
··· 58 58 59 59 err = do_settimeofday64(&tv64); 60 60 61 - dev_info(rtc->dev.parent, 62 - "setting system clock to " 63 - "%d-%02d-%02d %02d:%02d:%02d UTC (%lld)\n", 64 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 65 - tm.tm_hour, tm.tm_min, tm.tm_sec, 66 - (long long) tv64.tv_sec); 61 + dev_info(rtc->dev.parent, "setting system clock to %ptR UTC (%lld)\n", 62 + &tm, (long long)tv64.tv_sec); 67 63 68 64 err_read: 69 65 rtc_class_close(rtc);
+11 -16
drivers/rtc/interface.c
··· 368 368 err = rtc_valid_tm(&alarm->time); 369 369 370 370 done: 371 - if (err) { 372 - dev_warn(&rtc->dev, "invalid alarm value: %d-%d-%d %d:%d:%d\n", 373 - alarm->time.tm_year + 1900, alarm->time.tm_mon + 1, 374 - alarm->time.tm_mday, alarm->time.tm_hour, alarm->time.tm_min, 375 - alarm->time.tm_sec); 376 - } 371 + if (err) 372 + dev_warn(&rtc->dev, "invalid alarm value: %ptR\n", &alarm->time); 377 373 378 374 return err; 379 375 } ··· 609 613 610 614 /** 611 615 * rtc_aie_update_irq - AIE mode rtctimer hook 612 - * @private: pointer to the rtc_device 616 + * @rtc: pointer to the rtc_device 613 617 * 614 618 * This functions is called when the aie_timer expires. 615 619 */ 616 - void rtc_aie_update_irq(void *private) 620 + void rtc_aie_update_irq(struct rtc_device *rtc) 617 621 { 618 - struct rtc_device *rtc = (struct rtc_device *)private; 619 622 rtc_handle_legacy_irq(rtc, 1, RTC_AF); 620 623 } 621 624 622 625 623 626 /** 624 627 * rtc_uie_update_irq - UIE mode rtctimer hook 625 - * @private: pointer to the rtc_device 628 + * @rtc: pointer to the rtc_device 626 629 * 627 630 * This functions is called when the uie_timer expires. 628 631 */ 629 - void rtc_uie_update_irq(void *private) 632 + void rtc_uie_update_irq(struct rtc_device *rtc) 630 633 { 631 - struct rtc_device *rtc = (struct rtc_device *)private; 632 634 rtc_handle_legacy_irq(rtc, 1, RTC_UF); 633 635 } 634 636 ··· 906 912 trace_rtc_timer_dequeue(timer); 907 913 timer->enabled = 0; 908 914 if (timer->func) 909 - timer->func(timer->private_data); 915 + timer->func(timer->rtc); 910 916 911 917 trace_rtc_timer_fired(timer); 912 918 /* Re-add/fwd periodic timers */ ··· 953 959 /* rtc_timer_init - Initializes an rtc_timer 954 960 * @timer: timer to be intiialized 955 961 * @f: function pointer to be called when timer fires 956 - * @data: private data passed to function pointer 962 + * @rtc: pointer to the rtc_device 957 963 * 958 964 * Kernel interface to initializing an rtc_timer. 959 965 */ 960 - void rtc_timer_init(struct rtc_timer *timer, void (*f)(void *p), void *data) 966 + void rtc_timer_init(struct rtc_timer *timer, void (*f)(struct rtc_device *r), 967 + struct rtc_device *rtc) 961 968 { 962 969 timerqueue_init(&timer->node); 963 970 timer->enabled = 0; 964 971 timer->func = f; 965 - timer->private_data = data; 972 + timer->rtc = rtc; 966 973 } 967 974 968 975 /* rtc_timer_start - Sets an rtc_timer to fire in the future
+15 -23
drivers/rtc/nvmem.c
··· 12 12 #include <linux/types.h> 13 13 #include <linux/nvmem-consumer.h> 14 14 #include <linux/rtc.h> 15 + #include <linux/slab.h> 15 16 #include <linux/sysfs.h> 16 17 17 18 /* ··· 26 25 struct bin_attribute *attr, 27 26 char *buf, loff_t off, size_t count) 28 27 { 29 - struct rtc_device *rtc = attr->private; 30 - 31 28 dev_warn_once(kobj_to_dev(kobj), nvram_warning); 32 29 33 - return nvmem_device_read(rtc->nvmem, off, count, buf); 30 + return nvmem_device_read(attr->private, off, count, buf); 34 31 } 35 32 36 33 static ssize_t ··· 36 37 struct bin_attribute *attr, 37 38 char *buf, loff_t off, size_t count) 38 39 { 39 - struct rtc_device *rtc = attr->private; 40 - 41 40 dev_warn_once(kobj_to_dev(kobj), nvram_warning); 42 41 43 - return nvmem_device_write(rtc->nvmem, off, count, buf); 42 + return nvmem_device_write(attr->private, off, count, buf); 44 43 } 45 44 46 - static int rtc_nvram_register(struct rtc_device *rtc, size_t size) 45 + static int rtc_nvram_register(struct rtc_device *rtc, 46 + struct nvmem_device *nvmem, size_t size) 47 47 { 48 48 int err; 49 49 50 - rtc->nvram = devm_kzalloc(rtc->dev.parent, 51 - sizeof(struct bin_attribute), 52 - GFP_KERNEL); 50 + rtc->nvram = kzalloc(sizeof(struct bin_attribute), GFP_KERNEL); 53 51 if (!rtc->nvram) 54 52 return -ENOMEM; 55 53 56 54 rtc->nvram->attr.name = "nvram"; 57 55 rtc->nvram->attr.mode = 0644; 58 - rtc->nvram->private = rtc; 56 + rtc->nvram->private = nvmem; 59 57 60 58 sysfs_bin_attr_init(rtc->nvram); 61 59 ··· 63 67 err = sysfs_create_bin_file(&rtc->dev.parent->kobj, 64 68 rtc->nvram); 65 69 if (err) { 66 - devm_kfree(rtc->dev.parent, rtc->nvram); 70 + kfree(rtc->nvram); 67 71 rtc->nvram = NULL; 68 72 } 69 73 ··· 73 77 static void rtc_nvram_unregister(struct rtc_device *rtc) 74 78 { 75 79 sysfs_remove_bin_file(&rtc->dev.parent->kobj, rtc->nvram); 80 + kfree(rtc->nvram); 81 + rtc->nvram = NULL; 76 82 } 77 83 78 84 /* ··· 83 85 int rtc_nvmem_register(struct rtc_device *rtc, 84 86 struct nvmem_config *nvmem_config) 85 87 { 86 - if (!IS_ERR_OR_NULL(rtc->nvmem)) 87 - return -EBUSY; 88 + struct nvmem_device *nvmem; 88 89 89 90 if (!nvmem_config) 90 91 return -ENODEV; 91 92 92 93 nvmem_config->dev = rtc->dev.parent; 93 94 nvmem_config->owner = rtc->owner; 94 - rtc->nvmem = nvmem_register(nvmem_config); 95 - if (IS_ERR(rtc->nvmem)) 96 - return PTR_ERR(rtc->nvmem); 95 + nvmem = devm_nvmem_register(rtc->dev.parent, nvmem_config); 96 + if (IS_ERR(nvmem)) 97 + return PTR_ERR(nvmem); 97 98 98 99 /* Register the old ABI */ 99 100 if (rtc->nvram_old_abi) 100 - rtc_nvram_register(rtc, nvmem_config->size); 101 + rtc_nvram_register(rtc, nvmem, nvmem_config->size); 101 102 102 103 return 0; 103 104 } ··· 104 107 105 108 void rtc_nvmem_unregister(struct rtc_device *rtc) 106 109 { 107 - if (IS_ERR_OR_NULL(rtc->nvmem)) 108 - return; 109 - 110 110 /* unregister the old ABI */ 111 111 if (rtc->nvram) 112 112 rtc_nvram_unregister(rtc); 113 - 114 - nvmem_unregister(rtc->nvmem); 115 113 }
+38
drivers/rtc/rtc-abx80x.c
··· 38 38 39 39 #define ABX8XX_REG_STATUS 0x0f 40 40 #define ABX8XX_STATUS_AF BIT(2) 41 + #define ABX8XX_STATUS_BLF BIT(4) 41 42 #define ABX8XX_STATUS_WDT BIT(6) 42 43 43 44 #define ABX8XX_REG_CTRL1 0x10 ··· 508 507 return err; 509 508 } 510 509 510 + static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 511 + { 512 + struct i2c_client *client = to_i2c_client(dev); 513 + int status, tmp; 514 + 515 + switch (cmd) { 516 + case RTC_VL_READ: 517 + status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS); 518 + if (status < 0) 519 + return status; 520 + 521 + tmp = !!(status & ABX8XX_STATUS_BLF); 522 + 523 + if (copy_to_user((void __user *)arg, &tmp, sizeof(int))) 524 + return -EFAULT; 525 + 526 + return 0; 527 + 528 + case RTC_VL_CLR: 529 + status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS); 530 + if (status < 0) 531 + return status; 532 + 533 + status &= ~ABX8XX_STATUS_BLF; 534 + 535 + tmp = i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS, 0); 536 + if (tmp < 0) 537 + return tmp; 538 + 539 + return 0; 540 + 541 + default: 542 + return -ENOIOCTLCMD; 543 + } 544 + } 545 + 511 546 static const struct rtc_class_ops abx80x_rtc_ops = { 512 547 .read_time = abx80x_rtc_read_time, 513 548 .set_time = abx80x_rtc_set_time, 514 549 .read_alarm = abx80x_read_alarm, 515 550 .set_alarm = abx80x_set_alarm, 516 551 .alarm_irq_enable = abx80x_alarm_irq_enable, 552 + .ioctl = abx80x_ioctl, 517 553 }; 518 554 519 555 static int abx80x_dt_trickle_cfg(struct device_node *np)
+4 -11
drivers/rtc/rtc-at91rm9200.c
··· 147 147 tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); 148 148 tm->tm_year = tm->tm_year - 1900; 149 149 150 - dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, 151 - 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, 152 - tm->tm_hour, tm->tm_min, tm->tm_sec); 150 + dev_dbg(dev, "%s(): %ptR\n", __func__, tm); 153 151 154 152 return 0; 155 153 } ··· 159 161 { 160 162 unsigned long cr; 161 163 162 - dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, 163 - 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, 164 - tm->tm_hour, tm->tm_min, tm->tm_sec); 164 + dev_dbg(dev, "%s(): %ptR\n", __func__, tm); 165 165 166 166 wait_for_completion(&at91_rtc_upd_rdy); 167 167 ··· 205 209 alrm->enabled = (at91_rtc_read_imr() & AT91_RTC_ALARM) 206 210 ? 1 : 0; 207 211 208 - dev_dbg(dev, "%s(): %02d-%02d %02d:%02d:%02d %sabled\n", __func__, 209 - tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, 212 + dev_dbg(dev, "%s(): %ptR %sabled\n", __func__, tm, 210 213 alrm->enabled ? "en" : "dis"); 211 214 212 215 return 0; ··· 242 247 at91_rtc_write_ier(AT91_RTC_ALARM); 243 248 } 244 249 245 - dev_dbg(dev, "%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, 246 - tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, 247 - tm.tm_min, tm.tm_sec); 250 + dev_dbg(dev, "%s(): %ptR\n", __func__, &tm); 248 251 249 252 return 0; 250 253 }
+4 -12
drivers/rtc/rtc-at91sam9.c
··· 124 124 125 125 rtc_time_to_tm(offset + secs, tm); 126 126 127 - dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "readtime", 128 - 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, 129 - tm->tm_hour, tm->tm_min, tm->tm_sec); 127 + dev_dbg(dev, "%s: %ptR\n", __func__, tm); 130 128 131 129 return 0; 132 130 } ··· 139 141 u32 offset, alarm, mr; 140 142 unsigned long secs; 141 143 142 - dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "settime", 143 - 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, 144 - tm->tm_hour, tm->tm_min, tm->tm_sec); 144 + dev_dbg(dev, "%s: %ptR\n", __func__, tm); 145 145 146 146 err = rtc_tm_to_time(tm, &secs); 147 147 if (err != 0) ··· 195 199 if (alarm != ALARM_DISABLED && offset != 0) { 196 200 rtc_time_to_tm(offset + alarm, tm); 197 201 198 - dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "readalarm", 199 - 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, 200 - tm->tm_hour, tm->tm_min, tm->tm_sec); 202 + dev_dbg(dev, "%s: %ptR\n", __func__, tm); 201 203 202 204 if (rtt_readl(rtc, MR) & AT91_RTT_ALMIEN) 203 205 alrm->enabled = 1; ··· 236 242 if (alrm->enabled) 237 243 rtt_writel(rtc, MR, mr | AT91_RTT_ALMIEN); 238 244 239 - dev_dbg(dev, "%s: %4d-%02d-%02d %02d:%02d:%02d\n", "setalarm", 240 - tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, 241 - tm->tm_min, tm->tm_sec); 245 + dev_dbg(dev, "%s: %ptR\n", __func__, tm); 242 246 243 247 return 0; 244 248 }
drivers/rtc/rtc-dev.c drivers/rtc/dev.c
+1 -1
drivers/rtc/rtc-ep93xx.c
··· 61 61 struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); 62 62 unsigned long time; 63 63 64 - time = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA); 64 + time = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA); 65 65 66 66 rtc_time_to_tm(time, tm); 67 67 return 0;
+91
drivers/rtc/rtc-imx-sc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Copyright 2018 NXP. 4 + */ 5 + 6 + #include <linux/firmware/imx/sci.h> 7 + #include <linux/module.h> 8 + #include <linux/of.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/rtc.h> 11 + 12 + #define IMX_SC_TIMER_FUNC_GET_RTC_SEC1970 9 13 + #define IMX_SC_TIMER_FUNC_SET_RTC_TIME 6 14 + 15 + static struct imx_sc_ipc *rtc_ipc_handle; 16 + static struct rtc_device *imx_sc_rtc; 17 + 18 + struct imx_sc_msg_timer_get_rtc_time { 19 + struct imx_sc_rpc_msg hdr; 20 + u32 time; 21 + } __packed; 22 + 23 + static int imx_sc_rtc_read_time(struct device *dev, struct rtc_time *tm) 24 + { 25 + struct imx_sc_msg_timer_get_rtc_time msg; 26 + struct imx_sc_rpc_msg *hdr = &msg.hdr; 27 + int ret; 28 + 29 + hdr->ver = IMX_SC_RPC_VERSION; 30 + hdr->svc = IMX_SC_RPC_SVC_TIMER; 31 + hdr->func = IMX_SC_TIMER_FUNC_GET_RTC_SEC1970; 32 + hdr->size = 1; 33 + 34 + ret = imx_scu_call_rpc(rtc_ipc_handle, &msg, true); 35 + if (ret) { 36 + dev_err(dev, "read rtc time failed, ret %d\n", ret); 37 + return ret; 38 + } 39 + 40 + rtc_time_to_tm(msg.time, tm); 41 + 42 + return 0; 43 + } 44 + 45 + static const struct rtc_class_ops imx_sc_rtc_ops = { 46 + .read_time = imx_sc_rtc_read_time, 47 + }; 48 + 49 + static int imx_sc_rtc_probe(struct platform_device *pdev) 50 + { 51 + int ret; 52 + 53 + ret = imx_scu_get_handle(&rtc_ipc_handle); 54 + if (ret) 55 + return ret; 56 + 57 + imx_sc_rtc = devm_rtc_allocate_device(&pdev->dev); 58 + if (IS_ERR(imx_sc_rtc)) 59 + return PTR_ERR(imx_sc_rtc); 60 + 61 + imx_sc_rtc->ops = &imx_sc_rtc_ops; 62 + imx_sc_rtc->range_min = 0; 63 + imx_sc_rtc->range_max = U32_MAX; 64 + 65 + ret = rtc_register_device(imx_sc_rtc); 66 + if (ret) { 67 + dev_err(&pdev->dev, "failed to register rtc: %d\n", ret); 68 + return ret; 69 + } 70 + 71 + return 0; 72 + } 73 + 74 + static const struct of_device_id imx_sc_dt_ids[] = { 75 + { .compatible = "fsl,imx8qxp-sc-rtc", }, 76 + {} 77 + }; 78 + MODULE_DEVICE_TABLE(of, imx_sc_dt_ids); 79 + 80 + static struct platform_driver imx_sc_rtc_driver = { 81 + .driver = { 82 + .name = "imx-sc-rtc", 83 + .of_match_table = imx_sc_dt_ids, 84 + }, 85 + .probe = imx_sc_rtc_probe, 86 + }; 87 + module_platform_driver(imx_sc_rtc_driver); 88 + 89 + MODULE_AUTHOR("Anson Huang <Anson.Huang@nxp.com>"); 90 + MODULE_DESCRIPTION("NXP i.MX System Controller RTC Driver"); 91 + MODULE_LICENSE("GPL");
+4 -33
drivers/rtc/rtc-isl1208.c
··· 84 84 isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[], 85 85 unsigned len) 86 86 { 87 - u8 reg_addr[1] = { reg }; 88 - struct i2c_msg msgs[2] = { 89 - { 90 - .addr = client->addr, 91 - .len = sizeof(reg_addr), 92 - .buf = reg_addr 93 - }, 94 - { 95 - .addr = client->addr, 96 - .flags = I2C_M_RD, 97 - .len = len, 98 - .buf = buf 99 - } 100 - }; 101 87 int ret; 102 88 103 89 WARN_ON(reg > ISL1219_REG_YRT); 104 90 WARN_ON(reg + len > ISL1219_REG_YRT + 1); 105 91 106 - ret = i2c_transfer(client->adapter, msgs, 2); 107 - if (ret > 0) 108 - ret = 0; 109 - return ret; 92 + ret = i2c_smbus_read_i2c_block_data(client, reg, len, buf); 93 + return (ret < 0) ? ret : 0; 110 94 } 111 95 112 96 /* block write */ ··· 98 114 isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 const buf[], 99 115 unsigned len) 100 116 { 101 - u8 i2c_buf[ISL1208_REG_USR2 + 2]; 102 - struct i2c_msg msgs[1] = { 103 - { 104 - .addr = client->addr, 105 - .len = len + 1, 106 - .buf = i2c_buf 107 - } 108 - }; 109 117 int ret; 110 118 111 119 WARN_ON(reg > ISL1219_REG_YRT); 112 120 WARN_ON(reg + len > ISL1219_REG_YRT + 1); 113 121 114 - i2c_buf[0] = reg; 115 - memcpy(&i2c_buf[1], &buf[0], len); 116 - 117 - ret = i2c_transfer(client->adapter, msgs, 1); 118 - if (ret > 0) 119 - ret = 0; 120 - return ret; 122 + ret = i2c_smbus_write_i2c_block_data(client, reg, len, buf); 123 + return (ret < 0) ? ret : 0; 121 124 } 122 125 123 126 /* simple check to see whether we have a isl1208 */
drivers/rtc/rtc-lib.c drivers/rtc/lib.c
+10 -11
drivers/rtc/rtc-m41t80.c
··· 217 217 sizeof(buf), buf); 218 218 if (err < 0) { 219 219 dev_err(&client->dev, "Unable to read date\n"); 220 - return -EIO; 220 + return err; 221 221 } 222 222 223 223 tm->tm_sec = bcd2bin(buf[M41T80_REG_SEC] & 0x7f); ··· 274 274 if (flags < 0) 275 275 return flags; 276 276 277 - if (i2c_smbus_write_byte_data(client, M41T80_REG_FLAGS, 278 - flags & ~M41T80_FLAGS_OF)) { 277 + err = i2c_smbus_write_byte_data(client, M41T80_REG_FLAGS, 278 + flags & ~M41T80_FLAGS_OF); 279 + if (err < 0) { 279 280 dev_err(&client->dev, "Unable to write flags register\n"); 280 - return -EIO; 281 + return err; 281 282 } 282 283 283 284 return err; ··· 288 287 { 289 288 struct i2c_client *client = to_i2c_client(dev); 290 289 struct m41t80_data *clientdata = i2c_get_clientdata(client); 291 - u8 reg; 290 + int reg; 292 291 293 292 if (clientdata->features & M41T80_FEATURE_BL) { 294 293 reg = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS); 294 + if (reg < 0) 295 + return reg; 295 296 seq_printf(seq, "battery\t\t: %s\n", 296 297 (reg & M41T80_FLAGS_BATT_LOW) ? "exhausted" : "ok"); 297 298 } ··· 396 393 alrm->time.tm_min = bcd2bin(alarmvals[3] & 0x7f); 397 394 alrm->time.tm_hour = bcd2bin(alarmvals[2] & 0x3f); 398 395 alrm->time.tm_mday = bcd2bin(alarmvals[1] & 0x3f); 399 - alrm->time.tm_mon = bcd2bin(alarmvals[0] & 0x3f); 396 + alrm->time.tm_mon = bcd2bin(alarmvals[0] & 0x3f) - 1; 400 397 401 398 alrm->enabled = !!(alarmvals[0] & M41T80_ALMON_AFE); 402 399 alrm->pending = (flags & M41T80_FLAGS_AF) && alrm->enabled; ··· 942 939 if (m41t80_data->features & M41T80_FEATURE_HT) { 943 940 m41t80_rtc_read_time(&client->dev, &tm); 944 941 dev_info(&client->dev, "HT bit was set!\n"); 945 - dev_info(&client->dev, 946 - "Power Down at %04i-%02i-%02i %02i:%02i:%02i\n", 947 - tm.tm_year + 1900, 948 - tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, 949 - tm.tm_min, tm.tm_sec); 942 + dev_info(&client->dev, "Power Down at %ptR\n", &tm); 950 943 } 951 944 rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_HOUR, 952 945 rc & ~M41T80_ALHOUR_HT);
+2 -6
drivers/rtc/rtc-m48t59.c
··· 99 99 M48T59_CLEAR_BITS(M48T59_CNTL_READ, M48T59_CNTL); 100 100 spin_unlock_irqrestore(&m48t59->lock, flags); 101 101 102 - dev_dbg(dev, "RTC read time %04d-%02d-%02d %02d/%02d/%02d\n", 103 - tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, 104 - tm->tm_hour, tm->tm_min, tm->tm_sec); 102 + dev_dbg(dev, "RTC read time %ptR\n", tm); 105 103 return 0; 106 104 } 107 105 ··· 186 188 M48T59_CLEAR_BITS(M48T59_CNTL_READ, M48T59_CNTL); 187 189 spin_unlock_irqrestore(&m48t59->lock, flags); 188 190 189 - dev_dbg(dev, "RTC read alarm time %04d-%02d-%02d %02d/%02d/%02d\n", 190 - tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, 191 - tm->tm_hour, tm->tm_min, tm->tm_sec); 191 + dev_dbg(dev, "RTC read alarm time %ptR\n", tm); 192 192 return rtc_valid_tm(tm); 193 193 } 194 194
+1 -1
drivers/rtc/rtc-max6916.c
··· 86 86 if (dt->tm_year < 100 || dt->tm_year > 199) { 87 87 dev_err(&spi->dev, "Year must be between 2000 and 2099. It's %d.\n", 88 88 dt->tm_year + 1900); 89 - return -EINVAL; 89 + return -EINVAL; 90 90 } 91 91 92 92 buf[0] = MAX6916_CLOCK_BURST & 0x7F;
+1 -1
drivers/rtc/rtc-max77686.c
··· 360 360 361 361 out: 362 362 mutex_unlock(&info->lock); 363 - return 0; 363 + return ret; 364 364 } 365 365 366 366 static int max77686_rtc_set_time(struct device *dev, struct rtc_time *tm)
+1 -1
drivers/rtc/rtc-max8997.c
··· 215 215 216 216 out: 217 217 mutex_unlock(&info->lock); 218 - return 0; 218 + return ret; 219 219 } 220 220 221 221 static int max8997_rtc_stop_alarm(struct max8997_rtc_info *info)
+6 -12
drivers/rtc/rtc-mcp795.c
··· 233 233 if (ret) 234 234 return ret; 235 235 236 - dev_dbg(dev, "Set mcp795: %04d-%02d-%02d(%d) %02d:%02d:%02d\n", 237 - tim->tm_year + 1900, tim->tm_mon, tim->tm_mday, 238 - tim->tm_wday, tim->tm_hour, tim->tm_min, tim->tm_sec); 236 + dev_dbg(dev, "Set mcp795: %ptR\n", tim); 239 237 240 238 return 0; 241 239 } ··· 256 258 tim->tm_mon = bcd2bin(data[5] & 0x1F) - 1; 257 259 tim->tm_year = bcd2bin(data[6]) + 100; /* Assume we are in 20xx */ 258 260 259 - dev_dbg(dev, "Read from mcp795: %04d-%02d-%02d(%d) %02d:%02d:%02d\n", 260 - tim->tm_year + 1900, tim->tm_mon, tim->tm_mday, 261 - tim->tm_wday, tim->tm_hour, tim->tm_min, tim->tm_sec); 261 + dev_dbg(dev, "Read from mcp795: %ptR\n", tim); 262 262 263 263 return 0; 264 264 } ··· 315 319 return ret; 316 320 dev_dbg(dev, "Alarm IRQ armed\n"); 317 321 } 318 - dev_dbg(dev, "Set alarm: %02d-%02d(%d) %02d:%02d:%02d\n", 319 - alm->time.tm_mon, alm->time.tm_mday, alm->time.tm_wday, 320 - alm->time.tm_hour, alm->time.tm_min, alm->time.tm_sec); 322 + dev_dbg(dev, "Set alarm: %ptRdr(%d) %ptRt\n", 323 + &alm->time, alm->time.tm_wday, &alm->time); 321 324 return 0; 322 325 } 323 326 ··· 340 345 alm->time.tm_isdst = -1; 341 346 alm->time.tm_yday = -1; 342 347 343 - dev_dbg(dev, "Read alarm: %02d-%02d(%d) %02d:%02d:%02d\n", 344 - alm->time.tm_mon, alm->time.tm_mday, alm->time.tm_wday, 345 - alm->time.tm_hour, alm->time.tm_min, alm->time.tm_sec); 348 + dev_dbg(dev, "Read alarm: %ptRdr(%d) %ptRt\n", 349 + &alm->time, alm->time.tm_wday, &alm->time); 346 350 return 0; 347 351 } 348 352
+1 -3
drivers/rtc/rtc-omap.c
··· 566 566 .dt_free_map = pinconf_generic_dt_free_map, 567 567 }; 568 568 569 - enum rtc_pin_config_param { 570 - PIN_CONFIG_ACTIVE_HIGH = PIN_CONFIG_END + 1, 571 - }; 569 + #define PIN_CONFIG_ACTIVE_HIGH (PIN_CONFIG_END + 1) 572 570 573 571 static const struct pinconf_generic_params rtc_params[] = { 574 572 {"ti,active-high", PIN_CONFIG_ACTIVE_HIGH, 0},
+1
drivers/rtc/rtc-pcf2123.c
··· 453 453 #ifdef CONFIG_OF 454 454 static const struct of_device_id pcf2123_dt_ids[] = { 455 455 { .compatible = "nxp,rtc-pcf2123", }, 456 + { .compatible = "microcrystal,rv2123", }, 456 457 { /* sentinel */ } 457 458 }; 458 459 MODULE_DEVICE_TABLE(of, pcf2123_dt_ids);
+2 -6
drivers/rtc/rtc-pcf50633.c
··· 131 131 132 132 pcf2rtc_time(tm, &pcf_tm); 133 133 134 - dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n", 135 - tm->tm_mday, tm->tm_mon, tm->tm_year, 136 - tm->tm_hour, tm->tm_min, tm->tm_sec); 134 + dev_dbg(dev, "RTC_TIME: %ptRr\n", tm); 137 135 138 136 return 0; 139 137 } ··· 144 146 145 147 rtc = dev_get_drvdata(dev); 146 148 147 - dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n", 148 - tm->tm_mday, tm->tm_mon, tm->tm_year, 149 - tm->tm_hour, tm->tm_min, tm->tm_sec); 149 + dev_dbg(dev, "RTC_TIME: %ptRr\n", tm); 150 150 151 151 rtc2pcf_time(&pcf_tm, tm); 152 152
+24 -8
drivers/rtc/rtc-pcf8523.c
··· 85 85 return 0; 86 86 } 87 87 88 + static int pcf8523_voltage_low(struct i2c_client *client) 89 + { 90 + u8 value; 91 + int err; 92 + 93 + err = pcf8523_read(client, REG_CONTROL3, &value); 94 + if (err < 0) 95 + return err; 96 + 97 + return !!(value & REG_CONTROL3_BLF); 98 + } 99 + 88 100 static int pcf8523_select_capacitance(struct i2c_client *client, bool high) 89 101 { 90 102 u8 value; ··· 178 166 u8 start = REG_SECONDS, regs[7]; 179 167 struct i2c_msg msgs[2]; 180 168 int err; 169 + 170 + err = pcf8523_voltage_low(client); 171 + if (err < 0) { 172 + return err; 173 + } else if (err > 0) { 174 + dev_err(dev, "low voltage detected, time is unreliable\n"); 175 + return -EINVAL; 176 + } 181 177 182 178 msgs[0].addr = client->addr; 183 179 msgs[0].flags = 0; ··· 271 251 unsigned long arg) 272 252 { 273 253 struct i2c_client *client = to_i2c_client(dev); 274 - u8 value; 275 - int ret = 0, err; 254 + int ret; 276 255 277 256 switch (cmd) { 278 257 case RTC_VL_READ: 279 - err = pcf8523_read(client, REG_CONTROL3, &value); 280 - if (err < 0) 281 - return err; 282 - 283 - if (value & REG_CONTROL3_BLF) 284 - ret = 1; 258 + ret = pcf8523_voltage_low(client); 259 + if (ret < 0) 260 + return ret; 285 261 286 262 if (copy_to_user((void __user *)arg, &ret, sizeof(int))) 287 263 return -EFAULT;
+76 -18
drivers/rtc/rtc-pcf85363.c
··· 120 120 struct regmap *regmap; 121 121 }; 122 122 123 + struct pcf85x63_config { 124 + struct regmap_config regmap; 125 + unsigned int num_nvram; 126 + }; 127 + 123 128 static int pcf85363_rtc_read_time(struct device *dev, struct rtc_time *tm) 124 129 { 125 130 struct pcf85363 *pcf85363 = dev_get_drvdata(dev); ··· 316 311 val, bytes); 317 312 } 318 313 319 - static const struct regmap_config regmap_config = { 320 - .reg_bits = 8, 321 - .val_bits = 8, 322 - .max_register = 0x7f, 314 + static int pcf85x63_nvram_read(void *priv, unsigned int offset, void *val, 315 + size_t bytes) 316 + { 317 + struct pcf85363 *pcf85363 = priv; 318 + unsigned int tmp_val; 319 + int ret; 320 + 321 + ret = regmap_read(pcf85363->regmap, CTRL_RAMBYTE, &tmp_val); 322 + (*(unsigned char *) val) = (unsigned char) tmp_val; 323 + 324 + return ret; 325 + } 326 + 327 + static int pcf85x63_nvram_write(void *priv, unsigned int offset, void *val, 328 + size_t bytes) 329 + { 330 + struct pcf85363 *pcf85363 = priv; 331 + unsigned char tmp_val; 332 + 333 + tmp_val = *((unsigned char *)val); 334 + return regmap_write(pcf85363->regmap, CTRL_RAMBYTE, 335 + (unsigned int)tmp_val); 336 + } 337 + 338 + static const struct pcf85x63_config pcf_85263_config = { 339 + .regmap = { 340 + .reg_bits = 8, 341 + .val_bits = 8, 342 + .max_register = 0x2f, 343 + }, 344 + .num_nvram = 1 345 + }; 346 + 347 + static const struct pcf85x63_config pcf_85363_config = { 348 + .regmap = { 349 + .reg_bits = 8, 350 + .val_bits = 8, 351 + .max_register = 0x7f, 352 + }, 353 + .num_nvram = 2 323 354 }; 324 355 325 356 static int pcf85363_probe(struct i2c_client *client, 326 357 const struct i2c_device_id *id) 327 358 { 328 359 struct pcf85363 *pcf85363; 329 - struct nvmem_config nvmem_cfg = { 330 - .name = "pcf85363-", 331 - .word_size = 1, 332 - .stride = 1, 333 - .size = NVRAM_SIZE, 334 - .reg_read = pcf85363_nvram_read, 335 - .reg_write = pcf85363_nvram_write, 360 + const struct pcf85x63_config *config = &pcf_85363_config; 361 + const void *data = of_device_get_match_data(&client->dev); 362 + static struct nvmem_config nvmem_cfg[] = { 363 + { 364 + .name = "pcf85x63-", 365 + .word_size = 1, 366 + .stride = 1, 367 + .size = 1, 368 + .reg_read = pcf85x63_nvram_read, 369 + .reg_write = pcf85x63_nvram_write, 370 + }, { 371 + .name = "pcf85363-", 372 + .word_size = 1, 373 + .stride = 1, 374 + .size = NVRAM_SIZE, 375 + .reg_read = pcf85363_nvram_read, 376 + .reg_write = pcf85363_nvram_write, 377 + }, 336 378 }; 337 - int ret; 379 + int ret, i; 380 + 381 + if (data) 382 + config = data; 338 383 339 384 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 340 385 return -ENODEV; ··· 394 339 if (!pcf85363) 395 340 return -ENOMEM; 396 341 397 - pcf85363->regmap = devm_regmap_init_i2c(client, &regmap_config); 342 + pcf85363->regmap = devm_regmap_init_i2c(client, &config->regmap); 398 343 if (IS_ERR(pcf85363->regmap)) { 399 344 dev_err(&client->dev, "regmap allocation failed\n"); 400 345 return PTR_ERR(pcf85363->regmap); ··· 425 370 426 371 ret = rtc_register_device(pcf85363->rtc); 427 372 428 - nvmem_cfg.priv = pcf85363; 429 - rtc_nvmem_register(pcf85363->rtc, &nvmem_cfg); 373 + for (i = 0; i < config->num_nvram; i++) { 374 + nvmem_cfg[i].priv = pcf85363; 375 + rtc_nvmem_register(pcf85363->rtc, &nvmem_cfg[i]); 376 + } 430 377 431 378 return ret; 432 379 } 433 380 434 381 static const struct of_device_id dev_ids[] = { 435 - { .compatible = "nxp,pcf85363" }, 436 - {} 382 + { .compatible = "nxp,pcf85263", .data = &pcf_85263_config }, 383 + { .compatible = "nxp,pcf85363", .data = &pcf_85363_config }, 384 + { /* sentinel */ } 437 385 }; 438 386 MODULE_DEVICE_TABLE(of, dev_ids); 439 387 ··· 451 393 module_i2c_driver(pcf85363_driver); 452 394 453 395 MODULE_AUTHOR("Eric Nelson"); 454 - MODULE_DESCRIPTION("pcf85363 I2C RTC driver"); 396 + MODULE_DESCRIPTION("pcf85263/pcf85363 I2C RTC driver"); 455 397 MODULE_LICENSE("GPL");
+4 -14
drivers/rtc/rtc-pic32.c
··· 170 170 171 171 rtc_tm->tm_year += 100; 172 172 173 - dev_dbg(dev, "read time %04d.%02d.%02d %02d:%02d:%02d\n", 174 - 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, 175 - rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); 173 + dev_dbg(dev, "read time %ptR\n", rtc_tm); 176 174 177 175 clk_disable(pdata->clk); 178 176 return 0; ··· 182 184 void __iomem *base = pdata->reg_base; 183 185 int year = tm->tm_year - 100; 184 186 185 - dev_dbg(dev, "set time %04d.%02d.%02d %02d:%02d:%02d\n", 186 - 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, 187 - tm->tm_hour, tm->tm_min, tm->tm_sec); 187 + dev_dbg(dev, "set time %ptR\n", tm); 188 188 189 189 if (year < 0 || year >= 100) { 190 190 dev_err(dev, "rtc only supports 100 years\n"); ··· 220 224 221 225 alrm->enabled = (alm_en & PIC32_RTCALRM_ALRMEN) ? 1 : 0; 222 226 223 - dev_dbg(dev, "getalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", 224 - alm_en, 225 - 1900 + alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, 226 - alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec); 227 + dev_dbg(dev, "getalarm: %d, %ptR\n", alm_en, alm_tm); 227 228 228 229 alm_tm->tm_sec = bcd2bin(alm_tm->tm_sec); 229 230 alm_tm->tm_min = bcd2bin(alm_tm->tm_min); ··· 240 247 void __iomem *base = pdata->reg_base; 241 248 242 249 clk_enable(pdata->clk); 243 - dev_dbg(dev, "setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", 244 - alrm->enabled, 245 - 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, 246 - tm->tm_hour, tm->tm_min, tm->tm_sec); 250 + dev_dbg(dev, "setalarm: %d, %ptR\n", alrm->enabled, tm); 247 251 248 252 writel(0x00, base + PIC32_ALRMTIME); 249 253 writel(0x00, base + PIC32_ALRMDATE);
+5 -11
drivers/rtc/rtc-pm8xxx.c
··· 217 217 218 218 rtc_time_to_tm(secs, tm); 219 219 220 - dev_dbg(dev, "secs = %lu, h:m:s == %d:%d:%d, d/m/y = %d/%d/%d\n", 221 - secs, tm->tm_hour, tm->tm_min, tm->tm_sec, 222 - tm->tm_mday, tm->tm_mon, tm->tm_year); 220 + dev_dbg(dev, "secs = %lu, h:m:s == %ptRt, y-m-d = %ptRdr\n", secs, tm, tm); 223 221 224 222 return 0; 225 223 } ··· 262 264 goto rtc_rw_fail; 263 265 } 264 266 265 - dev_dbg(dev, "Alarm Set for h:r:s=%d:%d:%d, d/m/y=%d/%d/%d\n", 266 - alarm->time.tm_hour, alarm->time.tm_min, 267 - alarm->time.tm_sec, alarm->time.tm_mday, 268 - alarm->time.tm_mon, alarm->time.tm_year); 267 + dev_dbg(dev, "Alarm Set for h:m:s=%ptRt, y-m-d=%ptRdr\n", 268 + &alarm->time, &alarm->time); 269 269 rtc_rw_fail: 270 270 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); 271 271 return rc; ··· 294 298 return rc; 295 299 } 296 300 297 - dev_dbg(dev, "Alarm set for - h:r:s=%d:%d:%d, d/m/y=%d/%d/%d\n", 298 - alarm->time.tm_hour, alarm->time.tm_min, 299 - alarm->time.tm_sec, alarm->time.tm_mday, 300 - alarm->time.tm_mon, alarm->time.tm_year); 301 + dev_dbg(dev, "Alarm set for - h:m:s=%ptRt, y-m-d=%ptRdr\n", 302 + &alarm->time, &alarm->time); 301 303 302 304 return 0; 303 305 }
+5 -31
drivers/rtc/rtc-proc.c drivers/rtc/proc.c
··· 50 50 err = rtc_read_time(rtc, &tm); 51 51 if (err == 0) { 52 52 seq_printf(seq, 53 - "rtc_time\t: %02d:%02d:%02d\n" 54 - "rtc_date\t: %04d-%02d-%02d\n", 55 - tm.tm_hour, tm.tm_min, tm.tm_sec, 56 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); 53 + "rtc_time\t: %ptRt\n" 54 + "rtc_date\t: %ptRd\n", 55 + &tm, &tm); 57 56 } 58 57 59 58 err = rtc_read_alarm(rtc, &alrm); 60 59 if (err == 0) { 61 - seq_printf(seq, "alrm_time\t: "); 62 - if ((unsigned int)alrm.time.tm_hour <= 24) 63 - seq_printf(seq, "%02d:", alrm.time.tm_hour); 64 - else 65 - seq_printf(seq, "**:"); 66 - if ((unsigned int)alrm.time.tm_min <= 59) 67 - seq_printf(seq, "%02d:", alrm.time.tm_min); 68 - else 69 - seq_printf(seq, "**:"); 70 - if ((unsigned int)alrm.time.tm_sec <= 59) 71 - seq_printf(seq, "%02d\n", alrm.time.tm_sec); 72 - else 73 - seq_printf(seq, "**\n"); 74 - 75 - seq_printf(seq, "alrm_date\t: "); 76 - if ((unsigned int)alrm.time.tm_year <= 200) 77 - seq_printf(seq, "%04d-", alrm.time.tm_year + 1900); 78 - else 79 - seq_printf(seq, "****-"); 80 - if ((unsigned int)alrm.time.tm_mon <= 11) 81 - seq_printf(seq, "%02d-", alrm.time.tm_mon + 1); 82 - else 83 - seq_printf(seq, "**-"); 84 - if (alrm.time.tm_mday && (unsigned int)alrm.time.tm_mday <= 31) 85 - seq_printf(seq, "%02d\n", alrm.time.tm_mday); 86 - else 87 - seq_printf(seq, "**\n"); 60 + seq_printf(seq, "alrm_time\t: %ptRt\n", &alrm.time); 61 + seq_printf(seq, "alrm_date\t: %ptRd\n", &alrm.time); 88 62 seq_printf(seq, "alarm_IRQ\t: %s\n", 89 63 alrm.enabled ? "yes" : "no"); 90 64 seq_printf(seq, "alrm_pending\t: %s\n",
+4 -14
drivers/rtc/rtc-puv3.c
··· 90 90 { 91 91 rtc_time_to_tm(readl(RTC_RCNR), rtc_tm); 92 92 93 - dev_dbg(dev, "read time %02x.%02x.%02x %02x/%02x/%02x\n", 94 - rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, 95 - rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); 93 + dev_dbg(dev, "read time %ptRr\n", rtc_tm); 96 94 97 95 return 0; 98 96 } ··· 99 101 { 100 102 unsigned long rtc_count = 0; 101 103 102 - dev_dbg(dev, "set time %02d.%02d.%02d %02d/%02d/%02d\n", 103 - tm->tm_year, tm->tm_mon, tm->tm_mday, 104 - tm->tm_hour, tm->tm_min, tm->tm_sec); 104 + dev_dbg(dev, "set time %ptRr\n", tm); 105 105 106 106 rtc_tm_to_time(tm, &rtc_count); 107 107 writel(rtc_count, RTC_RCNR); ··· 115 119 116 120 alrm->enabled = readl(RTC_RTSR) & RTC_RTSR_ALE; 117 121 118 - dev_dbg(dev, "read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n", 119 - alrm->enabled, 120 - alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, 121 - alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec); 122 + dev_dbg(dev, "read alarm: %d, %ptRr\n", alrm->enabled, alm_tm); 122 123 123 124 return 0; 124 125 } ··· 125 132 struct rtc_time *tm = &alrm->time; 126 133 unsigned long rtcalarm_count = 0; 127 134 128 - dev_dbg(dev, "puv3_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n", 129 - alrm->enabled, 130 - tm->tm_mday & 0xff, tm->tm_mon & 0xff, tm->tm_year & 0xff, 131 - tm->tm_hour & 0xff, tm->tm_min & 0xff, tm->tm_sec); 135 + dev_dbg(dev, "set alarm: %d, %ptRr\n", alrm->enabled, tm); 132 136 133 137 rtc_tm_to_time(tm, &rtcalarm_count); 134 138 writel(rtcalarm_count, RTC_RTAR);
+7 -15
drivers/rtc/rtc-rk808.c
··· 138 138 tm->tm_year = (bcd2bin(rtc_data[5] & YEARS_REG_MSK)) + 100; 139 139 tm->tm_wday = bcd2bin(rtc_data[6] & WEEKS_REG_MSK); 140 140 rockchip_to_gregorian(tm); 141 - dev_dbg(dev, "RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n", 142 - 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, 143 - tm->tm_wday, tm->tm_hour, tm->tm_min, tm->tm_sec); 141 + dev_dbg(dev, "RTC date/time %ptRd(%d) %ptRt\n", tm, tm->tm_wday, tm); 144 142 145 143 return ret; 146 144 } ··· 151 153 u8 rtc_data[NUM_TIME_REGS]; 152 154 int ret; 153 155 154 - dev_dbg(dev, "set RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n", 155 - 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, 156 - tm->tm_wday, tm->tm_hour, tm->tm_min, tm->tm_sec); 156 + dev_dbg(dev, "set RTC date/time %ptRd(%d) %ptRt\n", tm, tm->tm_wday, tm); 157 157 gregorian_to_rockchip(tm); 158 158 rtc_data[0] = bin2bcd(tm->tm_sec); 159 159 rtc_data[1] = bin2bcd(tm->tm_min); ··· 212 216 return ret; 213 217 } 214 218 215 - dev_dbg(dev, "alrm read RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n", 216 - 1900 + alrm->time.tm_year, alrm->time.tm_mon + 1, 217 - alrm->time.tm_mday, alrm->time.tm_wday, alrm->time.tm_hour, 218 - alrm->time.tm_min, alrm->time.tm_sec); 219 + dev_dbg(dev, "alrm read RTC date/time %ptRd(%d) %ptRt\n", 220 + &alrm->time, alrm->time.tm_wday, &alrm->time); 219 221 220 222 alrm->enabled = (int_reg & BIT_RTC_INTERRUPTS_REG_IT_ALARM_M) ? 1 : 0; 221 223 ··· 255 261 dev_err(dev, "Failed to stop alarm: %d\n", ret); 256 262 return ret; 257 263 } 258 - dev_dbg(dev, "alrm set RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n", 259 - 1900 + alrm->time.tm_year, alrm->time.tm_mon + 1, 260 - alrm->time.tm_mday, alrm->time.tm_wday, alrm->time.tm_hour, 261 - alrm->time.tm_min, alrm->time.tm_sec); 264 + dev_dbg(dev, "alrm set RTC date/time %ptRd(%d) %ptRt\n", 265 + &alrm->time, alrm->time.tm_wday, &alrm->time); 262 266 263 267 gregorian_to_rockchip(&alrm->time); 264 268 alrm_data[0] = bin2bcd(alrm->time.tm_sec); ··· 392 400 if (ret) { 393 401 dev_err(&pdev->dev, 394 402 "Failed to write RTC status: %d\n", ret); 395 - return ret; 403 + return ret; 396 404 } 397 405 398 406 device_init_wakeup(&pdev->dev, 1);
+3 -9
drivers/rtc/rtc-rx6110.c
··· 114 114 */ 115 115 static int rx6110_rtc_tm_to_data(struct rtc_time *tm, u8 *data) 116 116 { 117 - pr_debug("%s: date %ds %dm %dh %dmd %dm %dy\n", __func__, 118 - tm->tm_sec, tm->tm_min, tm->tm_hour, 119 - tm->tm_mday, tm->tm_mon, tm->tm_year); 117 + pr_debug("%s: date %ptRr\n", __func__, tm); 120 118 121 119 /* 122 120 * The year in the RTC is a value between 0 and 99. ··· 152 154 tm->tm_mon = bcd2bin(data[RTC_MONTH] & 0x1f) - 1; 153 155 tm->tm_year = bcd2bin(data[RTC_YEAR]) + 100; 154 156 155 - pr_debug("%s: date %ds %dm %dh %dmd %dm %dy\n", __func__, 156 - tm->tm_sec, tm->tm_min, tm->tm_hour, 157 - tm->tm_mday, tm->tm_mon, tm->tm_year); 157 + pr_debug("%s: date %ptRr\n", __func__, tm); 158 158 159 159 /* 160 160 * The year in the RTC is a value between 0 and 99. ··· 244 248 if (ret) 245 249 return ret; 246 250 247 - dev_dbg(dev, "%s: date %ds %dm %dh %dmd %dm %dy\n", __func__, 248 - tm->tm_sec, tm->tm_min, tm->tm_hour, 249 - tm->tm_mday, tm->tm_mon, tm->tm_year); 251 + dev_dbg(dev, "%s: date %ptRr\n", __func__, tm); 250 252 251 253 return 0; 252 254 }
+4 -15
drivers/rtc/rtc-rx8025.c
··· 193 193 if (err) 194 194 return err; 195 195 196 - dev_dbg(dev, "%s: read 0x%02x 0x%02x " 197 - "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", __func__, 198 - date[0], date[1], date[2], date[3], date[4], 199 - date[5], date[6]); 196 + dev_dbg(dev, "%s: read %7ph\n", __func__, date); 200 197 201 198 dt->tm_sec = bcd2bin(date[RX8025_REG_SEC] & 0x7f); 202 199 dt->tm_min = bcd2bin(date[RX8025_REG_MIN] & 0x7f); ··· 207 210 dt->tm_mon = bcd2bin(date[RX8025_REG_MONTH] & 0x1f) - 1; 208 211 dt->tm_year = bcd2bin(date[RX8025_REG_YEAR]) + 100; 209 212 210 - dev_dbg(dev, "%s: date %ds %dm %dh %dmd %dm %dy\n", __func__, 211 - dt->tm_sec, dt->tm_min, dt->tm_hour, 212 - dt->tm_mday, dt->tm_mon, dt->tm_year); 213 + dev_dbg(dev, "%s: date %ptRr\n", __func__, dt); 213 214 214 215 return 0; 215 216 } ··· 238 243 date[RX8025_REG_MONTH] = bin2bcd(dt->tm_mon + 1); 239 244 date[RX8025_REG_YEAR] = bin2bcd(dt->tm_year - 100); 240 245 241 - dev_dbg(dev, 242 - "%s: write 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", 243 - __func__, 244 - date[0], date[1], date[2], date[3], date[4], date[5], date[6]); 246 + dev_dbg(dev, "%s: write %7ph\n", __func__, date); 245 247 246 248 ret = rx8025_write_regs(rx8025->client, RX8025_REG_SEC, 7, date); 247 249 if (ret < 0) ··· 311 319 t->time.tm_hour = bcd2bin(ald[1] & 0x1f) % 12 312 320 + (ald[1] & 0x20 ? 12 : 0); 313 321 314 - dev_dbg(dev, "%s: date: %ds %dm %dh %dmd %dm %dy\n", 315 - __func__, 316 - t->time.tm_sec, t->time.tm_min, t->time.tm_hour, 317 - t->time.tm_mday, t->time.tm_mon, t->time.tm_year); 322 + dev_dbg(dev, "%s: date: %ptRr\n", __func__, t); 318 323 t->enabled = !!(rx8025->ctrl1 & RX8025_BIT_CTRL1_DALE); 319 324 t->pending = (ctrl2 & RX8025_BIT_CTRL2_DAFG) && t->enabled; 320 325
+4 -22
drivers/rtc/rtc-s3c.c
··· 225 225 s3c_rtc_disable_clk(info); 226 226 227 227 rtc_tm->tm_year += 100; 228 - 229 - dev_dbg(dev, "read time %04d.%02d.%02d %02d:%02d:%02d\n", 230 - 1900 + rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, 231 - rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); 232 - 233 228 rtc_tm->tm_mon -= 1; 234 229 230 + dev_dbg(dev, "read time %ptR\n", rtc_tm); 235 231 return 0; 236 232 } 237 233 ··· 237 241 int year = tm->tm_year - 100; 238 242 int ret; 239 243 240 - dev_dbg(dev, "set time %04d.%02d.%02d %02d:%02d:%02d\n", 241 - 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, 242 - tm->tm_hour, tm->tm_min, tm->tm_sec); 244 + dev_dbg(dev, "set time %ptR\n", tm); 243 245 244 246 /* we get around y2k by simply not supporting it */ 245 247 ··· 286 292 287 293 alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0; 288 294 289 - dev_dbg(dev, "read alarm %d, %04d.%02d.%02d %02d:%02d:%02d\n", 290 - alm_en, 291 - 1900 + alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, 292 - alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec); 295 + dev_dbg(dev, "read alarm %d, %ptR\n", alm_en, alm_tm); 293 296 294 297 /* decode the alarm enable field */ 295 298 if (alm_en & S3C2410_RTCALM_SECEN) ··· 318 327 struct rtc_time *tm = &alrm->time; 319 328 unsigned int alrm_en; 320 329 int ret; 321 - int year = tm->tm_year - 100; 322 330 323 - dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", 324 - alrm->enabled, 325 - 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, 326 - tm->tm_hour, tm->tm_min, tm->tm_sec); 331 + dev_dbg(dev, "s3c_rtc_setalarm: %d, %ptR\n", alrm->enabled, tm); 327 332 328 333 ret = s3c_rtc_enable_clk(info); 329 334 if (ret) ··· 341 354 if (tm->tm_hour < 24 && tm->tm_hour >= 0) { 342 355 alrm_en |= S3C2410_RTCALM_HOUREN; 343 356 writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_ALMHOUR); 344 - } 345 - 346 - if (year < 100 && year >= 0) { 347 - alrm_en |= S3C2410_RTCALM_YEAREN; 348 - writeb(bin2bcd(year), info->base + S3C2410_ALMYEAR); 349 357 } 350 358 351 359 if (tm->tm_mon < 12 && tm->tm_mon >= 0) {
+6 -21
drivers/rtc/rtc-s5m.c
··· 406 406 return -EINVAL; 407 407 } 408 408 409 - dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, 410 - 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, 411 - tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday); 409 + dev_dbg(dev, "%s: %ptR(%d)\n", __func__, tm, tm->tm_wday); 412 410 413 411 return 0; 414 412 } ··· 434 436 if (ret < 0) 435 437 return ret; 436 438 437 - dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, 438 - 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, 439 - tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday); 439 + dev_dbg(dev, "%s: %ptR(%d)\n", __func__, tm, tm->tm_wday); 440 440 441 441 ret = regmap_raw_write(info->regmap, info->regs->time, data, 442 442 info->regs->regs_count); ··· 486 490 return -EINVAL; 487 491 } 488 492 489 - dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, 490 - 1900 + alrm->time.tm_year, 1 + alrm->time.tm_mon, 491 - alrm->time.tm_mday, alrm->time.tm_hour, 492 - alrm->time.tm_min, alrm->time.tm_sec, 493 - alrm->time.tm_wday); 493 + dev_dbg(dev, "%s: %ptR(%d)\n", __func__, &alrm->time, alrm->time.tm_wday); 494 494 495 495 ret = s5m_check_peding_alarm_interrupt(info, alrm); 496 496 ··· 505 513 return ret; 506 514 507 515 s5m8767_data_to_tm(data, &tm, info->rtc_24hr_mode); 508 - dev_dbg(info->dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, 509 - 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, 510 - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_wday); 516 + dev_dbg(info->dev, "%s: %ptR(%d)\n", __func__, &tm, tm.tm_wday); 511 517 512 518 switch (info->device_type) { 513 519 case S5M8763X: ··· 548 558 return ret; 549 559 550 560 s5m8767_data_to_tm(data, &tm, info->rtc_24hr_mode); 551 - dev_dbg(info->dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, 552 - 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday, 553 - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_wday); 561 + dev_dbg(info->dev, "%s: %ptR(%d)\n", __func__, &tm, tm.tm_wday); 554 562 555 563 switch (info->device_type) { 556 564 case S5M8763X: ··· 608 620 return -EINVAL; 609 621 } 610 622 611 - dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__, 612 - 1900 + alrm->time.tm_year, 1 + alrm->time.tm_mon, 613 - alrm->time.tm_mday, alrm->time.tm_hour, alrm->time.tm_min, 614 - alrm->time.tm_sec, alrm->time.tm_wday); 623 + dev_dbg(dev, "%s: %ptR(%d)\n", __func__, &alrm->time, alrm->time.tm_wday); 615 624 616 625 ret = s5m_rtc_stop_alarm(info); 617 626 if (ret < 0)
+2 -5
drivers/rtc/rtc-sh.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * SuperH On-Chip RTC Support 3 4 * ··· 10 9 * 11 10 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> 12 11 * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka 13 - * 14 - * This file is subject to the terms and conditions of the GNU General Public 15 - * License. See the file "COPYING" in the main directory of this archive 16 - * for more details. 17 12 */ 18 13 #include <linux/module.h> 19 14 #include <linux/mod_devicetable.h> ··· 678 681 MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, " 679 682 "Jamie Lenehan <lenehan@twibble.org>, " 680 683 "Angelo Castello <angelo.castello@st.com>"); 681 - MODULE_LICENSE("GPL"); 684 + MODULE_LICENSE("GPL v2"); 682 685 MODULE_ALIAS("platform:" DRV_NAME);
+112 -9
drivers/rtc/rtc-sun6i.c
··· 118 118 #define SUN6I_YEAR_MAX 2033 119 119 #define SUN6I_YEAR_OFF (SUN6I_YEAR_MIN - 1900) 120 120 121 + /* 122 + * There are other differences between models, including: 123 + * 124 + * - number of GPIO pins that can be configured to hold a certain level 125 + * - crypto-key related registers (H5, H6) 126 + * - boot process related (super standby, secondary processor entry address) 127 + * registers (R40, H6) 128 + * - SYS power domain controls (R40) 129 + * - DCXO controls (H6) 130 + * - RC oscillator calibration (H6) 131 + * 132 + * These functions are not covered by this driver. 133 + */ 134 + struct sun6i_rtc_clk_data { 135 + unsigned long rc_osc_rate; 136 + unsigned int fixed_prescaler : 16; 137 + unsigned int has_prescaler : 1; 138 + unsigned int has_out_clk : 1; 139 + unsigned int export_iosc : 1; 140 + }; 141 + 121 142 struct sun6i_rtc_dev { 122 143 struct rtc_device *rtc; 123 144 struct device *dev; 145 + const struct sun6i_rtc_clk_data *data; 124 146 void __iomem *base; 125 147 int irq; 126 148 unsigned long alarm; ··· 161 139 unsigned long parent_rate) 162 140 { 163 141 struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw); 164 - u32 val; 142 + u32 val = 0; 165 143 166 144 val = readl(rtc->base + SUN6I_LOSC_CTRL); 167 145 if (val & SUN6I_LOSC_CTRL_EXT_OSC) 168 146 return parent_rate; 169 147 170 - val = readl(rtc->base + SUN6I_LOSC_CLK_PRESCAL); 171 - val &= GENMASK(4, 0); 148 + if (rtc->data->fixed_prescaler) 149 + parent_rate /= rtc->data->fixed_prescaler; 150 + 151 + if (rtc->data->has_prescaler) { 152 + val = readl(rtc->base + SUN6I_LOSC_CLK_PRESCAL); 153 + val &= GENMASK(4, 0); 154 + } 172 155 173 156 return parent_rate / (val + 1); 174 157 } ··· 212 185 .set_parent = sun6i_rtc_osc_set_parent, 213 186 }; 214 187 215 - static void __init sun6i_rtc_clk_init(struct device_node *node) 188 + static void __init sun6i_rtc_clk_init(struct device_node *node, 189 + const struct sun6i_rtc_clk_data *data) 216 190 { 217 191 struct clk_hw_onecell_data *clk_data; 218 192 struct sun6i_rtc_dev *rtc; 219 193 struct clk_init_data init = { 220 194 .ops = &sun6i_rtc_osc_ops, 195 + .name = "losc", 221 196 }; 197 + const char *iosc_name = "rtc-int-osc"; 222 198 const char *clkout_name = "osc32k-out"; 223 199 const char *parents[2]; 224 200 ··· 229 199 if (!rtc) 230 200 return; 231 201 232 - clk_data = kzalloc(struct_size(clk_data, hws, 2), GFP_KERNEL); 202 + rtc->data = data; 203 + clk_data = kzalloc(struct_size(clk_data, hws, 3), GFP_KERNEL); 233 204 if (!clk_data) { 234 205 kfree(rtc); 235 206 return; ··· 255 224 if (!of_get_property(node, "clocks", NULL)) 256 225 goto err; 257 226 227 + /* Only read IOSC name from device tree if it is exported */ 228 + if (rtc->data->export_iosc) 229 + of_property_read_string_index(node, "clock-output-names", 2, 230 + &iosc_name); 231 + 258 232 rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL, 259 - "rtc-int-osc", 233 + iosc_name, 260 234 NULL, 0, 261 - 667000, 235 + rtc->data->rc_osc_rate, 262 236 300000000); 263 237 if (IS_ERR(rtc->int_osc)) { 264 238 pr_crit("Couldn't register the internal oscillator\n"); ··· 300 264 clk_data->num = 2; 301 265 clk_data->hws[0] = &rtc->hw; 302 266 clk_data->hws[1] = __clk_get_hw(rtc->ext_losc); 267 + if (rtc->data->export_iosc) { 268 + clk_data->hws[2] = rtc->int_osc; 269 + clk_data->num = 3; 270 + } 303 271 of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 304 272 return; 305 273 306 274 err: 307 275 kfree(clk_data); 308 276 } 309 - CLK_OF_DECLARE_DRIVER(sun6i_rtc_clk, "allwinner,sun6i-a31-rtc", 310 - sun6i_rtc_clk_init); 277 + 278 + static const struct sun6i_rtc_clk_data sun6i_a31_rtc_data = { 279 + .rc_osc_rate = 667000, /* datasheet says 600 ~ 700 KHz */ 280 + .has_prescaler = 1, 281 + }; 282 + 283 + static void __init sun6i_a31_rtc_clk_init(struct device_node *node) 284 + { 285 + sun6i_rtc_clk_init(node, &sun6i_a31_rtc_data); 286 + } 287 + CLK_OF_DECLARE_DRIVER(sun6i_a31_rtc_clk, "allwinner,sun6i-a31-rtc", 288 + sun6i_a31_rtc_clk_init); 289 + 290 + static const struct sun6i_rtc_clk_data sun8i_a23_rtc_data = { 291 + .rc_osc_rate = 667000, /* datasheet says 600 ~ 700 KHz */ 292 + .has_prescaler = 1, 293 + .has_out_clk = 1, 294 + }; 295 + 296 + static void __init sun8i_a23_rtc_clk_init(struct device_node *node) 297 + { 298 + sun6i_rtc_clk_init(node, &sun8i_a23_rtc_data); 299 + } 300 + CLK_OF_DECLARE_DRIVER(sun8i_a23_rtc_clk, "allwinner,sun8i-a23-rtc", 301 + sun8i_a23_rtc_clk_init); 302 + 303 + static const struct sun6i_rtc_clk_data sun8i_h3_rtc_data = { 304 + .rc_osc_rate = 16000000, 305 + .fixed_prescaler = 32, 306 + .has_prescaler = 1, 307 + .has_out_clk = 1, 308 + .export_iosc = 1, 309 + }; 310 + 311 + static void __init sun8i_h3_rtc_clk_init(struct device_node *node) 312 + { 313 + sun6i_rtc_clk_init(node, &sun8i_h3_rtc_data); 314 + } 315 + CLK_OF_DECLARE_DRIVER(sun8i_h3_rtc_clk, "allwinner,sun8i-h3-rtc", 316 + sun8i_h3_rtc_clk_init); 317 + /* As far as we are concerned, clocks for H5 are the same as H3 */ 318 + CLK_OF_DECLARE_DRIVER(sun50i_h5_rtc_clk, "allwinner,sun50i-h5-rtc", 319 + sun8i_h3_rtc_clk_init); 320 + 321 + static const struct sun6i_rtc_clk_data sun8i_v3_rtc_data = { 322 + .rc_osc_rate = 32000, 323 + .has_out_clk = 1, 324 + }; 325 + 326 + static void __init sun8i_v3_rtc_clk_init(struct device_node *node) 327 + { 328 + sun6i_rtc_clk_init(node, &sun8i_v3_rtc_data); 329 + } 330 + CLK_OF_DECLARE_DRIVER(sun8i_v3_rtc_clk, "allwinner,sun8i-v3-rtc", 331 + sun8i_v3_rtc_clk_init); 311 332 312 333 static irqreturn_t sun6i_rtc_alarmirq(int irq, void *id) 313 334 { ··· 671 578 return 0; 672 579 } 673 580 581 + /* 582 + * As far as RTC functionality goes, all models are the same. The 583 + * datasheets claim that different models have different number of 584 + * registers available for non-volatile storage, but experiments show 585 + * that all SoCs have 16 registers available for this purpose. 586 + */ 674 587 static const struct of_device_id sun6i_rtc_dt_ids[] = { 675 588 { .compatible = "allwinner,sun6i-a31-rtc" }, 589 + { .compatible = "allwinner,sun8i-a23-rtc" }, 590 + { .compatible = "allwinner,sun8i-h3-rtc" }, 591 + { .compatible = "allwinner,sun8i-v3-rtc" }, 592 + { .compatible = "allwinner,sun50i-h5-rtc" }, 676 593 { /* sentinel */ }, 677 594 }; 678 595 MODULE_DEVICE_TABLE(of, sun6i_rtc_dt_ids);
+6 -10
drivers/rtc/rtc-sysfs.c drivers/rtc/sysfs.c
··· 39 39 struct rtc_time tm; 40 40 41 41 retval = rtc_read_time(to_rtc_device(dev), &tm); 42 - if (retval == 0) { 43 - retval = sprintf(buf, "%04d-%02d-%02d\n", 44 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); 45 - } 42 + if (retval) 43 + return retval; 46 44 47 - return retval; 45 + return sprintf(buf, "%ptRd\n", &tm); 48 46 } 49 47 static DEVICE_ATTR_RO(date); 50 48 ··· 53 55 struct rtc_time tm; 54 56 55 57 retval = rtc_read_time(to_rtc_device(dev), &tm); 56 - if (retval == 0) { 57 - retval = sprintf(buf, "%02d:%02d:%02d\n", 58 - tm.tm_hour, tm.tm_min, tm.tm_sec); 59 - } 58 + if (retval) 59 + return retval; 60 60 61 - return retval; 61 + return sprintf(buf, "%ptRt\n", &tm); 62 62 } 63 63 static DEVICE_ATTR_RO(time); 64 64
+3 -27
drivers/rtc/rtc-tegra.c
··· 125 125 126 126 rtc_time_to_tm(sec, tm); 127 127 128 - dev_vdbg(dev, "time read as %lu. %d/%d/%d %d:%02u:%02u\n", 129 - sec, 130 - tm->tm_mon + 1, 131 - tm->tm_mday, 132 - tm->tm_year + 1900, 133 - tm->tm_hour, 134 - tm->tm_min, 135 - tm->tm_sec 136 - ); 128 + dev_vdbg(dev, "time read as %lu. %ptR\n", sec, tm); 137 129 138 130 return 0; 139 131 } ··· 139 147 /* convert tm to seconds. */ 140 148 rtc_tm_to_time(tm, &sec); 141 149 142 - dev_vdbg(dev, "time set to %lu. %d/%d/%d %d:%02u:%02u\n", 143 - sec, 144 - tm->tm_mon+1, 145 - tm->tm_mday, 146 - tm->tm_year+1900, 147 - tm->tm_hour, 148 - tm->tm_min, 149 - tm->tm_sec 150 - ); 150 + dev_vdbg(dev, "time set to %lu. %ptR\n", sec, tm); 151 151 152 152 /* seconds only written if wait succeeded. */ 153 153 ret = tegra_rtc_wait_while_busy(dev); ··· 216 232 /* if successfully written and alarm is enabled ... */ 217 233 if (sec) { 218 234 tegra_rtc_alarm_irq_enable(dev, 1); 219 - 220 - dev_vdbg(dev, "alarm set as %lu. %d/%d/%d %d:%02u:%02u\n", 221 - sec, 222 - alarm->time.tm_mon+1, 223 - alarm->time.tm_mday, 224 - alarm->time.tm_year+1900, 225 - alarm->time.tm_hour, 226 - alarm->time.tm_min, 227 - alarm->time.tm_sec); 235 + dev_vdbg(dev, "alarm set as %lu. %ptR\n", sec, &alarm->time); 228 236 } else { 229 237 /* disable alarm if 0 or write error. */ 230 238 dev_vdbg(dev, "alarm disabled\n");
+8 -9
include/linux/rtc.h
··· 87 87 int (*set_offset)(struct device *, long offset); 88 88 }; 89 89 90 + struct rtc_device; 91 + 90 92 struct rtc_timer { 91 93 struct timerqueue_node node; 92 94 ktime_t period; 93 - void (*func)(void *private_data); 94 - void *private_data; 95 + void (*func)(struct rtc_device *rtc); 96 + struct rtc_device *rtc; 95 97 int enabled; 96 98 }; 97 - 98 99 99 100 /* flags */ 100 101 #define RTC_DEV_BUSY 0 ··· 139 138 140 139 bool registered; 141 140 142 - struct nvmem_device *nvmem; 143 141 /* Old ABI support */ 144 142 bool nvram_old_abi; 145 143 struct bin_attribute *nvram; ··· 173 173 struct module *owner); 174 174 struct rtc_device *devm_rtc_allocate_device(struct device *dev); 175 175 int __rtc_register_device(struct module *owner, struct rtc_device *rtc); 176 - extern void devm_rtc_device_unregister(struct device *dev, 177 - struct rtc_device *rtc); 178 176 179 177 extern int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm); 180 178 extern int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm); ··· 198 200 unsigned int enabled); 199 201 200 202 void rtc_handle_legacy_irq(struct rtc_device *rtc, int num, int mode); 201 - void rtc_aie_update_irq(void *private); 202 - void rtc_uie_update_irq(void *private); 203 + void rtc_aie_update_irq(struct rtc_device *rtc); 204 + void rtc_uie_update_irq(struct rtc_device *rtc); 203 205 enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer); 204 206 205 - void rtc_timer_init(struct rtc_timer *timer, void (*f)(void *p), void *data); 207 + void rtc_timer_init(struct rtc_timer *timer, void (*f)(struct rtc_device *r), 208 + struct rtc_device *rtc); 206 209 int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer *timer, 207 210 ktime_t expires, ktime_t period); 208 211 void rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer *timer);
+58 -3
lib/test_printf.c
··· 9 9 #include <linux/module.h> 10 10 #include <linux/printk.h> 11 11 #include <linux/random.h> 12 + #include <linux/rtc.h> 12 13 #include <linux/slab.h> 13 14 #include <linux/string.h> 14 15 ··· 250 249 #endif /* BITS_PER_LONG == 64 */ 251 250 252 251 static int __init 253 - plain_hash(void) 252 + plain_hash_to_buffer(const void *p, char *buf, size_t len) 254 253 { 255 - char buf[PLAIN_BUF_SIZE]; 256 254 int nchars; 257 255 258 - nchars = snprintf(buf, PLAIN_BUF_SIZE, "%p", PTR); 256 + nchars = snprintf(buf, len, "%p", p); 259 257 260 258 if (nchars != PTR_WIDTH) 261 259 return -1; ··· 264 264 PTR_VAL_NO_CRNG); 265 265 return 0; 266 266 } 267 + 268 + return 0; 269 + } 270 + 271 + 272 + static int __init 273 + plain_hash(void) 274 + { 275 + char buf[PLAIN_BUF_SIZE]; 276 + int ret; 277 + 278 + ret = plain_hash_to_buffer(PTR, buf, PLAIN_BUF_SIZE); 279 + if (ret) 280 + return ret; 267 281 268 282 if (strncmp(buf, PTR_STR, PTR_WIDTH) == 0) 269 283 return -1; ··· 306 292 pr_warn("hashing plain 'p' has unexpected format\n"); 307 293 failed_tests++; 308 294 } 295 + } 296 + 297 + static void __init 298 + test_hashed(const char *fmt, const void *p) 299 + { 300 + char buf[PLAIN_BUF_SIZE]; 301 + int ret; 302 + 303 + /* 304 + * No need to increase failed test counter since this is assumed 305 + * to be called after plain(). 306 + */ 307 + ret = plain_hash_to_buffer(p, buf, PLAIN_BUF_SIZE); 308 + if (ret) 309 + return; 310 + 311 + test(buf, fmt, p); 309 312 } 310 313 311 314 static void __init ··· 450 419 } 451 420 452 421 static void __init 422 + struct_rtc_time(void) 423 + { 424 + /* 1543210543 */ 425 + const struct rtc_time tm = { 426 + .tm_sec = 43, 427 + .tm_min = 35, 428 + .tm_hour = 5, 429 + .tm_mday = 26, 430 + .tm_mon = 10, 431 + .tm_year = 118, 432 + }; 433 + 434 + test_hashed("%pt", &tm); 435 + 436 + test("2018-11-26T05:35:43", "%ptR", &tm); 437 + test("0118-10-26T05:35:43", "%ptRr", &tm); 438 + test("05:35:43|2018-11-26", "%ptRt|%ptRd", &tm, &tm); 439 + test("05:35:43|0118-10-26", "%ptRtr|%ptRdr", &tm, &tm); 440 + test("05:35:43|2018-11-26", "%ptRttr|%ptRdtr", &tm, &tm); 441 + test("05:35:43 tr|2018-11-26 tr", "%ptRt tr|%ptRd tr", &tm, &tm); 442 + } 443 + 444 + static void __init 453 445 struct_clk(void) 454 446 { 455 447 } ··· 583 529 uuid(); 584 530 dentry(); 585 531 struct_va_format(); 532 + struct_rtc_time(); 586 533 struct_clk(); 587 534 bitmap(); 588 535 netdev_features();
+100
lib/vsprintf.c
··· 30 30 #include <linux/ioport.h> 31 31 #include <linux/dcache.h> 32 32 #include <linux/cred.h> 33 + #include <linux/rtc.h> 33 34 #include <linux/uuid.h> 34 35 #include <linux/of.h> 35 36 #include <net/addrconf.h> ··· 823 822 .precision = -1, 824 823 }; 825 824 825 + static const struct printf_spec default_dec02_spec = { 826 + .base = 10, 827 + .field_width = 2, 828 + .precision = -1, 829 + .flags = ZEROPAD, 830 + }; 831 + 832 + static const struct printf_spec default_dec04_spec = { 833 + .base = 10, 834 + .field_width = 4, 835 + .precision = -1, 836 + .flags = ZEROPAD, 837 + }; 838 + 826 839 static noinline_for_stack 827 840 char *resource_string(char *buf, char *end, struct resource *res, 828 841 struct printf_spec spec, const char *fmt) ··· 1565 1550 } 1566 1551 1567 1552 static noinline_for_stack 1553 + char *date_str(char *buf, char *end, const struct rtc_time *tm, bool r) 1554 + { 1555 + int year = tm->tm_year + (r ? 0 : 1900); 1556 + int mon = tm->tm_mon + (r ? 0 : 1); 1557 + 1558 + buf = number(buf, end, year, default_dec04_spec); 1559 + if (buf < end) 1560 + *buf = '-'; 1561 + buf++; 1562 + 1563 + buf = number(buf, end, mon, default_dec02_spec); 1564 + if (buf < end) 1565 + *buf = '-'; 1566 + buf++; 1567 + 1568 + return number(buf, end, tm->tm_mday, default_dec02_spec); 1569 + } 1570 + 1571 + static noinline_for_stack 1572 + char *time_str(char *buf, char *end, const struct rtc_time *tm, bool r) 1573 + { 1574 + buf = number(buf, end, tm->tm_hour, default_dec02_spec); 1575 + if (buf < end) 1576 + *buf = ':'; 1577 + buf++; 1578 + 1579 + buf = number(buf, end, tm->tm_min, default_dec02_spec); 1580 + if (buf < end) 1581 + *buf = ':'; 1582 + buf++; 1583 + 1584 + return number(buf, end, tm->tm_sec, default_dec02_spec); 1585 + } 1586 + 1587 + static noinline_for_stack 1588 + char *rtc_str(char *buf, char *end, const struct rtc_time *tm, const char *fmt) 1589 + { 1590 + bool have_t = true, have_d = true; 1591 + bool raw = false; 1592 + int count = 2; 1593 + 1594 + switch (fmt[count]) { 1595 + case 'd': 1596 + have_t = false; 1597 + count++; 1598 + break; 1599 + case 't': 1600 + have_d = false; 1601 + count++; 1602 + break; 1603 + } 1604 + 1605 + raw = fmt[count] == 'r'; 1606 + 1607 + if (have_d) 1608 + buf = date_str(buf, end, tm, raw); 1609 + if (have_d && have_t) { 1610 + /* Respect ISO 8601 */ 1611 + if (buf < end) 1612 + *buf = 'T'; 1613 + buf++; 1614 + } 1615 + if (have_t) 1616 + buf = time_str(buf, end, tm, raw); 1617 + 1618 + return buf; 1619 + } 1620 + 1621 + static noinline_for_stack 1622 + char *time_and_date(char *buf, char *end, void *ptr, struct printf_spec spec, 1623 + const char *fmt) 1624 + { 1625 + switch (fmt[1]) { 1626 + case 'R': 1627 + return rtc_str(buf, end, (const struct rtc_time *)ptr, fmt); 1628 + default: 1629 + return ptr_to_id(buf, end, ptr, spec); 1630 + } 1631 + } 1632 + 1633 + static noinline_for_stack 1568 1634 char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec, 1569 1635 const char *fmt) 1570 1636 { ··· 1924 1828 * - 'd[234]' For a dentry name (optionally 2-4 last components) 1925 1829 * - 'D[234]' Same as 'd' but for a struct file 1926 1830 * - 'g' For block_device name (gendisk + partition number) 1831 + * - 't[R][dt][r]' For time and date as represented: 1832 + * R struct rtc_time 1927 1833 * - 'C' For a clock, it prints the name (Common Clock Framework) or address 1928 1834 * (legacy clock framework) of the clock 1929 1835 * - 'Cn' For a clock, it prints the name (Common Clock Framework) or address ··· 2050 1952 return address_val(buf, end, ptr, fmt); 2051 1953 case 'd': 2052 1954 return dentry_name(buf, end, ptr, spec, fmt); 1955 + case 't': 1956 + return time_and_date(buf, end, ptr, spec, fmt); 2053 1957 case 'C': 2054 1958 return clock(buf, end, ptr, spec, fmt); 2055 1959 case 'D':