aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firmware/efivars.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index b10b7d7bd7de..ff0c373e3bbf 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -89,28 +89,6 @@ MODULE_DESCRIPTION("sysfs interface to EFI Variables");
89MODULE_LICENSE("GPL"); 89MODULE_LICENSE("GPL");
90MODULE_VERSION(EFIVARS_VERSION); 90MODULE_VERSION(EFIVARS_VERSION);
91 91
92struct efivar_operations {
93 efi_get_variable_t *get_variable;
94 efi_get_next_variable_t *get_next_variable;
95 efi_set_variable_t *set_variable;
96};
97
98struct efivars {
99 /*
100 * ->lock protects two things:
101 * 1) ->list - adds, removals, reads, writes
102 * 2) ops.[gs]et_variable() calls.
103 * It must not be held when creating sysfs entries or calling kmalloc.
104 * ops.get_next_variable() is only called from register_efivars(),
105 * which is protected by the BKL, so that path is safe.
106 */
107 spinlock_t lock;
108 struct list_head list;
109 struct kset *kset;
110 struct bin_attribute *new_var, *del_var;
111 const struct efivar_operations *ops;
112};
113
114/* 92/*
115 * The maximum size of VariableName + Data = 1024 93 * The maximum size of VariableName + Data = 1024
116 * Therefore, it's reasonable to save that much 94 * Therefore, it's reasonable to save that much
@@ -706,7 +684,7 @@ out_free:
706 return error; 684 return error;
707} 685}
708 686
709static void unregister_efivars(struct efivars *efivars) 687void unregister_efivars(struct efivars *efivars)
710{ 688{
711 struct efivar_entry *entry, *n; 689 struct efivar_entry *entry, *n;
712 690
@@ -724,10 +702,11 @@ static void unregister_efivars(struct efivars *efivars)
724 kfree(efivars->del_var); 702 kfree(efivars->del_var);
725 kset_unregister(efivars->kset); 703 kset_unregister(efivars->kset);
726} 704}
705EXPORT_SYMBOL_GPL(unregister_efivars);
727 706
728static int register_efivars(struct efivars *efivars, 707int register_efivars(struct efivars *efivars,
729 const struct efivar_operations *ops, 708 const struct efivar_operations *ops,
730 struct kobject *parent_kobj) 709 struct kobject *parent_kobj)
731{ 710{
732 efi_status_t status = EFI_NOT_FOUND; 711 efi_status_t status = EFI_NOT_FOUND;
733 efi_guid_t vendor_guid; 712 efi_guid_t vendor_guid;
@@ -789,6 +768,7 @@ out:
789 768
790 return error; 769 return error;
791} 770}
771EXPORT_SYMBOL_GPL(register_efivars);
792 772
793static struct efivars __efivars; 773static struct efivars __efivars;
794static struct efivar_operations ops; 774static struct efivar_operations ops;
@@ -810,7 +790,7 @@ efivars_init(void)
810 EFIVARS_DATE); 790 EFIVARS_DATE);
811 791
812 if (!efi_enabled) 792 if (!efi_enabled)
813 return -ENODEV; 793 return 0;
814 794
815 /* For now we'll register the efi directory at /sys/firmware/efi */ 795 /* For now we'll register the efi directory at /sys/firmware/efi */
816 efi_kobj = kobject_create_and_add("efi", firmware_kobj); 796 efi_kobj = kobject_create_and_add("efi", firmware_kobj);