diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-09 17:46:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-09 17:46:33 -0400 |
commit | 8e4ff713ce313dcabbb60e6ede1ffc193e67631f (patch) | |
tree | 8efdfe4925570ec8608d40e229ed01a5432d901e /drivers/rtc/rtc-omap.c | |
parent | 45182e4e1f8ac04708ca7508c51d9103f07d81ab (diff) | |
parent | dacb6a4035a010e41abaf81c1cfe2beadfb05ec8 (diff) |
Merge tag 'rtc-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni:
"A huge series from me this cycle. I went through many drivers to set
the date and time range supported by the RTC which helps solving HW
limitation when the time comes (as early as next year for some). This
time, I focused on drivers using .set_mms and .set_mmss64, allowing me
to remove those callbacks. About a third of the patches got reviews, I
actually own the RTCs and I tested another third and the remaining one
are unlikely to cause any issues.
Other than that, a single new driver and the usual fixes here and there.
Summary:
Subsystem:
- set_mmss and set_mmss64 rtc_ops removal
- Fix timestamp value for RTC_TIMESTAMP_BEGIN_1900
- Use SPDX identifier for the core
- validate upper bound of tm->tm_year
New driver:
- Aspeed BMC SoC RTC
Drivers:
- abx80x: use rtc_add_group
- ds3232: nvram support
- pcf85063: add alarm, nvram, offset correction and microcrystal
rv8263 support
- x1205: add of_match_table
- Use set_time instead of set_mms/set_mmss64 for: ab3100, coh901331,
digicolor, ds1672, ds2404, ep93xx, imxdi, jz4740, lpc32xx, mc13xxx,
mxc, pcap, stmp3xxx, test, wm831x, xgene.
- Set RTC range for: ab3100, at91sam9, coh901331, da9063, digicolor,
dm355evm, ds1672, ds2404, ep39xx, goldfish, imxdi, jz4740, lpc32xx,
mc13xxx, mv, mxc, omap, pcap, pcf85063, pcf85363, ps3, sh,
stmp3xxx, sun4v, tegra, wm831x, xgene.
- Switch to rtc_time64_to_tm/rtc_tm_to_time64 for the driver that
properly set the RTC range.
- Use dev_get_drvdata instead of multiple indirections"
* tag 'rtc-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (177 commits)
rtc: snvs: Use __maybe_unused instead of #if CONFIG_PM_SLEEP
rtc: imxdi: remove unused variable
rtc: drop set_mms and set_mmss64
rtc: pcap: convert to SPDX identifier
rtc: pcap: use .set_time
rtc: pcap: switch to rtc_time64_to_tm/rtc_tm_to_time64
rtc: pcap: set range
rtc: digicolor: convert to SPDX identifier
rtc: digicolor: use .set_time
rtc: digicolor: set range
rtc: digicolor: fix possible race condition
rtc: jz4740: convert to SPDX identifier
rtc: jz4740: rework invalid time detection
rtc: jz4740: use dev_pm_set_wake_irq() to simplify code
rtc: jz4740: use .set_time
rtc: jz4740: remove useless check
rtc: jz4740: switch to rtc_time64_to_tm/rtc_tm_to_time64
rtc: jz4740: set range
rtc: 88pm860x: prevent use-after-free on device remove
rtc: Use dev_get_drvdata()
...
Diffstat (limited to 'drivers/rtc/rtc-omap.c')
-rw-r--r-- | drivers/rtc/rtc-omap.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index bbff0e2deb84..32994b0dd139 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * TI OMAP Real Time Clock interface for Linux | 3 | * TI OMAP Real Time Clock interface for Linux |
3 | * | 4 | * |
@@ -6,11 +7,6 @@ | |||
6 | * | 7 | * |
7 | * Copyright (C) 2006 David Brownell (new RTC framework) | 8 | * Copyright (C) 2006 David Brownell (new RTC framework) |
8 | * Copyright (C) 2014 Johan Hovold <johan@kernel.org> | 9 | * Copyright (C) 2014 Johan Hovold <johan@kernel.org> |
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | */ | 10 | */ |
15 | 11 | ||
16 | #include <dt-bindings/gpio/gpio.h> | 12 | #include <dt-bindings/gpio/gpio.h> |
@@ -271,7 +267,7 @@ static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
271 | } | 267 | } |
272 | 268 | ||
273 | /* this hardware doesn't support "don't care" alarm fields */ | 269 | /* this hardware doesn't support "don't care" alarm fields */ |
274 | static int tm2bcd(struct rtc_time *tm) | 270 | static void tm2bcd(struct rtc_time *tm) |
275 | { | 271 | { |
276 | tm->tm_sec = bin2bcd(tm->tm_sec); | 272 | tm->tm_sec = bin2bcd(tm->tm_sec); |
277 | tm->tm_min = bin2bcd(tm->tm_min); | 273 | tm->tm_min = bin2bcd(tm->tm_min); |
@@ -279,13 +275,7 @@ static int tm2bcd(struct rtc_time *tm) | |||
279 | tm->tm_mday = bin2bcd(tm->tm_mday); | 275 | tm->tm_mday = bin2bcd(tm->tm_mday); |
280 | 276 | ||
281 | tm->tm_mon = bin2bcd(tm->tm_mon + 1); | 277 | tm->tm_mon = bin2bcd(tm->tm_mon + 1); |
282 | |||
283 | /* epoch == 1900 */ | ||
284 | if (tm->tm_year < 100 || tm->tm_year > 199) | ||
285 | return -EINVAL; | ||
286 | tm->tm_year = bin2bcd(tm->tm_year - 100); | 278 | tm->tm_year = bin2bcd(tm->tm_year - 100); |
287 | |||
288 | return 0; | ||
289 | } | 279 | } |
290 | 280 | ||
291 | static void bcd2tm(struct rtc_time *tm) | 281 | static void bcd2tm(struct rtc_time *tm) |
@@ -328,8 +318,7 @@ static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
328 | { | 318 | { |
329 | struct omap_rtc *rtc = dev_get_drvdata(dev); | 319 | struct omap_rtc *rtc = dev_get_drvdata(dev); |
330 | 320 | ||
331 | if (tm2bcd(tm) < 0) | 321 | tm2bcd(tm); |
332 | return -EINVAL; | ||
333 | 322 | ||
334 | local_irq_disable(); | 323 | local_irq_disable(); |
335 | rtc_wait_not_busy(rtc); | 324 | rtc_wait_not_busy(rtc); |
@@ -378,8 +367,7 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
378 | struct omap_rtc *rtc = dev_get_drvdata(dev); | 367 | struct omap_rtc *rtc = dev_get_drvdata(dev); |
379 | u8 reg, irqwake_reg = 0; | 368 | u8 reg, irqwake_reg = 0; |
380 | 369 | ||
381 | if (tm2bcd(&alm->time) < 0) | 370 | tm2bcd(&alm->time); |
382 | return -EINVAL; | ||
383 | 371 | ||
384 | local_irq_disable(); | 372 | local_irq_disable(); |
385 | rtc_wait_not_busy(rtc); | 373 | rtc_wait_not_busy(rtc); |
@@ -441,14 +429,10 @@ again: | |||
441 | omap_rtc_read_time_raw(rtc, &tm); | 429 | omap_rtc_read_time_raw(rtc, &tm); |
442 | seconds = tm.tm_sec; | 430 | seconds = tm.tm_sec; |
443 | bcd2tm(&tm); | 431 | bcd2tm(&tm); |
444 | rtc_tm_to_time(&tm, &now); | 432 | now = rtc_tm_to_time64(&tm); |
445 | rtc_time_to_tm(now + 1, &tm); | 433 | rtc_time64_to_tm(now + 1, &tm); |
446 | 434 | ||
447 | if (tm2bcd(&tm) < 0) { | 435 | tm2bcd(&tm); |
448 | dev_err(&rtc->rtc->dev, "power off failed\n"); | ||
449 | rtc->type->lock(rtc); | ||
450 | return; | ||
451 | } | ||
452 | 436 | ||
453 | rtc_wait_not_busy(rtc); | 437 | rtc_wait_not_busy(rtc); |
454 | 438 | ||
@@ -845,6 +829,8 @@ static int omap_rtc_probe(struct platform_device *pdev) | |||
845 | } | 829 | } |
846 | 830 | ||
847 | rtc->rtc->ops = &omap_rtc_ops; | 831 | rtc->rtc->ops = &omap_rtc_ops; |
832 | rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; | ||
833 | rtc->rtc->range_max = RTC_TIMESTAMP_END_2099; | ||
848 | omap_rtc_nvmem_config.priv = rtc; | 834 | omap_rtc_nvmem_config.priv = rtc; |
849 | 835 | ||
850 | /* handle periodic and alarm irqs */ | 836 | /* handle periodic and alarm irqs */ |