hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-da9063.c
....@@ -1,15 +1,7 @@
1
-/* rtc-da9063.c - Real time clock device driver for DA9063
1
+// SPDX-License-Identifier: GPL-2.0+
2
+/*
3
+ * Real time clock device driver for DA9063
24 * Copyright (C) 2013-2015 Dialog Semiconductor Ltd.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License
6
- * as published by the Free Software Foundation; either version 2
7
- * of the License, or (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
135 */
146
157 #include <linux/delay.h>
....@@ -247,8 +239,8 @@
247239
248240 da9063_data_to_tm(data, tm, rtc);
249241
250
- rtc_tm_to_time(tm, &tm_secs);
251
- rtc_tm_to_time(&rtc->alarm_time, &al_secs);
242
+ tm_secs = rtc_tm_to_time64(tm);
243
+ al_secs = rtc_tm_to_time64(&rtc->alarm_time);
252244
253245 /* handle the rtc synchronisation delay */
254246 if (rtc->rtc_sync == true && al_secs - tm_secs == 1)
....@@ -472,10 +464,13 @@
472464
473465 platform_set_drvdata(pdev, rtc);
474466
475
- rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, DA9063_DRVNAME_RTC,
476
- &da9063_rtc_ops, THIS_MODULE);
467
+ rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
477468 if (IS_ERR(rtc->rtc_dev))
478469 return PTR_ERR(rtc->rtc_dev);
470
+
471
+ rtc->rtc_dev->ops = &da9063_rtc_ops;
472
+ rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000;
473
+ rtc->rtc_dev->range_max = RTC_TIMESTAMP_END_2063;
479474
480475 da9063_data_to_tm(data, &rtc->alarm_time, rtc);
481476 rtc->rtc_sync = false;
....@@ -488,6 +483,9 @@
488483 rtc->rtc_dev->uie_unsupported = 1;
489484
490485 irq_alarm = platform_get_irq_byname(pdev, "ALARM");
486
+ if (irq_alarm < 0)
487
+ return irq_alarm;
488
+
491489 ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL,
492490 da9063_alarm_event,
493491 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
....@@ -496,7 +494,7 @@
496494 dev_err(&pdev->dev, "Failed to request ALARM IRQ %d: %d\n",
497495 irq_alarm, ret);
498496
499
- return ret;
497
+ return rtc_register_device(rtc->rtc_dev);
500498 }
501499
502500 static struct platform_driver da9063_rtc_driver = {