diff options
| author | Greg KH <gregkh@t43.kroah.org> | 2007-11-07 14:40:48 -0800 |
|---|---|---|
| committer | Greg KH <gregkh@t43.kroah.org> | 2007-11-07 14:40:48 -0800 |
| commit | ac51fd85e03946e605f5ac171e6b7a46bbec393a (patch) | |
| tree | 98aabb96b6f7bd38279cbc7941b519a444790e5a /driver | |
| parent | 080c492f862bece2f9598805ac536b2b84df89ca (diff) | |
| download | patches-ac51fd85e03946e605f5ac171e6b7a46bbec393a.tar.gz | |
make the efivars files binary sysfs files and don't just delete them from the tree.
Diffstat (limited to 'driver')
6 files changed, 136 insertions, 219 deletions
diff --git a/driver/efivars-make-new_var-and-del_var-binary-sysfs-files.patch b/driver/efivars-make-new_var-and-del_var-binary-sysfs-files.patch new file mode 100644 index 00000000000000..d7fa904b26c985 --- /dev/null +++ b/driver/efivars-make-new_var-and-del_var-binary-sysfs-files.patch @@ -0,0 +1,106 @@ +From foo@baz Tue Apr 9 12:12:43 2002 +Date: Wed, 7 Nov 2007 13:56:19 -0800 +To: Greg KH <greg@kroah.com> +From: Greg Kroah-Hartman <gregkh@suse.de> +Subject: efivars: make new_var and del_var binary sysfs files + +These files should not be "normal" sysfs files as they really are binary +ones. This patch makes them binary files and saves code in doing so. + +Cc: Kay Sievers <kay.sievers@vrfy.org> +Cc: Matt Domsch <Matt_Domsch@dell.com> +Cc: Matt Tolentino <matthew.e.tolentino@intel.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + drivers/firmware/efivars.c | 43 +++++++++++++++---------------------------- + 1 file changed, 15 insertions(+), 28 deletions(-) + +--- a/drivers/firmware/efivars.c ++++ b/drivers/firmware/efivars.c +@@ -143,13 +143,6 @@ struct efivar_attribute efivar_attr_##_n + .store = _store, \ + }; + +-#define VAR_SUBSYS_ATTR(_name, _mode, _show, _store) \ +-struct subsys_attribute var_subsys_attr_##_name = { \ +- .attr = {.name = __stringify(_name), .mode = _mode}, \ +- .show = _show, \ +- .store = _store, \ +-}; +- + #define to_efivar_attr(_attr) container_of(_attr, struct efivar_attribute, attr) + #define to_efivar_entry(obj) container_of(obj, struct efivar_entry, kobj) + +@@ -408,12 +401,6 @@ static struct kobj_type efivar_ktype = { + .default_attrs = def_attrs, + }; + +-static ssize_t +-dummy(struct kset *kset, char *buf) +-{ +- return -ENODEV; +-} +- + static inline void + efivar_unregister(struct efivar_entry *var) + { +@@ -421,8 +408,9 @@ efivar_unregister(struct efivar_entry *v + } + + +-static ssize_t +-efivar_create(struct kset *kset, const char *buf, size_t count) ++static ssize_t efivar_create(struct kobject *kobj, ++ struct bin_attribute *bin_attr, ++ char *buf, loff_t pos, size_t count) + { + struct efi_variable *new_var = (struct efi_variable *)buf; + struct efivar_entry *search_efivar, *n; +@@ -479,8 +467,9 @@ efivar_create(struct kset *kset, const c + return count; + } + +-static ssize_t +-efivar_delete(struct kset *kset, const char *buf, size_t count) ++static ssize_t efivar_delete(struct kobject *kobj, ++ struct bin_attribute *bin_attr, ++ char *buf, loff_t pos, size_t count) + { + struct efi_variable *del_var = (struct efi_variable *)buf; + struct efivar_entry *search_efivar, *n; +@@ -537,13 +526,14 @@ efivar_delete(struct kset *kset, const c + return count; + } + +-static VAR_SUBSYS_ATTR(new_var, 0200, dummy, efivar_create); +-static VAR_SUBSYS_ATTR(del_var, 0200, dummy, efivar_delete); ++static struct bin_attribute var_subsys_attr_new_var = { ++ .attr = {.name = "new_var", .mode = 0200}, ++ .write = efivar_create, ++}; + +-static struct subsys_attribute *var_subsys_attrs[] = { +- &var_subsys_attr_new_var, +- &var_subsys_attr_del_var, +- NULL, ++static struct bin_attribute var_subsys_attr_del_var = { ++ .attr = {.name = "del_var", .mode = 0200}, ++ .write = efivar_delete, + }; + + /* +@@ -728,11 +718,8 @@ efivars_init(void) + * Now add attributes to allow creation of new vars + * and deletion of existing ones... + */ +- +- for (i = 0; (attr = var_subsys_attrs[i]) && !error; i++) { +- if (attr->show && attr->store) +- error = subsys_create_file(&vars_subsys, attr); +- } ++ sysfs_create_bin_file(&vars_subsys.kobj, &var_subsys_attr_new_var); ++ sysfs_create_bin_file(&vars_subsys.kobj, &var_subsys_attr_del_var); + + /* Don't forget the systab entry */ + diff --git a/driver/efivars-remove-new_var-and-del_var-files-from-sysfs.patch b/driver/efivars-remove-new_var-and-del_var-files-from-sysfs.patch deleted file mode 100644 index f0cb5ca3d165fb..00000000000000 --- a/driver/efivars-remove-new_var-and-del_var-files-from-sysfs.patch +++ /dev/null @@ -1,200 +0,0 @@ -From foo@baz Tue Apr 9 12:12:43 2002 -Date: Fri, 2 Nov 2007 13:20:40 -0700 -To: Greg KH <greg@kroah.com> -From: Greg Kroah-Hartman <gregkh@suse.de> -Subject: efivars: remove new_var and del_var files from sysfs - -WTF? Passing binary structures into a sysfs file, expecting it to be in -the correct format/endianness? That's just wrong on so many levels. - -So, these files are deleted. If you want to add them back, please do so -in configfs, or in debugfs. Or use text strings, which is what sysfs is -only for. - -Cc: Kay Sievers <kay.sievers@vrfy.org> -Cc: Matt Domsch <Matt_Domsch@dell.com> -Cc: Matt Tolentino <matthew.e.tolentino@intel.com> -Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> - ---- - drivers/firmware/efivars.c | 149 --------------------------------------------- - 1 file changed, 149 deletions(-) - ---- a/drivers/firmware/efivars.c -+++ b/drivers/firmware/efivars.c -@@ -143,13 +143,6 @@ struct efivar_attribute efivar_attr_##_n - .store = _store, \ - }; - --#define VAR_SUBSYS_ATTR(_name, _mode, _show, _store) \ --struct subsys_attribute var_subsys_attr_##_name = { \ -- .attr = {.name = __stringify(_name), .mode = _mode}, \ -- .show = _show, \ -- .store = _store, \ --}; -- - #define to_efivar_attr(_attr) container_of(_attr, struct efivar_attribute, attr) - #define to_efivar_entry(obj) container_of(obj, struct efivar_entry, kobj) - -@@ -408,144 +401,12 @@ static struct kobj_type efivar_ktype = { - .default_attrs = def_attrs, - }; - --static ssize_t --dummy(struct kset *kset, char *buf) --{ -- return -ENODEV; --} -- - static inline void - efivar_unregister(struct efivar_entry *var) - { - kobject_unregister(&var->kobj); - } - -- --static ssize_t --efivar_create(struct kset *kset, const char *buf, size_t count) --{ -- struct efi_variable *new_var = (struct efi_variable *)buf; -- struct efivar_entry *search_efivar, *n; -- unsigned long strsize1, strsize2; -- efi_status_t status = EFI_NOT_FOUND; -- int found = 0; -- -- if (!capable(CAP_SYS_ADMIN)) -- return -EACCES; -- -- spin_lock(&efivars_lock); -- -- /* -- * Does this variable already exist? -- */ -- list_for_each_entry_safe(search_efivar, n, &efivar_list, list) { -- strsize1 = utf8_strsize(search_efivar->var.VariableName, 1024); -- strsize2 = utf8_strsize(new_var->VariableName, 1024); -- if (strsize1 == strsize2 && -- !memcmp(&(search_efivar->var.VariableName), -- new_var->VariableName, strsize1) && -- !efi_guidcmp(search_efivar->var.VendorGuid, -- new_var->VendorGuid)) { -- found = 1; -- break; -- } -- } -- if (found) { -- spin_unlock(&efivars_lock); -- return -EINVAL; -- } -- -- /* now *really* create the variable via EFI */ -- status = efi.set_variable(new_var->VariableName, -- &new_var->VendorGuid, -- new_var->Attributes, -- new_var->DataSize, -- new_var->Data); -- -- if (status != EFI_SUCCESS) { -- printk(KERN_WARNING "efivars: set_variable() failed: status=%lx\n", -- status); -- spin_unlock(&efivars_lock); -- return -EIO; -- } -- spin_unlock(&efivars_lock); -- -- /* Create the entry in sysfs. Locking is not required here */ -- status = efivar_create_sysfs_entry(utf8_strsize(new_var->VariableName, -- 1024), new_var->VariableName, &new_var->VendorGuid); -- if (status) { -- printk(KERN_WARNING "efivars: variable created, but sysfs entry wasn't.\n"); -- } -- return count; --} -- --static ssize_t --efivar_delete(struct kset *kset, const char *buf, size_t count) --{ -- struct efi_variable *del_var = (struct efi_variable *)buf; -- struct efivar_entry *search_efivar, *n; -- unsigned long strsize1, strsize2; -- efi_status_t status = EFI_NOT_FOUND; -- int found = 0; -- -- if (!capable(CAP_SYS_ADMIN)) -- return -EACCES; -- -- spin_lock(&efivars_lock); -- -- /* -- * Does this variable already exist? -- */ -- list_for_each_entry_safe(search_efivar, n, &efivar_list, list) { -- strsize1 = utf8_strsize(search_efivar->var.VariableName, 1024); -- strsize2 = utf8_strsize(del_var->VariableName, 1024); -- if (strsize1 == strsize2 && -- !memcmp(&(search_efivar->var.VariableName), -- del_var->VariableName, strsize1) && -- !efi_guidcmp(search_efivar->var.VendorGuid, -- del_var->VendorGuid)) { -- found = 1; -- break; -- } -- } -- if (!found) { -- spin_unlock(&efivars_lock); -- return -EINVAL; -- } -- /* force the Attributes/DataSize to 0 to ensure deletion */ -- del_var->Attributes = 0; -- del_var->DataSize = 0; -- -- status = efi.set_variable(del_var->VariableName, -- &del_var->VendorGuid, -- del_var->Attributes, -- del_var->DataSize, -- del_var->Data); -- -- if (status != EFI_SUCCESS) { -- printk(KERN_WARNING "efivars: set_variable() failed: status=%lx\n", -- status); -- spin_unlock(&efivars_lock); -- return -EIO; -- } -- list_del(&search_efivar->list); -- /* We need to release this lock before unregistering. */ -- spin_unlock(&efivars_lock); -- efivar_unregister(search_efivar); -- -- /* It's dead Jim.... */ -- return count; --} -- --static VAR_SUBSYS_ATTR(new_var, 0200, dummy, efivar_create); --static VAR_SUBSYS_ATTR(del_var, 0200, dummy, efivar_delete); -- --static struct subsys_attribute *var_subsys_attrs[] = { -- &var_subsys_attr_new_var, -- &var_subsys_attr_del_var, -- NULL, --}; -- - /* - * Let's not leave out systab information that snuck into - * the efivars driver -@@ -724,16 +585,6 @@ efivars_init(void) - } - } while (status != EFI_NOT_FOUND); - -- /* -- * Now add attributes to allow creation of new vars -- * and deletion of existing ones... -- */ -- -- for (i = 0; (attr = var_subsys_attrs[i]) && !error; i++) { -- if (attr->show && attr->store) -- error = subsys_create_file(&vars_subsys, attr); -- } -- - /* Don't forget the systab entry */ - - for (i = 0; (attr = efi_subsys_attrs[i]) && !error; i++) { diff --git a/driver/firmware-change-firmware_kset-to-firmware_kobj.patch b/driver/firmware-change-firmware_kset-to-firmware_kobj.patch index 28e65e28cbb75a..976cdf90802253 100644 --- a/driver/firmware-change-firmware_kset-to-firmware_kobj.patch +++ b/driver/firmware-change-firmware_kset-to-firmware_kobj.patch @@ -109,7 +109,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c -@@ -539,7 +539,7 @@ efivars_init(void) +@@ -668,7 +668,7 @@ efivars_init(void) /* * For now we'll register the efi subsys within this driver */ diff --git a/driver/kobject-convert-efivars-to-kobj_attr-interface.patch b/driver/kobject-convert-efivars-to-kobj_attr-interface.patch index bfbdb9af3c8fb9..df40283c2644bb 100644 --- a/driver/kobject-convert-efivars-to-kobj_attr-interface.patch +++ b/driver/kobject-convert-efivars-to-kobj_attr-interface.patch @@ -32,7 +32,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> #define EFIVAR_ATTR(_name, _mode, _show, _store) \ struct efivar_attribute efivar_attr_##_name = { \ .attr = {.name = __stringify(_name), .mode = _mode}, \ -@@ -411,12 +404,12 @@ efivar_unregister(struct efivar_entry *v +@@ -540,12 +533,12 @@ static struct bin_attribute var_subsys_a * Let's not leave out systab information that snuck into * the efivars driver */ @@ -48,7 +48,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> return -EINVAL; if (efi.mps != EFI_INVALID_TABLE_ADDR) -@@ -437,13 +430,19 @@ systab_read(struct kset *kset, char *buf +@@ -566,13 +559,19 @@ systab_read(struct kset *kset, char *buf return str - buf; } @@ -71,7 +71,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> static decl_subsys(vars, NULL); static decl_subsys(efi, NULL); -@@ -522,9 +521,8 @@ efivars_init(void) +@@ -651,9 +650,8 @@ efivars_init(void) efi_status_t status = EFI_NOT_FOUND; efi_guid_t vendor_guid; efi_char16_t *variable_name; @@ -82,8 +82,8 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> if (!efi_enabled) return -ENODEV; -@@ -586,12 +584,7 @@ efivars_init(void) - } while (status != EFI_NOT_FOUND); +@@ -722,12 +720,7 @@ efivars_init(void) + sysfs_create_bin_file(&vars_subsys.kobj, &var_subsys_attr_del_var); /* Don't forget the systab entry */ - diff --git a/driver/kset-convert-efivars-to-use-kset_create-for-the-efi-subsystem.patch b/driver/kset-convert-efivars-to-use-kset_create-for-the-efi-subsystem.patch index 39297c79d64ae3..d6853d8c4a6e11 100644 --- a/driver/kset-convert-efivars-to-use-kset_create-for-the-efi-subsystem.patch +++ b/driver/kset-convert-efivars-to-use-kset_create-for-the-efi-subsystem.patch @@ -17,7 +17,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c -@@ -444,7 +444,7 @@ static struct attribute_group efi_subsys +@@ -573,7 +573,7 @@ static struct attribute_group efi_subsys static decl_subsys(vars, NULL); @@ -26,7 +26,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> /* * efivar_create_sysfs_entry() -@@ -539,15 +539,14 @@ efivars_init(void) +@@ -668,15 +668,14 @@ efivars_init(void) /* * For now we'll register the efi subsys within this driver */ @@ -47,8 +47,8 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> error = subsystem_register(&vars_subsys); -@@ -584,7 +583,7 @@ efivars_init(void) - } while (status != EFI_NOT_FOUND); +@@ -720,7 +719,7 @@ efivars_init(void) + sysfs_create_bin_file(&vars_subsys.kobj, &var_subsys_attr_del_var); /* Don't forget the systab entry */ - error = sysfs_create_group(&efi_subsys.kobj, &efi_subsys_attr_group); @@ -56,7 +56,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> if (error) printk(KERN_ERR "efivars: Sysfs attribute export failed with error %d.\n", error); else -@@ -593,7 +592,7 @@ efivars_init(void) +@@ -729,7 +728,7 @@ efivars_init(void) subsystem_unregister(&vars_subsys); out_firmware_unregister: @@ -65,7 +65,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> out_free: kfree(variable_name); -@@ -614,7 +613,7 @@ efivars_exit(void) +@@ -750,7 +749,7 @@ efivars_exit(void) } subsystem_unregister(&vars_subsys); diff --git a/driver/kset-convert-efivars-to-use-kset_create-for-the-vars-sub-subsystem.patch b/driver/kset-convert-efivars-to-use-kset_create-for-the-vars-sub-subsystem.patch index 471eaae7e1bf3a..71a1a002c553c2 100644 --- a/driver/kset-convert-efivars-to-use-kset_create-for-the-vars-sub-subsystem.patch +++ b/driver/kset-convert-efivars-to-use-kset_create-for-the-vars-sub-subsystem.patch @@ -12,12 +12,12 @@ Cc: Matt Tolentino <matthew.e.tolentino@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> --- - drivers/firmware/efivars.c | 18 ++++++++---------- - 1 file changed, 8 insertions(+), 10 deletions(-) + drivers/firmware/efivars.c | 22 ++++++++++------------ + 1 file changed, 10 insertions(+), 12 deletions(-) --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c -@@ -443,7 +443,7 @@ static struct attribute_group efi_subsys +@@ -572,7 +572,7 @@ static struct attribute_group efi_subsys }; @@ -26,7 +26,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> static struct kset *efi_kset; /* -@@ -489,7 +489,7 @@ efivar_create_sysfs_entry(unsigned long +@@ -618,7 +618,7 @@ efivar_create_sysfs_entry(unsigned long efi_guid_unparse(vendor_guid, short_name + strlen(short_name)); kobject_set_name(&new_efivar->kobj, "%s", short_name); @@ -35,7 +35,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> new_efivar->kobj.ktype = &efivar_ktype; i = kobject_register(&new_efivar->kobj); if (i) { -@@ -546,12 +546,10 @@ efivars_init(void) +@@ -675,12 +675,10 @@ efivars_init(void) goto out_free; } @@ -52,7 +52,18 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> goto out_firmware_unregister; } -@@ -589,7 +587,7 @@ efivars_init(void) +@@ -715,8 +713,8 @@ efivars_init(void) + * Now add attributes to allow creation of new vars + * and deletion of existing ones... + */ +- sysfs_create_bin_file(&vars_subsys.kobj, &var_subsys_attr_new_var); +- sysfs_create_bin_file(&vars_subsys.kobj, &var_subsys_attr_del_var); ++ sysfs_create_bin_file(&vars_kset->kobj, &var_subsys_attr_new_var); ++ sysfs_create_bin_file(&vars_kset->kobj, &var_subsys_attr_del_var); + + /* Don't forget the systab entry */ + error = sysfs_create_group(&efi_kset->kobj, &efi_subsys_attr_group); +@@ -725,7 +723,7 @@ efivars_init(void) else goto out_free; @@ -61,7 +72,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> out_firmware_unregister: kset_unregister(efi_kset); -@@ -612,7 +610,7 @@ efivars_exit(void) +@@ -748,7 +746,7 @@ efivars_exit(void) efivar_unregister(entry); } |
