hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-st-lpc.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * rtc-st-lpc.c - ST's LPC RTC, powered by the Low Power Timer
34 *
....@@ -7,11 +8,6 @@
78 * Lee Jones <lee.jones@linaro.org> for STMicroelectronics
89 *
910 * Based on the original driver written by Stuart Menefy.
10
- *
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public Licence
13
- * as published by the Free Software Foundation; either version
14
- * 2 of the Licence, or (at your option) any later version.
1511 */
1612
1713 #include <linux/clk.h>
....@@ -45,7 +41,6 @@
4541 struct st_rtc {
4642 struct rtc_device *rtc_dev;
4743 struct rtc_wkalrm alarm;
48
- struct resource *res;
4944 struct clk *clk;
5045 unsigned long clkrate;
5146 void __iomem *ioaddr;
....@@ -166,10 +161,6 @@
166161 now_secs = rtc_tm_to_time64(&now);
167162 alarm_secs = rtc_tm_to_time64(&t->time);
168163
169
- /* Invalid alarm time */
170
- if (now_secs > alarm_secs)
171
- return -EINVAL;
172
-
173164 memcpy(&rtc->alarm, t, sizeof(struct rtc_wkalrm));
174165
175166 /* Now many secs to fire */
....@@ -182,7 +173,7 @@
182173 return 0;
183174 }
184175
185
-static struct rtc_class_ops st_rtc_ops = {
176
+static const struct rtc_class_ops st_rtc_ops = {
186177 .read_time = st_rtc_read_time,
187178 .set_time = st_rtc_set_time,
188179 .read_alarm = st_rtc_read_alarm,
....@@ -194,7 +185,6 @@
194185 {
195186 struct device_node *np = pdev->dev.of_node;
196187 struct st_rtc *rtc;
197
- struct resource *res;
198188 uint32_t mode;
199189 int ret = 0;
200190
....@@ -218,8 +208,7 @@
218208
219209 spin_lock_init(&rtc->lock);
220210
221
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
222
- rtc->ioaddr = devm_ioremap_resource(&pdev->dev, res);
211
+ rtc->ioaddr = devm_platform_ioremap_resource(pdev, 0);
223212 if (IS_ERR(rtc->ioaddr))
224213 return PTR_ERR(rtc->ioaddr);
225214
....@@ -239,7 +228,7 @@
239228 enable_irq_wake(rtc->irq);
240229 disable_irq(rtc->irq);
241230
242
- rtc->clk = clk_get(&pdev->dev, NULL);
231
+ rtc->clk = devm_clk_get(&pdev->dev, NULL);
243232 if (IS_ERR(rtc->clk)) {
244233 dev_err(&pdev->dev, "Unable to request clock\n");
245234 return PTR_ERR(rtc->clk);
....@@ -249,6 +238,7 @@
249238
250239 rtc->clkrate = clk_get_rate(rtc->clk);
251240 if (!rtc->clkrate) {
241
+ clk_disable_unprepare(rtc->clk);
252242 dev_err(&pdev->dev, "Unable to fetch clock rate\n");
253243 return -EINVAL;
254244 }