gsmi: Remove autoselected dependency on EFI and EFI_VARS
authorDuncan Laurie <dlaurie@chromium.org>
Wed, 27 Jun 2012 22:00:25 +0000 (15:00 -0700)
committerGerrit <chrome-bot@google.com>
Fri, 29 Jun 2012 00:06:48 +0000 (17:06 -0700)
Instead of selecting EFI and EFI_VARS automatically when GSMI is
enabled let that portion of the driver be conditionally compiled
if EFI and EFI_VARS are enabled.

This allows the rest of the driver (specifically event log) to
be used if EFI_VARS is not enabled.

BUG=chromium-os:32188
TEST=manual: compile and run kernel on multiple devices

1) verify that EFI_VARS is not automatically selected when
CONFIG_GOOGLE_GSMI is enabled
2) verify that the kernel boots on Link and that GSMI event log
is still available and functional
3) specifically boot the kernel on Alex to ensure it does not
try to load efivars and that gsmi also does not load because it
is not in the supported DMI table

Change-Id: I6f9149b575976316dd1d4d8ac20f2688d2208767
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26273
Reviewed-by: Olof Johansson <olofj@chromium.org>
drivers/firmware/google/Kconfig
drivers/firmware/google/gsmi.c

index 2f21b0b..5e5931d 100644 (file)
@@ -13,12 +13,11 @@ menu "Google Firmware Drivers"
 config GOOGLE_SMI
        tristate "SMI interface for Google platforms"
        depends on ACPI && DMI
-       select EFI
-       select EFI_VARS
        help
          Say Y here if you want to enable SMI callbacks for Google
          platforms.  This provides an interface for writing to and
-         clearing the EFI event log and reading and writing NVRAM
+         clearing the event log.  If EFI_VARS is also enabled this
+         driver provides an interface for reading and writing NVRAM
          variables.
 
 config GOOGLE_MEMCONSOLE
index 02b9b5a..c8cb48d 100644 (file)
@@ -288,6 +288,8 @@ static int gsmi_exec(u8 func, u8 sub)
        return rc;
 }
 
+#ifdef CONFIG_EFI_VARS
+
 /* Return the number of unicode characters in data */
 static size_t
 utf16_strlen(efi_char16_t *data, unsigned long maxlength)
@@ -476,6 +478,8 @@ static const struct efivar_operations efivar_ops = {
        .get_next_variable = gsmi_get_next_variable,
 };
 
+#endif /* CONFIG_EFI_VARS */
+
 static ssize_t eventlog_write(struct file *filp, struct kobject *kobj,
                               struct bin_attribute *bin_attr,
                               char *buf, loff_t pos, size_t count)
@@ -898,11 +902,14 @@ static __init int gsmi_init(void)
                goto out_remove_bin_file;
        }
 
+#ifdef CONFIG_EFI_VARS
        ret = register_efivars(&efivars, &efivar_ops, gsmi_kobj);
        if (ret) {
                printk(KERN_INFO "gsmi: Failed to register efivars\n");
-               goto out_remove_sysfs_files;
+               sysfs_remove_files(gsmi_kobj, gsmi_attrs);
+               goto out_remove_bin_file;
        }
+#endif
 
        register_reboot_notifier(&gsmi_reboot_notifier);
        register_die_notifier(&gsmi_die_notifier);
@@ -913,8 +920,6 @@ static __init int gsmi_init(void)
 
        return 0;
 
-out_remove_sysfs_files:
-       sysfs_remove_files(gsmi_kobj, gsmi_attrs);
 out_remove_bin_file:
        sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr);
 out_err:
@@ -935,7 +940,9 @@ static void __exit gsmi_exit(void)
        unregister_die_notifier(&gsmi_die_notifier);
        atomic_notifier_chain_unregister(&panic_notifier_list,
                                         &gsmi_panic_notifier);
+#ifdef CONFIG_EFI_VARS
        unregister_efivars(&efivars);
+#endif
 
        sysfs_remove_files(gsmi_kobj, gsmi_attrs);
        sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr);