aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware/efivars.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firmware/efivars.c')
-rw-r--r--drivers/firmware/efivars.c51
1 files changed, 23 insertions, 28 deletions
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 06ecdb9f6013..82183c28a12a 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -143,13 +143,6 @@ struct efivar_attribute efivar_attr_##_name = { \
143 .store = _store, \ 143 .store = _store, \
144}; 144};
145 145
146#define VAR_SUBSYS_ATTR(_name, _mode, _show, _store) \
147struct subsys_attribute var_subsys_attr_##_name = { \
148 .attr = {.name = __stringify(_name), .mode = _mode}, \
149 .show = _show, \
150 .store = _store, \
151};
152
153#define to_efivar_attr(_attr) container_of(_attr, struct efivar_attribute, attr) 146#define to_efivar_attr(_attr) container_of(_attr, struct efivar_attribute, attr)
154#define to_efivar_entry(obj) container_of(obj, struct efivar_entry, kobj) 147#define to_efivar_entry(obj) container_of(obj, struct efivar_entry, kobj)
155 148
@@ -408,12 +401,6 @@ static struct kobj_type efivar_ktype = {
408 .default_attrs = def_attrs, 401 .default_attrs = def_attrs,
409}; 402};
410 403
411static ssize_t
412dummy(struct kset *kset, char *buf)
413{
414 return -ENODEV;
415}
416
417static inline void 404static inline void
418efivar_unregister(struct efivar_entry *var) 405efivar_unregister(struct efivar_entry *var)
419{ 406{
@@ -421,8 +408,9 @@ efivar_unregister(struct efivar_entry *var)
421} 408}
422 409
423 410
424static ssize_t 411static ssize_t efivar_create(struct kobject *kobj,
425efivar_create(struct kset *kset, const char *buf, size_t count) 412 struct bin_attribute *bin_attr,
413 char *buf, loff_t pos, size_t count)
426{ 414{
427 struct efi_variable *new_var = (struct efi_variable *)buf; 415 struct efi_variable *new_var = (struct efi_variable *)buf;
428 struct efivar_entry *search_efivar, *n; 416 struct efivar_entry *search_efivar, *n;
@@ -479,8 +467,9 @@ efivar_create(struct kset *kset, const char *buf, size_t count)
479 return count; 467 return count;
480} 468}
481 469
482static ssize_t 470static ssize_t efivar_delete(struct kobject *kobj,
483efivar_delete(struct kset *kset, const char *buf, size_t count) 471 struct bin_attribute *bin_attr,
472 char *buf, loff_t pos, size_t count)
484{ 473{
485 struct efi_variable *del_var = (struct efi_variable *)buf; 474 struct efi_variable *del_var = (struct efi_variable *)buf;
486 struct efivar_entry *search_efivar, *n; 475 struct efivar_entry *search_efivar, *n;
@@ -537,13 +526,14 @@ efivar_delete(struct kset *kset, const char *buf, size_t count)
537 return count; 526 return count;
538} 527}
539 528
540static VAR_SUBSYS_ATTR(new_var, 0200, dummy, efivar_create); 529static struct bin_attribute var_subsys_attr_new_var = {
541static VAR_SUBSYS_ATTR(del_var, 0200, dummy, efivar_delete); 530 .attr = {.name = "new_var", .mode = 0200},
531 .write = efivar_create,
532};
542 533
543static struct subsys_attribute *var_subsys_attrs[] = { 534static struct bin_attribute var_subsys_attr_del_var = {
544 &var_subsys_attr_new_var, 535 .attr = {.name = "del_var", .mode = 0200},
545 &var_subsys_attr_del_var, 536 .write = efivar_delete,
546 NULL,
547}; 537};
548 538
549/* 539/*
@@ -728,11 +718,16 @@ efivars_init(void)
728 * Now add attributes to allow creation of new vars 718 * Now add attributes to allow creation of new vars
729 * and deletion of existing ones... 719 * and deletion of existing ones...
730 */ 720 */
731 721 error = sysfs_create_bin_file(&vars_subsys.kobj,
732 for (i = 0; (attr = var_subsys_attrs[i]) && !error; i++) { 722 &var_subsys_attr_new_var);
733 if (attr->show && attr->store) 723 if (error)
734 error = subsys_create_file(&vars_subsys, attr); 724 printk(KERN_ERR "efivars: unable to create new_var sysfs file"
735 } 725 " due to error %d\n", error);
726 error = sysfs_create_bin_file(&vars_subsys.kobj,
727 &var_subsys_attr_del_var);
728 if (error)
729 printk(KERN_ERR "efivars: unable to create del_var sysfs file"
730 " due to error %d\n", error);
736 731
737 /* Don't forget the systab entry */ 732 /* Don't forget the systab entry */
738 733