efi: Register EFI rtc platform device only when available
authorArd Biesheuvel <ardb@kernel.org>
Thu, 23 Jan 2020 08:14:09 +0000 (09:14 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Sun, 23 Feb 2020 20:59:42 +0000 (21:59 +0100)
Drop the separate driver that registers the EFI rtc on all EFI
systems that have runtime services available, and instead, move
the registration into the core EFI code, and make it conditional
on whether the actual time related services are available.

Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/efi.c
drivers/rtc/Makefile
drivers/rtc/rtc-efi-platform.c [deleted file]

index abf4c02..69a5851 100644 (file)
@@ -321,6 +321,9 @@ static int __init efisubsys_init(void)
                }
        }
 
+       if (efi_rt_services_supported(EFI_RT_SUPPORTED_TIME_SERVICES))
+               platform_device_register_simple("rtc-efi", 0, NULL, 0);
+
        /* We register the efi directory at /sys/firmware/efi */
        efi_kobj = kobject_create_and_add("efi", firmware_kobj);
        if (!efi_kobj) {
index 4ac8f19..24c7dfa 100644 (file)
@@ -12,10 +12,6 @@ obj-$(CONFIG_RTC_CLASS)              += rtc-core.o
 obj-$(CONFIG_RTC_MC146818_LIB) += rtc-mc146818-lib.o
 rtc-core-y                     := class.o interface.o
 
-ifdef CONFIG_RTC_DRV_EFI
-rtc-core-y                     += rtc-efi-platform.o
-endif
-
 rtc-core-$(CONFIG_RTC_NVMEM)           += nvmem.o
 rtc-core-$(CONFIG_RTC_INTF_DEV)                += dev.o
 rtc-core-$(CONFIG_RTC_INTF_PROC)       += proc.o
diff --git a/drivers/rtc/rtc-efi-platform.c b/drivers/rtc/rtc-efi-platform.c
deleted file mode 100644 (file)
index 6c037dc..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Moved from arch/ia64/kernel/time.c
- *
- * Copyright (C) 1998-2003 Hewlett-Packard Co
- *     Stephane Eranian <eranian@hpl.hp.com>
- *     David Mosberger <davidm@hpl.hp.com>
- * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
- * Copyright (C) 1999-2000 VA Linux Systems
- * Copyright (C) 1999-2000 Walt Drummond <drummond@valinux.com>
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/efi.h>
-#include <linux/platform_device.h>
-
-static struct platform_device rtc_efi_dev = {
-       .name = "rtc-efi",
-       .id = -1,
-};
-
-static int __init rtc_init(void)
-{
-       if (efi_enabled(EFI_RUNTIME_SERVICES))
-               if (platform_device_register(&rtc_efi_dev) < 0)
-                       pr_err("unable to register rtc device...\n");
-
-       /* not necessarily an error */
-       return 0;
-}
-module_init(rtc_init);