aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-pcap.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-09 17:46:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-09 17:46:33 -0400
commit8e4ff713ce313dcabbb60e6ede1ffc193e67631f (patch)
tree8efdfe4925570ec8608d40e229ed01a5432d901e /drivers/rtc/rtc-pcap.c
parent45182e4e1f8ac04708ca7508c51d9103f07d81ab (diff)
parentdacb6a4035a010e41abaf81c1cfe2beadfb05ec8 (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-pcap.c')
-rw-r--r--drivers/rtc/rtc-pcap.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c
index f176cb9d0dbc..178bfb1dea21 100644
--- a/drivers/rtc/rtc-pcap.c
+++ b/drivers/rtc/rtc-pcap.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * pcap rtc code for Motorola EZX phones 3 * pcap rtc code for Motorola EZX phones
3 * 4 *
@@ -5,11 +6,6 @@
5 * Copyright (c) 2009 Daniel Ribeiro <drwyrm@gmail.com> 6 * Copyright (c) 2009 Daniel Ribeiro <drwyrm@gmail.com>
6 * 7 *
7 * Based on Motorola's rtc.c Copyright (c) 2003-2005 Motorola 8 * Based on Motorola's rtc.c Copyright (c) 2003-2005 Motorola
8 *
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 */ 9 */
14 10
15#include <linux/kernel.h> 11#include <linux/kernel.h>
@@ -55,7 +51,7 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
55 ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days); 51 ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days);
56 secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY; 52 secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
57 53
58 rtc_time_to_tm(secs, tm); 54 rtc_time64_to_tm(secs, tm);
59 55
60 return 0; 56 return 0;
61} 57}
@@ -63,12 +59,9 @@ static int pcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
63static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 59static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
64{ 60{
65 struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev); 61 struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev);
66 struct rtc_time *tm = &alrm->time; 62 unsigned long secs = rtc_tm_to_time64(&alrm->time);
67 unsigned long secs;
68 u32 tod, days; 63 u32 tod, days;
69 64
70 rtc_tm_to_time(tm, &secs);
71
72 tod = secs % SEC_PER_DAY; 65 tod = secs % SEC_PER_DAY;
73 ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod); 66 ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod);
74 67
@@ -90,14 +83,15 @@ static int pcap_rtc_read_time(struct device *dev, struct rtc_time *tm)
90 ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days); 83 ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days);
91 secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY; 84 secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY;
92 85
93 rtc_time_to_tm(secs, tm); 86 rtc_time64_to_tm(secs, tm);
94 87
95 return 0; 88 return 0;
96} 89}
97 90
98static int pcap_rtc_set_mmss(struct device *dev, unsigned long secs) 91static int pcap_rtc_set_time(struct device *dev, struct rtc_time *tm)
99{ 92{
100 struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev); 93 struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev);
94 unsigned long secs = rtc_tm_to_time64(tm);
101 u32 tod, days; 95 u32 tod, days;
102 96
103 tod = secs % SEC_PER_DAY; 97 tod = secs % SEC_PER_DAY;
@@ -128,9 +122,9 @@ static int pcap_rtc_alarm_irq_enable(struct device *dev, unsigned int en)
128 122
129static const struct rtc_class_ops pcap_rtc_ops = { 123static const struct rtc_class_ops pcap_rtc_ops = {
130 .read_time = pcap_rtc_read_time, 124 .read_time = pcap_rtc_read_time,
125 .set_time = pcap_rtc_set_time,
131 .read_alarm = pcap_rtc_read_alarm, 126 .read_alarm = pcap_rtc_read_alarm,
132 .set_alarm = pcap_rtc_set_alarm, 127 .set_alarm = pcap_rtc_set_alarm,
133 .set_mmss = pcap_rtc_set_mmss,
134 .alarm_irq_enable = pcap_rtc_alarm_irq_enable, 128 .alarm_irq_enable = pcap_rtc_alarm_irq_enable,
135}; 129};
136 130
@@ -149,11 +143,13 @@ static int __init pcap_rtc_probe(struct platform_device *pdev)
149 143
150 platform_set_drvdata(pdev, pcap_rtc); 144 platform_set_drvdata(pdev, pcap_rtc);
151 145
152 pcap_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pcap", 146 pcap_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
153 &pcap_rtc_ops, THIS_MODULE);
154 if (IS_ERR(pcap_rtc->rtc)) 147 if (IS_ERR(pcap_rtc->rtc))
155 return PTR_ERR(pcap_rtc->rtc); 148 return PTR_ERR(pcap_rtc->rtc);
156 149
150 pcap_rtc->rtc->ops = &pcap_rtc_ops;
151 pcap_rtc->rtc->range_max = (1 << 14) * 86400ULL - 1;
152
157 timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); 153 timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ);
158 alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); 154 alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA);
159 155
@@ -167,7 +163,7 @@ static int __init pcap_rtc_probe(struct platform_device *pdev)
167 if (err) 163 if (err)
168 return err; 164 return err;
169 165
170 return 0; 166 return rtc_register_device(pcap_rtc->rtc);
171} 167}
172 168
173static int __exit pcap_rtc_remove(struct platform_device *pdev) 169static int __exit pcap_rtc_remove(struct platform_device *pdev)