summaryrefslogtreecommitdiffstats
path: root/drivers/firmware/efivars.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 08:34:42 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 08:35:13 -0800
commitdf8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e (patch)
treebc3799a43e8b94fa84b32e37b1c124d5e4868f50 /drivers/firmware/efivars.c
parent556a169dab38b5100df6f4a45b655dddd3db94c1 (diff)
parent4a3ad20ccd8f4d2a0535cf98fa83f7b561ba59a9 (diff)
downloadop-kernel-dev-df8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e.zip
op-kernel-dev-df8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e.tar.gz
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
This can be broken down into these major areas: - Documentation updates (language translations and fixes, as well as kobject and kset documenatation updates.) - major kset/kobject/ktype rework and fixes. This cleans up the kset and kobject and ktype relationship and architecture, making sense of things now, and good documenation and samples are provided for others to use. Also the attributes for kobjects are much easier to handle now. This cleaned up a LOT of code all through the kernel, making kobjects easier to use if you want to. - struct bus_type has been reworked to now handle the lifetime rules properly, as the kobject is properly dynamic. - struct driver has also been reworked, and now the lifetime issues are resolved. - the block subsystem has been converted to use struct device now, and not "raw" kobjects. This patch has been in the -mm tree for over a year now, and finally all the issues are worked out with it. Older distros now properly work with new kernels, and no userspace updates are needed at all. - nozomi driver is added. This has also been in -mm for a long time, and many people have asked for it to go in. It is now in good enough shape to do so. - lots of class_device conversions to use struct device instead. The tree is almost all cleaned up now, only SCSI and IB is the remaining code to fix up... * git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: (196 commits) Driver core: coding style fixes Kobject: fix coding style issues in kobject c files Kobject: fix coding style issues in kobject.h Driver core: fix coding style issues in device.h spi: use class iteration api scsi: use class iteration api rtc: use class iteration api power supply : use class iteration api ieee1394: use class iteration api Driver Core: add class iteration api Driver core: Cleanup get_device_parent() in device_add() and device_move() UIO: constify function pointer tables Driver Core: constify the name passed to platform_device_register_simple driver core: fix build with SYSFS=n sysfs: make SYSFS_DEPRECATED depend on SYSFS Driver core: use LIST_HEAD instead of call to INIT_LIST_HEAD in __init kobject: add sample code for how to use ksets/ktypes/kobjects kobject: add sample code for how to use kobjects in a simple manner. kobject: update the kobject/kset documentation kobject: remove old, outdated documentation. ...
Diffstat (limited to 'drivers/firmware/efivars.c')
-rw-r--r--drivers/firmware/efivars.c130
1 files changed, 57 insertions, 73 deletions
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 858a7b9..f4f709d 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -129,13 +129,6 @@ struct efivar_attribute {
};
-#define EFI_ATTR(_name, _mode, _show, _store) \
-struct subsys_attribute efi_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode}, \
- .show = _show, \
- .store = _store, \
-};
-
#define EFIVAR_ATTR(_name, _mode, _show, _store) \
struct efivar_attribute efivar_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode}, \
@@ -143,13 +136,6 @@ struct efivar_attribute efivar_attr_##_name = { \
.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,21 +394,16 @@ 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);
+ kobject_put(&var->kobj);
}
-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 +460,9 @@ efivar_create(struct kset *kset, const char *buf, size_t count)
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,25 +519,26 @@ efivar_delete(struct kset *kset, const char *buf, size_t count)
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,
};
/*
* Let's not leave out systab information that snuck into
* the efivars driver
*/
-static ssize_t
-systab_read(struct kset *kset, char *buf)
+static ssize_t systab_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
{
char *str = buf;
- if (!kset || !buf)
+ if (!kobj || !buf)
return -EINVAL;
if (efi.mps != EFI_INVALID_TABLE_ADDR)
@@ -576,15 +559,21 @@ systab_read(struct kset *kset, char *buf)
return str - buf;
}
-static EFI_ATTR(systab, 0400, systab_read, NULL);
+static struct kobj_attribute efi_attr_systab =
+ __ATTR(systab, 0400, systab_show, NULL);
-static struct subsys_attribute *efi_subsys_attrs[] = {
- &efi_attr_systab,
+static struct attribute *efi_subsys_attrs[] = {
+ &efi_attr_systab.attr,
NULL, /* maybe more in the future? */
};
-static decl_subsys(vars, &efivar_ktype, NULL);
-static decl_subsys(efi, NULL, NULL);
+static struct attribute_group efi_subsys_attr_group = {
+ .attrs = efi_subsys_attrs,
+};
+
+
+static struct kset *vars_kset;
+static struct kobject *efi_kobj;
/*
* efivar_create_sysfs_entry()
@@ -628,15 +617,16 @@ efivar_create_sysfs_entry(unsigned long variable_name_size,
*(short_name + strlen(short_name)) = '-';
efi_guid_unparse(vendor_guid, short_name + strlen(short_name));
- kobject_set_name(&new_efivar->kobj, "%s", short_name);
- kobj_set_kset_s(new_efivar, vars_subsys);
- i = kobject_register(&new_efivar->kobj);
+ new_efivar->kobj.kset = vars_kset;
+ i = kobject_init_and_add(&new_efivar->kobj, &efivar_ktype, NULL,
+ "%s", short_name);
if (i) {
kfree(short_name);
kfree(new_efivar);
return 1;
}
+ kobject_uevent(&new_efivar->kobj, KOBJ_ADD);
kfree(short_name);
short_name = NULL;
@@ -660,9 +650,8 @@ efivars_init(void)
efi_status_t status = EFI_NOT_FOUND;
efi_guid_t vendor_guid;
efi_char16_t *variable_name;
- struct subsys_attribute *attr;
unsigned long variable_name_size = 1024;
- int i, error = 0;
+ int error = 0;
if (!efi_enabled)
return -ENODEV;
@@ -676,23 +665,18 @@ efivars_init(void)
printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION,
EFIVARS_DATE);
- /*
- * For now we'll register the efi subsys within this driver
- */
-
- error = firmware_register(&efi_subsys);
-
- if (error) {
- printk(KERN_ERR "efivars: Firmware registration failed with error %d.\n", error);
+ /* For now we'll register the efi directory at /sys/firmware/efi */
+ efi_kobj = kobject_create_and_add("efi", firmware_kobj);
+ if (!efi_kobj) {
+ printk(KERN_ERR "efivars: Firmware registration failed.\n");
+ error = -ENOMEM;
goto out_free;
}
- kobj_set_kset_s(&vars_subsys, efi_subsys);
-
- error = subsystem_register(&vars_subsys);
-
- if (error) {
- printk(KERN_ERR "efivars: Subsystem registration failed with error %d.\n", error);
+ vars_kset = kset_create_and_add("vars", NULL, efi_kobj);
+ if (!vars_kset) {
+ printk(KERN_ERR "efivars: Subsystem registration failed.\n");
+ error = -ENOMEM;
goto out_firmware_unregister;
}
@@ -727,28 +711,28 @@ 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);
- }
+ error = sysfs_create_bin_file(&vars_kset->kobj,
+ &var_subsys_attr_new_var);
+ if (error)
+ printk(KERN_ERR "efivars: unable to create new_var sysfs file"
+ " due to error %d\n", error);
+ error = sysfs_create_bin_file(&vars_kset->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 */
-
- for (i = 0; (attr = efi_subsys_attrs[i]) && !error; i++) {
- if (attr->show)
- error = subsys_create_file(&efi_subsys, attr);
- }
-
+ error = sysfs_create_group(efi_kobj, &efi_subsys_attr_group);
if (error)
printk(KERN_ERR "efivars: Sysfs attribute export failed with error %d.\n", error);
else
goto out_free;
- subsystem_unregister(&vars_subsys);
+ kset_unregister(vars_kset);
out_firmware_unregister:
- firmware_unregister(&efi_subsys);
+ kobject_put(efi_kobj);
out_free:
kfree(variable_name);
@@ -768,8 +752,8 @@ efivars_exit(void)
efivar_unregister(entry);
}
- subsystem_unregister(&vars_subsys);
- firmware_unregister(&efi_subsys);
+ kset_unregister(vars_kset);
+ kobject_put(efi_kobj);
}
module_init(efivars_init);
OpenPOWER on IntegriCloud