* [PATCH] alpha: rtc: simplify alpha_rtc_init
@ 2018-09-09 21:15 Alexandre Belloni
0 siblings, 0 replies; only message in thread
From: Alexandre Belloni @ 2018-09-09 21:15 UTC (permalink / raw)
To: Matt Turner
Cc: Ivan Kokshaysky, Richard Henderson, linux-alpha, linux-kernel,
linux-rtc, Alexandre Belloni
Use devm_rtc_allocate_device to simplify choosing the rtc_ops in
alpha_rtc_init().
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
arch/alpha/kernel/rtc.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/arch/alpha/kernel/rtc.c b/arch/alpha/kernel/rtc.c
index 1376a2867048..1b1d5963ac55 100644
--- a/arch/alpha/kernel/rtc.c
+++ b/arch/alpha/kernel/rtc.c
@@ -198,26 +198,24 @@ static const struct rtc_class_ops remote_rtc_ops = {
static int __init
alpha_rtc_init(void)
{
- const struct rtc_class_ops *ops;
struct platform_device *pdev;
struct rtc_device *rtc;
- const char *name;
init_rtc_epoch();
- name = "rtc-alpha";
- ops = &alpha_rtc_ops;
-#ifdef HAVE_REMOTE_RTC
- if (alpha_mv.rtc_boot_cpu_only)
- ops = &remote_rtc_ops;
-#endif
-
- pdev = platform_device_register_simple(name, -1, NULL, 0);
- rtc = devm_rtc_device_register(&pdev->dev, name, ops, THIS_MODULE);
+ pdev = platform_device_register_simple("rtc-alpha", -1, NULL, 0);
+ rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
platform_set_drvdata(pdev, rtc);
- return 0;
+ rtc->ops = &alpha_rtc_ops;
+
+#ifdef HAVE_REMOTE_RTC
+ if (alpha_mv.rtc_boot_cpu_only)
+ rtc->ops = &remote_rtc_ops;
+#endif
+
+ return rtc_register_device(rtc);
}
device_initcall(alpha_rtc_init);
--
2.19.0.rc2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-09-10 2:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-09 21:15 [PATCH] alpha: rtc: simplify alpha_rtc_init Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).