Commit 97fa5bb7 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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>
Tested-by: default avatarMatt Domsch <Matt_Domsch@dell.com>
Cc: Matt Tolentino <matthew.e.tolentino@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent af6370ea
...@@ -143,13 +143,6 @@ struct efivar_attribute efivar_attr_##_name = { \ ...@@ -143,13 +143,6 @@ struct efivar_attribute efivar_attr_##_name = { \
.store = _store, \ .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_attr(_attr) container_of(_attr, struct efivar_attribute, attr)
#define to_efivar_entry(obj) container_of(obj, struct efivar_entry, kobj) #define to_efivar_entry(obj) container_of(obj, struct efivar_entry, kobj)
...@@ -408,12 +401,6 @@ static struct kobj_type efivar_ktype = { ...@@ -408,12 +401,6 @@ static struct kobj_type efivar_ktype = {
.default_attrs = def_attrs, .default_attrs = def_attrs,
}; };
static ssize_t
dummy(struct kset *kset, char *buf)
{
return -ENODEV;
}
static inline void static inline void
efivar_unregister(struct efivar_entry *var) efivar_unregister(struct efivar_entry *var)
{ {
...@@ -421,8 +408,9 @@ efivar_unregister(struct efivar_entry *var) ...@@ -421,8 +408,9 @@ efivar_unregister(struct efivar_entry *var)
} }
static ssize_t static ssize_t efivar_create(struct kobject *kobj,
efivar_create(struct kset *kset, const char *buf, size_t count) struct bin_attribute *bin_attr,
char *buf, loff_t pos, size_t count)
{ {
struct efi_variable *new_var = (struct efi_variable *)buf; struct efi_variable *new_var = (struct efi_variable *)buf;
struct efivar_entry *search_efivar, *n; struct efivar_entry *search_efivar, *n;
...@@ -479,8 +467,9 @@ efivar_create(struct kset *kset, const char *buf, size_t count) ...@@ -479,8 +467,9 @@ efivar_create(struct kset *kset, const char *buf, size_t count)
return count; return count;
} }
static ssize_t static ssize_t efivar_delete(struct kobject *kobj,
efivar_delete(struct kset *kset, const char *buf, size_t count) struct bin_attribute *bin_attr,
char *buf, loff_t pos, size_t count)
{ {
struct efi_variable *del_var = (struct efi_variable *)buf; struct efi_variable *del_var = (struct efi_variable *)buf;
struct efivar_entry *search_efivar, *n; struct efivar_entry *search_efivar, *n;
...@@ -537,13 +526,14 @@ efivar_delete(struct kset *kset, const char *buf, size_t count) ...@@ -537,13 +526,14 @@ efivar_delete(struct kset *kset, const char *buf, size_t count)
return count; return count;
} }
static VAR_SUBSYS_ATTR(new_var, 0200, dummy, efivar_create); static struct bin_attribute var_subsys_attr_new_var = {
static VAR_SUBSYS_ATTR(del_var, 0200, dummy, efivar_delete); .attr = {.name = "new_var", .mode = 0200},
.write = efivar_create,
};
static struct subsys_attribute *var_subsys_attrs[] = { static struct bin_attribute var_subsys_attr_del_var = {
&var_subsys_attr_new_var, .attr = {.name = "del_var", .mode = 0200},
&var_subsys_attr_del_var, .write = efivar_delete,
NULL,
}; };
/* /*
...@@ -728,11 +718,16 @@ efivars_init(void) ...@@ -728,11 +718,16 @@ efivars_init(void)
* Now add attributes to allow creation of new vars * Now add attributes to allow creation of new vars
* and deletion of existing ones... * and deletion of existing ones...
*/ */
error = sysfs_create_bin_file(&vars_subsys.kobj,
for (i = 0; (attr = var_subsys_attrs[i]) && !error; i++) { &var_subsys_attr_new_var);
if (attr->show && attr->store) if (error)
error = subsys_create_file(&vars_subsys, attr); printk(KERN_ERR "efivars: unable to create new_var sysfs file"
} " due to error %d\n", error);
error = sysfs_create_bin_file(&vars_subsys.kobj,
&var_subsys_attr_del_var);
if (error)
printk(KERN_ERR "efivars: unable to create del_var sysfs file"
" due to error %d\n", error);
/* Don't forget the systab entry */ /* Don't forget the systab entry */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment