forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 ea08eeccae9297f7aabd2ef7f0c2517ac4549acc
kernel/drivers/firmware/efi/efibc.c
....@@ -1,15 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * efibc: control EFI bootloaders which obey LoaderEntryOneShot var
34 * Copyright (c) 2013-2016, Intel Corporation.
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms and conditions of the GNU General Public License,
7
- * version 2, as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
135 */
146
157 #define pr_fmt(fmt) "efibc: " fmt
....@@ -51,11 +43,13 @@
5143 efibc_str_to_str16(value, (efi_char16_t *)entry->var.Data);
5244 memcpy(&entry->var.VendorGuid, &guid, sizeof(guid));
5345
54
- ret = efivar_entry_set(entry,
55
- EFI_VARIABLE_NON_VOLATILE
56
- | EFI_VARIABLE_BOOTSERVICE_ACCESS
57
- | EFI_VARIABLE_RUNTIME_ACCESS,
58
- size, entry->var.Data, NULL);
46
+ ret = efivar_entry_set_safe(entry->var.VariableName,
47
+ entry->var.VendorGuid,
48
+ EFI_VARIABLE_NON_VOLATILE
49
+ | EFI_VARIABLE_BOOTSERVICE_ACCESS
50
+ | EFI_VARIABLE_RUNTIME_ACCESS,
51
+ false, size, entry->var.Data);
52
+
5953 if (ret)
6054 pr_err("failed to set %s EFI variable: 0x%x\n",
6155 name, ret);
....@@ -90,7 +84,7 @@
9084 {
9185 int ret;
9286
93
- if (!efi_enabled(EFI_RUNTIME_SERVICES))
87
+ if (!efivars_kobject() || !efivar_supports_writes())
9488 return -ENODEV;
9589
9690 ret = register_reboot_notifier(&efibc_reboot_notifier);