.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * rtc-st-lpc.c - ST's LPC RTC, powered by the Low Power Timer |
---|
3 | 4 | * |
---|
.. | .. |
---|
7 | 8 | * Lee Jones <lee.jones@linaro.org> for STMicroelectronics |
---|
8 | 9 | * |
---|
9 | 10 | * 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. |
---|
15 | 11 | */ |
---|
16 | 12 | |
---|
17 | 13 | #include <linux/clk.h> |
---|
.. | .. |
---|
45 | 41 | struct st_rtc { |
---|
46 | 42 | struct rtc_device *rtc_dev; |
---|
47 | 43 | struct rtc_wkalrm alarm; |
---|
48 | | - struct resource *res; |
---|
49 | 44 | struct clk *clk; |
---|
50 | 45 | unsigned long clkrate; |
---|
51 | 46 | void __iomem *ioaddr; |
---|
.. | .. |
---|
166 | 161 | now_secs = rtc_tm_to_time64(&now); |
---|
167 | 162 | alarm_secs = rtc_tm_to_time64(&t->time); |
---|
168 | 163 | |
---|
169 | | - /* Invalid alarm time */ |
---|
170 | | - if (now_secs > alarm_secs) |
---|
171 | | - return -EINVAL; |
---|
172 | | - |
---|
173 | 164 | memcpy(&rtc->alarm, t, sizeof(struct rtc_wkalrm)); |
---|
174 | 165 | |
---|
175 | 166 | /* Now many secs to fire */ |
---|
.. | .. |
---|
182 | 173 | return 0; |
---|
183 | 174 | } |
---|
184 | 175 | |
---|
185 | | -static struct rtc_class_ops st_rtc_ops = { |
---|
| 176 | +static const struct rtc_class_ops st_rtc_ops = { |
---|
186 | 177 | .read_time = st_rtc_read_time, |
---|
187 | 178 | .set_time = st_rtc_set_time, |
---|
188 | 179 | .read_alarm = st_rtc_read_alarm, |
---|
.. | .. |
---|
194 | 185 | { |
---|
195 | 186 | struct device_node *np = pdev->dev.of_node; |
---|
196 | 187 | struct st_rtc *rtc; |
---|
197 | | - struct resource *res; |
---|
198 | 188 | uint32_t mode; |
---|
199 | 189 | int ret = 0; |
---|
200 | 190 | |
---|
.. | .. |
---|
218 | 208 | |
---|
219 | 209 | spin_lock_init(&rtc->lock); |
---|
220 | 210 | |
---|
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); |
---|
223 | 212 | if (IS_ERR(rtc->ioaddr)) |
---|
224 | 213 | return PTR_ERR(rtc->ioaddr); |
---|
225 | 214 | |
---|
.. | .. |
---|
239 | 228 | enable_irq_wake(rtc->irq); |
---|
240 | 229 | disable_irq(rtc->irq); |
---|
241 | 230 | |
---|
242 | | - rtc->clk = clk_get(&pdev->dev, NULL); |
---|
| 231 | + rtc->clk = devm_clk_get(&pdev->dev, NULL); |
---|
243 | 232 | if (IS_ERR(rtc->clk)) { |
---|
244 | 233 | dev_err(&pdev->dev, "Unable to request clock\n"); |
---|
245 | 234 | return PTR_ERR(rtc->clk); |
---|
.. | .. |
---|
249 | 238 | |
---|
250 | 239 | rtc->clkrate = clk_get_rate(rtc->clk); |
---|
251 | 240 | if (!rtc->clkrate) { |
---|
| 241 | + clk_disable_unprepare(rtc->clk); |
---|
252 | 242 | dev_err(&pdev->dev, "Unable to fetch clock rate\n"); |
---|
253 | 243 | return -EINVAL; |
---|
254 | 244 | } |
---|