2 * Originally from efivars.c
4 * Copyright (C) 2001,2003,2004 Dell <Matt_Domsch@dell.com>
5 * Copyright (C) 2004 Intel Corporation <matthew.e.tolentino@intel.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/capability.h>
23 #include <linux/types.h>
24 #include <linux/errno.h>
25 #include <linux/init.h>
27 #include <linux/module.h>
28 #include <linux/string.h>
29 #include <linux/smp.h>
30 #include <linux/efi.h>
31 #include <linux/sysfs.h>
32 #include <linux/device.h>
33 #include <linux/slab.h>
34 #include <linux/ctype.h>
36 /* Private pointer to registered efivars */
37 static struct efivars *__efivars;
39 static bool efivar_wq_enabled = true;
40 DECLARE_WORK(efivar_work, NULL);
41 EXPORT_SYMBOL_GPL(efivar_work);
44 validate_device_path(struct efi_variable *var, int match, u8 *buffer,
47 struct efi_generic_dev_path *node;
50 node = (struct efi_generic_dev_path *)buffer;
52 if (len < sizeof(*node))
55 while (offset <= len - sizeof(*node) &&
56 node->length >= sizeof(*node) &&
57 node->length <= len - offset) {
58 offset += node->length;
60 if ((node->type == EFI_DEV_END_PATH ||
61 node->type == EFI_DEV_END_PATH2) &&
62 node->sub_type == EFI_DEV_END_ENTIRE)
65 node = (struct efi_generic_dev_path *)(buffer + offset);
69 * If we're here then either node->length pointed past the end
70 * of the buffer or we reached the end of the buffer without
71 * finding a device path end node.
77 validate_boot_order(struct efi_variable *var, int match, u8 *buffer,
80 /* An array of 16-bit integers */
88 validate_load_option(struct efi_variable *var, int match, u8 *buffer,
92 int i, desclength = 0, namelen;
94 namelen = utf16_strnlen(var->VariableName, sizeof(var->VariableName));
96 /* Either "Boot" or "Driver" followed by four digits of hex */
97 for (i = match; i < match+4; i++) {
98 if (var->VariableName[i] > 127 ||
99 hex_to_bin(var->VariableName[i] & 0xff) < 0)
103 /* Reject it if there's 4 digits of hex and then further content */
104 if (namelen > match + 4)
107 /* A valid entry must be at least 8 bytes */
111 filepathlength = buffer[4] | buffer[5] << 8;
114 * There's no stored length for the description, so it has to be
117 desclength = utf16_strsize((efi_char16_t *)(buffer + 6), len - 6) + 2;
119 /* Each boot entry must have a descriptor */
124 * If the sum of the length of the description, the claimed filepath
125 * length and the original header are greater than the length of the
126 * variable, it's malformed
128 if ((desclength + filepathlength + 6) > len)
132 * And, finally, check the filepath
134 return validate_device_path(var, match, buffer + desclength + 6,
139 validate_uint16(struct efi_variable *var, int match, u8 *buffer,
142 /* A single 16-bit integer */
150 validate_ascii_string(struct efi_variable *var, int match, u8 *buffer,
155 for (i = 0; i < len; i++) {
166 struct variable_validate {
168 bool (*validate)(struct efi_variable *var, int match, u8 *data,
172 static const struct variable_validate variable_validate[] = {
173 { "BootNext", validate_uint16 },
174 { "BootOrder", validate_boot_order },
175 { "DriverOrder", validate_boot_order },
176 { "Boot*", validate_load_option },
177 { "Driver*", validate_load_option },
178 { "ConIn", validate_device_path },
179 { "ConInDev", validate_device_path },
180 { "ConOut", validate_device_path },
181 { "ConOutDev", validate_device_path },
182 { "ErrOut", validate_device_path },
183 { "ErrOutDev", validate_device_path },
184 { "Timeout", validate_uint16 },
185 { "Lang", validate_ascii_string },
186 { "PlatformLang", validate_ascii_string },
191 efivar_validate(struct efi_variable *var, u8 *data, unsigned long len)
194 u16 *unicode_name = var->VariableName;
196 for (i = 0; variable_validate[i].validate != NULL; i++) {
197 const char *name = variable_validate[i].name;
200 for (match = 0; ; match++) {
201 char c = name[match];
202 u16 u = unicode_name[match];
204 /* All special variables are plain ascii */
208 /* Wildcard in the matching name means we've matched */
210 return variable_validate[i].validate(var,
213 /* Case sensitive match */
217 /* Reached the end of the string while matching */
219 return variable_validate[i].validate(var,
226 EXPORT_SYMBOL_GPL(efivar_validate);
229 check_var_size(u32 attributes, unsigned long size)
231 u64 storage_size, remaining_size, max_size;
233 const struct efivar_operations *fops = __efivars->ops;
235 if (!fops->query_variable_info)
236 return EFI_UNSUPPORTED;
238 status = fops->query_variable_info(attributes, &storage_size,
239 &remaining_size, &max_size);
241 if (status != EFI_SUCCESS)
244 if (!storage_size || size > remaining_size || size > max_size ||
245 (remaining_size - size) < (storage_size / 2))
246 return EFI_OUT_OF_RESOURCES;
251 static int efi_status_to_err(efi_status_t status)
259 case EFI_INVALID_PARAMETER:
262 case EFI_OUT_OF_RESOURCES:
265 case EFI_DEVICE_ERROR:
268 case EFI_WRITE_PROTECTED:
271 case EFI_SECURITY_VIOLATION:
284 static bool variable_is_present(efi_char16_t *variable_name, efi_guid_t *vendor,
285 struct list_head *head)
287 struct efivar_entry *entry, *n;
288 unsigned long strsize1, strsize2;
291 strsize1 = utf16_strsize(variable_name, 1024);
292 list_for_each_entry_safe(entry, n, head, list) {
293 strsize2 = utf16_strsize(entry->var.VariableName, 1024);
294 if (strsize1 == strsize2 &&
295 !memcmp(variable_name, &(entry->var.VariableName),
297 !efi_guidcmp(entry->var.VendorGuid,
307 * Returns the size of variable_name, in bytes, including the
308 * terminating NULL character, or variable_name_size if no NULL
309 * character is found among the first variable_name_size bytes.
311 static unsigned long var_name_strnsize(efi_char16_t *variable_name,
312 unsigned long variable_name_size)
318 * The variable name is, by definition, a NULL-terminated
319 * string, so make absolutely sure that variable_name_size is
320 * the value we expect it to be. If not, return the real size.
322 for (len = 2; len <= variable_name_size; len += sizeof(c)) {
323 c = variable_name[(len / sizeof(c)) - 1];
328 return min(len, variable_name_size);
332 * Print a warning when duplicate EFI variables are encountered and
333 * disable the sysfs workqueue since the firmware is buggy.
335 static void dup_variable_bug(efi_char16_t *s16, efi_guid_t *vendor_guid,
338 size_t i, len8 = len16 / sizeof(efi_char16_t);
342 * Disable the workqueue since the algorithm it uses for
343 * detecting new variables won't work with this buggy
344 * implementation of GetNextVariableName().
346 efivar_wq_enabled = false;
348 s8 = kzalloc(len8, GFP_KERNEL);
352 for (i = 0; i < len8; i++)
355 printk(KERN_WARNING "efivars: duplicate variable: %s-%pUl\n",
361 * efivar_init - build the initial list of EFI variables
362 * @func: callback function to invoke for every variable
363 * @data: function-specific data to pass to @func
364 * @atomic: do we need to execute the @func-loop atomically?
365 * @duplicates: error if we encounter duplicates on @head?
366 * @head: initialised head of variable list
368 * Get every EFI variable from the firmware and invoke @func. @func
369 * should call efivar_entry_add() to build the list of variables.
371 * Returns 0 on success, or a kernel error code on failure.
373 int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
374 void *data, bool atomic, bool duplicates,
375 struct list_head *head)
377 const struct efivar_operations *ops = __efivars->ops;
378 unsigned long variable_name_size = 1024;
379 efi_char16_t *variable_name;
381 efi_guid_t vendor_guid;
384 variable_name = kzalloc(variable_name_size, GFP_KERNEL);
385 if (!variable_name) {
386 printk(KERN_ERR "efivars: Memory allocation failed.\n");
390 spin_lock_irq(&__efivars->lock);
393 * Per EFI spec, the maximum storage allocated for both
394 * the variable name and variable data is 1024 bytes.
398 variable_name_size = 1024;
400 status = ops->get_next_variable(&variable_name_size,
406 spin_unlock_irq(&__efivars->lock);
408 variable_name_size = var_name_strnsize(variable_name,
412 * Some firmware implementations return the
413 * same variable name on multiple calls to
414 * get_next_variable(). Terminate the loop
415 * immediately as there is no guarantee that
416 * we'll ever see a different variable name,
417 * and may end up looping here forever.
420 variable_is_present(variable_name, &vendor_guid, head)) {
421 dup_variable_bug(variable_name, &vendor_guid,
424 spin_lock_irq(&__efivars->lock);
426 status = EFI_NOT_FOUND;
430 err = func(variable_name, vendor_guid, variable_name_size, data);
432 status = EFI_NOT_FOUND;
435 spin_lock_irq(&__efivars->lock);
441 printk(KERN_WARNING "efivars: get_next_variable: status=%lx\n",
443 status = EFI_NOT_FOUND;
447 } while (status != EFI_NOT_FOUND);
449 spin_unlock_irq(&__efivars->lock);
451 kfree(variable_name);
455 EXPORT_SYMBOL_GPL(efivar_init);
458 * efivar_entry_add - add entry to variable list
459 * @entry: entry to add to list
462 void efivar_entry_add(struct efivar_entry *entry, struct list_head *head)
464 spin_lock_irq(&__efivars->lock);
465 list_add(&entry->list, head);
466 spin_unlock_irq(&__efivars->lock);
468 EXPORT_SYMBOL_GPL(efivar_entry_add);
471 * efivar_entry_remove - remove entry from variable list
472 * @entry: entry to remove from list
474 void efivar_entry_remove(struct efivar_entry *entry)
476 spin_lock_irq(&__efivars->lock);
477 list_del(&entry->list);
478 spin_unlock_irq(&__efivars->lock);
480 EXPORT_SYMBOL_GPL(efivar_entry_remove);
483 * efivar_entry_list_del_unlock - remove entry from variable list
484 * @entry: entry to remove
486 * Remove @entry from the variable list and release the list lock.
488 * NOTE: slightly weird locking semantics here - we expect to be
489 * called with the efivars lock already held, and we release it before
490 * returning. This is because this function is usually called after
491 * set_variable() while the lock is still held.
493 static void efivar_entry_list_del_unlock(struct efivar_entry *entry)
495 WARN_ON(!spin_is_locked(&__efivars->lock));
497 list_del(&entry->list);
498 spin_unlock_irq(&__efivars->lock);
502 * __efivar_entry_delete - delete an EFI variable
503 * @entry: entry containing EFI variable to delete
505 * Delete the variable from the firmware but leave @entry on the
508 * This function differs from efivar_entry_delete() because it does
509 * not remove @entry from the variable list. Also, it is safe to be
510 * called from within a efivar_entry_iter_begin() and
511 * efivar_entry_iter_end() region, unlike efivar_entry_delete().
513 * Returns 0 on success, or a converted EFI status code if
514 * set_variable() fails.
516 int __efivar_entry_delete(struct efivar_entry *entry)
518 const struct efivar_operations *ops = __efivars->ops;
521 WARN_ON(!spin_is_locked(&__efivars->lock));
523 status = ops->set_variable(entry->var.VariableName,
524 &entry->var.VendorGuid,
527 return efi_status_to_err(status);
529 EXPORT_SYMBOL_GPL(__efivar_entry_delete);
532 * efivar_entry_delete - delete variable and remove entry from list
533 * @entry: entry containing variable to delete
535 * Delete the variable from the firmware and remove @entry from the
536 * variable list. It is the caller's responsibility to free @entry
539 * Returns 0 on success, or a converted EFI status code if
540 * set_variable() fails.
542 int efivar_entry_delete(struct efivar_entry *entry)
544 const struct efivar_operations *ops = __efivars->ops;
547 spin_lock_irq(&__efivars->lock);
548 status = ops->set_variable(entry->var.VariableName,
549 &entry->var.VendorGuid,
551 if (!(status == EFI_SUCCESS || status == EFI_NOT_FOUND)) {
552 spin_unlock_irq(&__efivars->lock);
553 return efi_status_to_err(status);
556 efivar_entry_list_del_unlock(entry);
559 EXPORT_SYMBOL_GPL(efivar_entry_delete);
562 * efivar_entry_set - call set_variable()
563 * @entry: entry containing the EFI variable to write
564 * @attributes: variable attributes
565 * @size: size of @data buffer
566 * @data: buffer containing variable data
567 * @head: head of variable list
569 * Calls set_variable() for an EFI variable. If creating a new EFI
570 * variable, this function is usually followed by efivar_entry_add().
572 * Before writing the variable, the remaining EFI variable storage
573 * space is checked to ensure there is enough room available.
575 * If @head is not NULL a lookup is performed to determine whether
576 * the entry is already on the list.
578 * Returns 0 on success, -EEXIST if a lookup is performed and the entry
579 * already exists on the list, or a converted EFI status code if
580 * set_variable() fails.
582 int efivar_entry_set(struct efivar_entry *entry, u32 attributes,
583 unsigned long size, void *data, struct list_head *head)
585 const struct efivar_operations *ops = __efivars->ops;
587 efi_char16_t *name = entry->var.VariableName;
588 efi_guid_t vendor = entry->var.VendorGuid;
590 spin_lock_irq(&__efivars->lock);
592 if (head && efivar_entry_find(name, vendor, head, false)) {
593 spin_unlock_irq(&__efivars->lock);
597 status = check_var_size(attributes, size + utf16_strsize(name, 1024));
598 if (status == EFI_SUCCESS || status == EFI_UNSUPPORTED)
599 status = ops->set_variable(name, &vendor,
600 attributes, size, data);
602 spin_unlock_irq(&__efivars->lock);
604 return efi_status_to_err(status);
607 EXPORT_SYMBOL_GPL(efivar_entry_set);
610 * efivar_entry_set_safe - call set_variable() if enough space in firmware
611 * @name: buffer containing the variable name
612 * @vendor: variable vendor guid
613 * @attributes: variable attributes
614 * @block: can we block in this context?
615 * @size: size of @data buffer
616 * @data: buffer containing variable data
618 * Ensures there is enough free storage in the firmware for this variable, and
619 * if so, calls set_variable(). If creating a new EFI variable, this function
620 * is usually followed by efivar_entry_add().
622 * Returns 0 on success, -ENOSPC if the firmware does not have enough
623 * space for set_variable() to succeed, or a converted EFI status code
624 * if set_variable() fails.
626 int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
627 bool block, unsigned long size, void *data)
629 const struct efivar_operations *ops = __efivars->ops;
633 if (!ops->query_variable_info)
636 if (!block && spin_trylock_irqsave(&__efivars->lock, flags))
639 spin_lock_irqsave(&__efivars->lock, flags);
641 status = check_var_size(attributes, size + utf16_strsize(name, 1024));
642 if (status != EFI_SUCCESS) {
643 spin_unlock_irqrestore(&__efivars->lock, flags);
647 status = ops->set_variable(name, &vendor, attributes, size, data);
649 spin_unlock_irqrestore(&__efivars->lock, flags);
651 return efi_status_to_err(status);
653 EXPORT_SYMBOL_GPL(efivar_entry_set_safe);
656 * efivar_entry_find - search for an entry
657 * @name: the EFI variable name
658 * @guid: the EFI variable vendor's guid
659 * @head: head of the variable list
660 * @remove: should we remove the entry from the list?
662 * Search for an entry on the variable list that has the EFI variable
663 * name @name and vendor guid @guid. If an entry is found on the list
664 * and @remove is true, the entry is removed from the list.
666 * The caller MUST call efivar_entry_iter_begin() and
667 * efivar_entry_iter_end() before and after the invocation of this
668 * function, respectively.
670 * Returns the entry if found on the list, %NULL otherwise.
672 struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid,
673 struct list_head *head, bool remove)
675 struct efivar_entry *entry, *n;
676 int strsize1, strsize2;
679 WARN_ON(!spin_is_locked(&__efivars->lock));
681 list_for_each_entry_safe(entry, n, head, list) {
682 strsize1 = utf16_strsize(name, 1024);
683 strsize2 = utf16_strsize(entry->var.VariableName, 1024);
684 if (strsize1 == strsize2 &&
685 !memcmp(name, &(entry->var.VariableName), strsize1) &&
686 !efi_guidcmp(guid, entry->var.VendorGuid)) {
696 list_del(&entry->list);
700 EXPORT_SYMBOL_GPL(efivar_entry_find);
703 * __efivar_entry_size - obtain the size of a variable
704 * @entry: entry for this variable
705 * @size: location to store the variable's size
707 * The caller MUST call efivar_entry_iter_begin() and
708 * efivar_entry_iter_end() before and after the invocation of this
709 * function, respectively.
711 int __efivar_entry_size(struct efivar_entry *entry, unsigned long *size)
713 const struct efivar_operations *ops = __efivars->ops;
716 WARN_ON(!spin_is_locked(&__efivars->lock));
719 status = ops->get_variable(entry->var.VariableName,
720 &entry->var.VendorGuid, NULL, size, NULL);
721 if (status != EFI_BUFFER_TOO_SMALL)
722 return efi_status_to_err(status);
726 EXPORT_SYMBOL_GPL(__efivar_entry_size);
729 * efivar_entry_size - obtain the size of a variable
730 * @entry: entry for this variable
731 * @size: location to store the variable's size
733 int efivar_entry_size(struct efivar_entry *entry, unsigned long *size)
735 const struct efivar_operations *ops = __efivars->ops;
740 spin_lock_irq(&__efivars->lock);
741 status = ops->get_variable(entry->var.VariableName,
742 &entry->var.VendorGuid, NULL, size, NULL);
743 spin_unlock_irq(&__efivars->lock);
745 if (status != EFI_BUFFER_TOO_SMALL)
746 return efi_status_to_err(status);
750 EXPORT_SYMBOL_GPL(efivar_entry_size);
753 * efivar_entry_get - call get_variable()
754 * @entry: read data for this variable
755 * @attributes: variable attributes
756 * @size: size of @data buffer
757 * @data: buffer to store variable data
759 int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
760 unsigned long *size, void *data)
762 const struct efivar_operations *ops = __efivars->ops;
765 spin_lock_irq(&__efivars->lock);
766 status = ops->get_variable(entry->var.VariableName,
767 &entry->var.VendorGuid,
768 attributes, size, data);
769 spin_unlock_irq(&__efivars->lock);
771 return efi_status_to_err(status);
773 EXPORT_SYMBOL_GPL(efivar_entry_get);
776 * efivar_entry_set_get_size - call set_variable() and get new size (atomic)
777 * @entry: entry containing variable to set and get
778 * @attributes: attributes of variable to be written
779 * @size: size of data buffer
780 * @data: buffer containing data to write
781 * @set: did the set_variable() call succeed?
783 * This is a pretty special (complex) function. See efivarfs_file_write().
785 * Atomically call set_variable() for @entry and if the call is
786 * successful, return the new size of the variable from get_variable()
787 * in @size. The success of set_variable() is indicated by @set.
789 * Returns 0 on success, -EINVAL if the variable data is invalid,
790 * -ENOSPC if the firmware does not have enough available space, or a
791 * converted EFI status code if either of set_variable() or
792 * get_variable() fail.
794 * If the EFI variable does not exist when calling set_variable()
795 * (EFI_NOT_FOUND), @entry is removed from the variable list.
797 int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
798 unsigned long *size, void *data, bool *set)
800 const struct efivar_operations *ops = __efivars->ops;
801 efi_char16_t *name = entry->var.VariableName;
802 efi_guid_t *vendor = &entry->var.VendorGuid;
808 if (efivar_validate(&entry->var, data, *size) == false)
812 * The lock here protects the get_variable call, the conditional
813 * set_variable call, and removal of the variable from the efivars
814 * list (in the case of an authenticated delete).
816 spin_lock_irq(&__efivars->lock);
819 * Ensure that the available space hasn't shrunk below the safe level
821 status = check_var_size(attributes, *size + utf16_strsize(name, 1024));
822 if (status != EFI_SUCCESS) {
823 if (status != EFI_UNSUPPORTED) {
824 err = efi_status_to_err(status);
834 status = ops->set_variable(name, vendor, attributes, *size, data);
835 if (status != EFI_SUCCESS) {
836 err = efi_status_to_err(status);
843 * Writing to the variable may have caused a change in size (which
844 * could either be an append or an overwrite), or the variable to be
845 * deleted. Perform a GetVariable() so we can tell what actually
849 status = ops->get_variable(entry->var.VariableName,
850 &entry->var.VendorGuid,
853 if (status == EFI_NOT_FOUND)
854 efivar_entry_list_del_unlock(entry);
856 spin_unlock_irq(&__efivars->lock);
858 if (status && status != EFI_BUFFER_TOO_SMALL)
859 return efi_status_to_err(status);
864 spin_unlock_irq(&__efivars->lock);
868 EXPORT_SYMBOL_GPL(efivar_entry_set_get_size);
871 * efivar_entry_iter_begin - begin iterating the variable list
873 * Lock the variable list to prevent entry insertion and removal until
874 * efivar_entry_iter_end() is called. This function is usually used in
875 * conjunction with __efivar_entry_iter() or efivar_entry_iter().
877 void efivar_entry_iter_begin(void)
879 spin_lock_irq(&__efivars->lock);
881 EXPORT_SYMBOL_GPL(efivar_entry_iter_begin);
884 * efivar_entry_iter_end - finish iterating the variable list
886 * Unlock the variable list and allow modifications to the list again.
888 void efivar_entry_iter_end(void)
890 spin_unlock_irq(&__efivars->lock);
892 EXPORT_SYMBOL_GPL(efivar_entry_iter_end);
895 * __efivar_entry_iter - iterate over variable list
896 * @func: callback function
897 * @head: head of the variable list
898 * @data: function-specific data to pass to callback
899 * @prev: entry to begin iterating from
901 * Iterate over the list of EFI variables and call @func with every
902 * entry on the list. It is safe for @func to remove entries in the
903 * list via efivar_entry_delete().
905 * You MUST call efivar_enter_iter_begin() before this function, and
906 * efivar_entry_iter_end() afterwards.
908 * It is possible to begin iteration from an arbitrary entry within
909 * the list by passing @prev. @prev is updated on return to point to
910 * the last entry passed to @func. To begin iterating from the
911 * beginning of the list @prev must be %NULL.
913 * The restrictions for @func are the same as documented for
914 * efivar_entry_iter().
916 int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
917 struct list_head *head, void *data,
918 struct efivar_entry **prev)
920 struct efivar_entry *entry, *n;
923 if (!prev || !*prev) {
924 list_for_each_entry_safe(entry, n, head, list) {
925 err = func(entry, data);
937 list_for_each_entry_safe_continue((*prev), n, head, list) {
938 err = func(*prev, data);
945 EXPORT_SYMBOL_GPL(__efivar_entry_iter);
948 * efivar_entry_iter - iterate over variable list
949 * @func: callback function
950 * @head: head of variable list
951 * @data: function-specific data to pass to callback
953 * Iterate over the list of EFI variables and call @func with every
954 * entry on the list. It is safe for @func to remove entries in the
955 * list via efivar_entry_delete() while iterating.
957 * Some notes for the callback function:
958 * - a non-zero return value indicates an error and terminates the loop
959 * - @func is called from atomic context
961 int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
962 struct list_head *head, void *data)
966 efivar_entry_iter_begin();
967 err = __efivar_entry_iter(func, head, data, NULL);
968 efivar_entry_iter_end();
972 EXPORT_SYMBOL_GPL(efivar_entry_iter);
975 * efivars_kobject - get the kobject for the registered efivars
977 * If efivars_register() has not been called we return NULL,
978 * otherwise return the kobject used at registration time.
980 struct kobject *efivars_kobject(void)
985 return __efivars->kobject;
987 EXPORT_SYMBOL_GPL(efivars_kobject);
990 * efivar_run_worker - schedule the efivar worker thread
992 void efivar_run_worker(void)
994 if (efivar_wq_enabled)
995 schedule_work(&efivar_work);
997 EXPORT_SYMBOL_GPL(efivar_run_worker);
1000 * efivars_register - register an efivars
1001 * @efivars: efivars to register
1002 * @ops: efivars operations
1003 * @kobject: @efivars-specific kobject
1005 * Only a single efivars can be registered at any time.
1007 int efivars_register(struct efivars *efivars,
1008 const struct efivar_operations *ops,
1009 struct kobject *kobject)
1011 spin_lock_init(&efivars->lock);
1013 efivars->kobject = kobject;
1015 __efivars = efivars;
1019 EXPORT_SYMBOL_GPL(efivars_register);
1022 * efivars_unregister - unregister an efivars
1023 * @efivars: efivars to unregister
1025 * The caller must have already removed every entry from the list,
1026 * failure to do so is an error.
1028 int efivars_unregister(struct efivars *efivars)
1033 printk(KERN_ERR "efivars not registered\n");
1038 if (__efivars != efivars) {
1049 EXPORT_SYMBOL_GPL(efivars_unregister);