.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
---|
1 | 2 | /* |
---|
2 | 3 | * Real Time Clock driver for Conexant Digicolor |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2015 Paradox Innovation Ltd. |
---|
5 | 6 | * |
---|
6 | 7 | * Author: Baruch Siach <baruch@tkos.co.il> |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify it |
---|
9 | | - * under the terms of the GNU General Public License as published by the |
---|
10 | | - * Free Software Foundation; either version 2 of the License, or (at your |
---|
11 | | - * option) any later version. |
---|
12 | 8 | */ |
---|
13 | 9 | |
---|
14 | 10 | #include <linux/io.h> |
---|
.. | .. |
---|
106 | 102 | return 0; |
---|
107 | 103 | } |
---|
108 | 104 | |
---|
109 | | -static int dc_rtc_set_mmss(struct device *dev, unsigned long secs) |
---|
| 105 | +static int dc_rtc_set_time(struct device *dev, struct rtc_time *tm) |
---|
110 | 106 | { |
---|
111 | 107 | struct dc_rtc *rtc = dev_get_drvdata(dev); |
---|
112 | 108 | |
---|
113 | | - return dc_rtc_write(rtc, secs); |
---|
| 109 | + return dc_rtc_write(rtc, rtc_tm_to_time64(tm)); |
---|
114 | 110 | } |
---|
115 | 111 | |
---|
116 | 112 | static int dc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) |
---|
.. | .. |
---|
161 | 157 | |
---|
162 | 158 | static const struct rtc_class_ops dc_rtc_ops = { |
---|
163 | 159 | .read_time = dc_rtc_read_time, |
---|
164 | | - .set_mmss = dc_rtc_set_mmss, |
---|
| 160 | + .set_time = dc_rtc_set_time, |
---|
165 | 161 | .read_alarm = dc_rtc_read_alarm, |
---|
166 | 162 | .set_alarm = dc_rtc_set_alarm, |
---|
167 | 163 | .alarm_irq_enable = dc_rtc_alarm_irq_enable, |
---|
.. | .. |
---|
179 | 175 | |
---|
180 | 176 | static int __init dc_rtc_probe(struct platform_device *pdev) |
---|
181 | 177 | { |
---|
182 | | - struct resource *res; |
---|
183 | 178 | struct dc_rtc *rtc; |
---|
184 | 179 | int irq, ret; |
---|
185 | 180 | |
---|
.. | .. |
---|
187 | 182 | if (!rtc) |
---|
188 | 183 | return -ENOMEM; |
---|
189 | 184 | |
---|
190 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
191 | | - rtc->regs = devm_ioremap_resource(&pdev->dev, res); |
---|
| 185 | + rtc->regs = devm_platform_ioremap_resource(pdev, 0); |
---|
192 | 186 | if (IS_ERR(rtc->regs)) |
---|
193 | 187 | return PTR_ERR(rtc->regs); |
---|
| 188 | + |
---|
| 189 | + rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev); |
---|
| 190 | + if (IS_ERR(rtc->rtc_dev)) |
---|
| 191 | + return PTR_ERR(rtc->rtc_dev); |
---|
194 | 192 | |
---|
195 | 193 | irq = platform_get_irq(pdev, 0); |
---|
196 | 194 | if (irq < 0) |
---|
.. | .. |
---|
200 | 198 | return ret; |
---|
201 | 199 | |
---|
202 | 200 | platform_set_drvdata(pdev, rtc); |
---|
203 | | - rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, pdev->name, |
---|
204 | | - &dc_rtc_ops, THIS_MODULE); |
---|
205 | | - if (IS_ERR(rtc->rtc_dev)) |
---|
206 | | - return PTR_ERR(rtc->rtc_dev); |
---|
207 | 201 | |
---|
208 | | - return 0; |
---|
| 202 | + rtc->rtc_dev->ops = &dc_rtc_ops; |
---|
| 203 | + rtc->rtc_dev->range_max = U32_MAX; |
---|
| 204 | + |
---|
| 205 | + return rtc_register_device(rtc->rtc_dev); |
---|
209 | 206 | } |
---|
210 | 207 | |
---|
211 | 208 | static const struct of_device_id dc_dt_ids[] = { |
---|