From 81b4e1f6269cea345f17d3aa349ec9beb31a8cd3 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 16 Jan 2008 17:20:37 -0500 Subject: DMI: move dmi_available declaration to linux/dmi.h Signed-off-by: Len Brown --- drivers/firmware/dmi-id.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c index bc132d8f79c..313c99cbdc6 100644 --- a/drivers/firmware/dmi-id.c +++ b/drivers/firmware/dmi-id.c @@ -173,8 +173,6 @@ static struct device *dmi_dev; if (dmi_get_system_info(_field)) \ sys_dmi_attributes[i++] = &sys_dmi_##_name##_attr.dev_attr.attr; -extern int dmi_available; - /* In a separate function to keep gcc 3.2 happy - do NOT merge this in dmi_id_init! */ static void __init dmi_id_init_attr_table(void) -- cgit v1.2.3 From f89e3b0620a0dc19f313218f55373b9361142203 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Wed, 23 Jan 2008 16:36:45 -0500 Subject: DMI: create dmi_get_slot() This simply allows other sub-systems (such as ACPI) to access and print out slots in static dmi_ident[]. Signed-off-by: Len Brown --- drivers/firmware/dmi_scan.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/firmware') diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 0cdadea7a40..5e596a7e360 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -470,3 +470,11 @@ int dmi_get_year(int field) return year; } +/** + * dmi_get_slot - return dmi_ident[slot] + * @slot: index into dmi_ident[] + */ +char *dmi_get_slot(int slot) +{ + return(dmi_ident[slot]); +} -- cgit v1.2.3 From 3514faca19a6fdc209734431c509631ea92b094e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 16 Oct 2007 10:11:44 -0600 Subject: kobject: remove struct kobj_type from struct kset We don't need a "default" ktype for a kset. We should set this explicitly every time for each kset. This change is needed so that we can make ksets dynamic, and cleans up one of the odd, undocumented assumption that the kset/kobject/ktype model has. This patch is based on a lot of help from Kay Sievers. Nasty bug in the block code was found by Dave Young Cc: Kay Sievers Cc: Dave Young Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/edd.c | 5 +++-- drivers/firmware/efivars.c | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index 6942e065e60..fc567fad3f7 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c @@ -631,7 +631,7 @@ static struct kobj_type edd_ktype = { .default_attrs = def_attrs, }; -static decl_subsys(edd, &edd_ktype, NULL); +static decl_subsys(edd, NULL); /** @@ -723,7 +723,8 @@ edd_device_register(struct edd_device *edev, int i) edd_dev_set_info(edev, i); kobject_set_name(&edev->kobj, "int13_dev%02x", 0x80 + i); - kobj_set_kset_s(edev,edd_subsys); + edev->kobj.kset = &edd_subsys; + edev->kobj.ktype = &edd_ktype; error = kobject_register(&edev->kobj); if (!error) edd_populate_dir(edev); diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 858a7b95933..06ecdb9f601 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -583,8 +583,8 @@ static struct subsys_attribute *efi_subsys_attrs[] = { NULL, /* maybe more in the future? */ }; -static decl_subsys(vars, &efivar_ktype, NULL); -static decl_subsys(efi, NULL, NULL); +static decl_subsys(vars, NULL); +static decl_subsys(efi, NULL); /* * efivar_create_sysfs_entry() @@ -629,7 +629,8 @@ efivar_create_sysfs_entry(unsigned long variable_name_size, 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); + new_efivar->kobj.kset = &vars_subsys; + new_efivar->kobj.ktype = &efivar_ktype; i = kobject_register(&new_efivar->kobj); if (i) { kfree(short_name); @@ -687,7 +688,7 @@ efivars_init(void) goto out_free; } - kobj_set_kset_s(&vars_subsys, efi_subsys); + vars_subsys.kobj.kset = &efi_subsys; error = subsystem_register(&vars_subsys); -- cgit v1.2.3 From 97fa5bb74c26fda93757b94ed248f5dabd4ad3d7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 7 Nov 2007 13:56:19 -0800 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 Tested-by: Matt Domsch Cc: Matt Tolentino Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efivars.c | 51 +++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 06ecdb9f601..82183c28a12 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -143,13 +143,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,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 *var) } -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 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,13 +526,14 @@ 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, }; /* @@ -728,11 +718,16 @@ 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_subsys.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_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 */ -- cgit v1.2.3 From 334c6307543a2b8af730a422f466d5f9442b606a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Nov 2007 13:20:40 -0700 Subject: kobject: convert efivars to kobj_attr interface This cleans up a lot of code and gets rid of a unneeded macro, and gets us one step closer to deleting the deprecated subsys_attr code. Cc: Kay Sievers Cc: Matt Domsch Cc: Matt Tolentino Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efivars.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 82183c28a12..ebc38534b02 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}, \ @@ -540,12 +533,12 @@ static struct bin_attribute var_subsys_attr_del_var = { * 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) @@ -566,13 +559,19 @@ 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 struct attribute_group efi_subsys_attr_group = { + .attrs = efi_subsys_attrs, +}; + + static decl_subsys(vars, NULL); static decl_subsys(efi, NULL); @@ -651,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; @@ -730,12 +728,7 @@ efivars_init(void) " 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_subsys.kobj, &efi_subsys_attr_group); if (error) printk(KERN_ERR "efivars: Sysfs attribute export failed with error %d.\n", error); else -- cgit v1.2.3 From 89a07e34b16d9dcdf0a9ada3ca0c9a506b490c8f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Nov 2007 13:20:40 -0700 Subject: kset: convert efivars to use kset_create for the efi subsystem. Dynamically create the kset instead of declaring it statically. Cc: Kay Sievers Cc: Matt Domsch Cc: Matt Tolentino Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efivars.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index ebc38534b02..018ca1cd82b 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -573,7 +573,7 @@ static struct attribute_group efi_subsys_attr_group = { static decl_subsys(vars, NULL); -static decl_subsys(efi, NULL); +static struct kset *efi_kset; /* * efivar_create_sysfs_entry() @@ -668,15 +668,14 @@ efivars_init(void) /* * 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); + efi_kset = kset_create_and_add("efi", NULL, &firmware_kset->kobj); + if (!efi_kset) { + printk(KERN_ERR "efivars: Firmware registration failed.\n"); + error = -ENOMEM; goto out_free; } - vars_subsys.kobj.kset = &efi_subsys; + vars_subsys.kobj.kset = efi_kset; error = subsystem_register(&vars_subsys); @@ -728,7 +727,7 @@ efivars_init(void) " due to error %d\n", error); /* Don't forget the systab entry */ - error = sysfs_create_group(&efi_subsys.kobj, &efi_subsys_attr_group); + error = sysfs_create_group(&efi_kset->kobj, &efi_subsys_attr_group); if (error) printk(KERN_ERR "efivars: Sysfs attribute export failed with error %d.\n", error); else @@ -737,7 +736,7 @@ efivars_init(void) subsystem_unregister(&vars_subsys); out_firmware_unregister: - firmware_unregister(&efi_subsys); + kset_unregister(efi_kset); out_free: kfree(variable_name); @@ -758,7 +757,7 @@ efivars_exit(void) } subsystem_unregister(&vars_subsys); - firmware_unregister(&efi_subsys); + kset_unregister(efi_kset); } module_init(efivars_init); -- cgit v1.2.3 From 66ac831e03879c3c7dae76f793e6094e407081d2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Nov 2007 13:20:40 -0700 Subject: kset: convert efivars to use kset_create for the vars sub-subsystem. Dynamically create the kset instead of declaring it statically. Cc: Kay Sievers Cc: Matt Domsch Cc: Matt Tolentino Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efivars.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 018ca1cd82b..e17cd813354 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -572,7 +572,7 @@ static struct attribute_group efi_subsys_attr_group = { }; -static decl_subsys(vars, NULL); +static struct kset *vars_kset; static struct kset *efi_kset; /* @@ -618,7 +618,7 @@ efivar_create_sysfs_entry(unsigned long variable_name_size, efi_guid_unparse(vendor_guid, short_name + strlen(short_name)); kobject_set_name(&new_efivar->kobj, "%s", short_name); - new_efivar->kobj.kset = &vars_subsys; + new_efivar->kobj.kset = vars_kset; new_efivar->kobj.ktype = &efivar_ktype; i = kobject_register(&new_efivar->kobj); if (i) { @@ -675,12 +675,10 @@ efivars_init(void) goto out_free; } - vars_subsys.kobj.kset = efi_kset; - - 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_kset->kobj); + if (!vars_kset) { + printk(KERN_ERR "efivars: Subsystem registration failed.\n"); + error = -ENOMEM; goto out_firmware_unregister; } @@ -715,12 +713,12 @@ efivars_init(void) * Now add attributes to allow creation of new vars * and deletion of existing ones... */ - error = sysfs_create_bin_file(&vars_subsys.kobj, + 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_subsys.kobj, + 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" @@ -733,7 +731,7 @@ efivars_init(void) else goto out_free; - subsystem_unregister(&vars_subsys); + kset_unregister(vars_kset); out_firmware_unregister: kset_unregister(efi_kset); @@ -756,7 +754,7 @@ efivars_exit(void) efivar_unregister(entry); } - subsystem_unregister(&vars_subsys); + kset_unregister(vars_kset); kset_unregister(efi_kset); } -- cgit v1.2.3 From 9651d350ab2c1b9ef1875be2a9def1c375e6503f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Nov 2007 16:19:59 -0700 Subject: kset: convert edd to use kset_create Dynamically create the kset instead of declaring it statically. Cc: Kay Sievers Cc: Matt Domsch Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/edd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index fc567fad3f7..f07f37047cd 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c @@ -631,7 +631,7 @@ static struct kobj_type edd_ktype = { .default_attrs = def_attrs, }; -static decl_subsys(edd, NULL); +static struct kset *edd_kset; /** @@ -723,7 +723,7 @@ edd_device_register(struct edd_device *edev, int i) edd_dev_set_info(edev, i); kobject_set_name(&edev->kobj, "int13_dev%02x", 0x80 + i); - edev->kobj.kset = &edd_subsys; + edev->kobj.kset = edd_kset; edev->kobj.ktype = &edd_ktype; error = kobject_register(&edev->kobj); if (!error) @@ -756,9 +756,9 @@ edd_init(void) return 1; } - rc = firmware_register(&edd_subsys); - if (rc) - return rc; + edd_kset = kset_create_and_add("edd", NULL, &firmware_kset->kobj); + if (!edd_kset) + return -ENOMEM; for (i = 0; i < edd_num_devices() && !rc; i++) { edev = kzalloc(sizeof (*edev), GFP_KERNEL); @@ -774,7 +774,7 @@ edd_init(void) } if (rc) - firmware_unregister(&edd_subsys); + kset_unregister(edd_kset); return rc; } @@ -788,7 +788,7 @@ edd_exit(void) if ((edev = edd_devices[i])) edd_device_unregister(edev); } - firmware_unregister(&edd_subsys); + kset_unregister(edd_kset); } late_initcall(edd_init); -- cgit v1.2.3 From f62ed9e33b3ccff54d66b08f82d11940bb9e269b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 5 Nov 2007 13:16:15 -0800 Subject: firmware: change firmware_kset to firmware_kobj There is no firmware "subsystem" it's just a directory in /sys that other portions of the kernel want to hook into. So make it a kobject not a kset to help alivate anyone who tries to do some odd kset-like things with this. Cc: Kay Sievers Cc: Cornelia Huck Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/edd.c | 2 +- drivers/firmware/efivars.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index f07f37047cd..ddcc9579306 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c @@ -756,7 +756,7 @@ edd_init(void) return 1; } - edd_kset = kset_create_and_add("edd", NULL, &firmware_kset->kobj); + edd_kset = kset_create_and_add("edd", NULL, firmware_kobj); if (!edd_kset) return -ENOMEM; diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index e17cd813354..d1ad48190af 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -668,7 +668,7 @@ efivars_init(void) /* * For now we'll register the efi subsys within this driver */ - efi_kset = kset_create_and_add("efi", NULL, &firmware_kset->kobj); + efi_kset = kset_create_and_add("efi", NULL, firmware_kobj); if (!efi_kset) { printk(KERN_ERR "efivars: Firmware registration failed.\n"); error = -ENOMEM; -- cgit v1.2.3 From bc87d2fe7a1190f1c257af8a91fc490b1ee35954 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 7 Nov 2007 13:56:19 -0800 Subject: kobject: convert efivars to use kobject_create Using a kset for this simple directory is an overkill. Cc: Kay Sievers Cc: Matt Domsch Cc: Matt Tolentino Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efivars.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index d1ad48190af..7f9f086106c 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -573,7 +573,7 @@ static struct attribute_group efi_subsys_attr_group = { static struct kset *vars_kset; -static struct kset *efi_kset; +static struct kobject *efi_kobj; /* * efivar_create_sysfs_entry() @@ -665,17 +665,15 @@ 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 - */ - efi_kset = kset_create_and_add("efi", NULL, firmware_kobj); - if (!efi_kset) { + /* 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; } - vars_kset = kset_create_and_add("vars", NULL, &efi_kset->kobj); + vars_kset = kset_create_and_add("vars", NULL, efi_kobj); if (!vars_kset) { printk(KERN_ERR "efivars: Subsystem registration failed.\n"); error = -ENOMEM; @@ -725,7 +723,7 @@ efivars_init(void) " due to error %d\n", error); /* Don't forget the systab entry */ - error = sysfs_create_group(&efi_kset->kobj, &efi_subsys_attr_group); + 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 @@ -734,7 +732,7 @@ efivars_init(void) kset_unregister(vars_kset); out_firmware_unregister: - kset_unregister(efi_kset); + kobject_unregister(efi_kobj); out_free: kfree(variable_name); @@ -755,7 +753,7 @@ efivars_exit(void) } kset_unregister(vars_kset); - kset_unregister(efi_kset); + kobject_unregister(efi_kobj); } module_init(efivars_init); -- cgit v1.2.3 From dd002e807486f9858147c073069a37ba625baad8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 17 Dec 2007 15:54:39 -0400 Subject: Kobject: change drivers/firmware/edd.c to use kobject_init_and_add Stop using kobject_register, as this way we can control the sending of the uevent properly, after everything is properly initialized. Cc: Matt Domsch Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/edd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index ddcc9579306..dc0b87b1350 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c @@ -721,13 +721,13 @@ edd_device_register(struct edd_device *edev, int i) if (!edev) return 1; edd_dev_set_info(edev, i); - kobject_set_name(&edev->kobj, "int13_dev%02x", - 0x80 + i); edev->kobj.kset = edd_kset; - edev->kobj.ktype = &edd_ktype; - error = kobject_register(&edev->kobj); - if (!error) + error = kobject_init_and_add(&edev->kobj, &edd_ktype, NULL, + "int13_dev%02x", 0x80 + i); + if (!error) { edd_populate_dir(edev); + kobject_uevent(&edev->kobj, KOBJ_ADD); + } return error; } -- cgit v1.2.3 From d6d292c451e0ffe715fff36dc3a1129868258fa3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 17 Dec 2007 15:54:39 -0400 Subject: Kobject: change drivers/firmware/efivars.c to use kobject_init_and_add Stop using kobject_register, as this way we can control the sending of the uevent properly, after everything is properly initialized. Cc: Matt Domsch Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efivars.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 7f9f086106c..b61a72fb621 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -617,16 +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); new_efivar->kobj.kset = vars_kset; - new_efivar->kobj.ktype = &efivar_ktype; - i = kobject_register(&new_efivar->kobj); + 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; -- cgit v1.2.3 From c10997f6575f476ff38442fa18fd4a0d80345f9d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 20 Dec 2007 08:13:05 -0800 Subject: Kobject: convert drivers/* from kobject_unregister() to kobject_put() There is no need for kobject_unregister() anymore, thanks to Kay's kobject cleanup changes, so replace all instances of it with kobject_put(). Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/edd.c | 2 +- drivers/firmware/efivars.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index dc0b87b1350..d168223db15 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c @@ -693,7 +693,7 @@ edd_create_symlink_to_pcidev(struct edd_device *edev) static inline void edd_device_unregister(struct edd_device *edev) { - kobject_unregister(&edev->kobj); + kobject_put(&edev->kobj); } static void edd_populate_dir(struct edd_device * edev) diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index b61a72fb621..f4f709d1370 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c @@ -397,7 +397,7 @@ static struct kobj_type efivar_ktype = { static inline void efivar_unregister(struct efivar_entry *var) { - kobject_unregister(&var->kobj); + kobject_put(&var->kobj); } @@ -732,7 +732,7 @@ efivars_init(void) kset_unregister(vars_kset); out_firmware_unregister: - kobject_unregister(efi_kobj); + kobject_put(efi_kobj); out_free: kfree(variable_name); @@ -753,7 +753,7 @@ efivars_exit(void) } kset_unregister(vars_kset); - kobject_unregister(efi_kobj); + kobject_put(efi_kobj); } module_init(efivars_init); -- cgit v1.2.3 From 79da4721117fcf188b4b007b775738a530f574da Mon Sep 17 00:00:00 2001 From: Parag Warudkar Date: Wed, 30 Jan 2008 13:31:59 +0100 Subject: x86: fix DMI out of memory problems People with HP Desktops (including me) encounter couple of DMI errors during boot - dmi_save_oem_strings_devices: out of memory and dmi_string: out of memory. On some HP desktops the DMI data include OEM strings (type 11) out of which only few are meaningful and most other are empty. DMI code religiously creates copies of these 27 strings (65 bytes each in my case) and goes OOM in dmi_string(). If DMI_MAX_DATA is bumped up a little then it goes and fails in dmi_save_oem_strings while allocating dmi_devices of sizeof(struct dmi_device) corresponding to these strings. On x86_64 since we cannot use alloc_bootmem this early, the code uses a static array of 2048 bytes (DMI_MAX_DATA) for allocating the memory DMI needs. It does not survive the creation of empty strings and devices. Fix this by detecting and not newly allocating empty strings and instead using a one statically defined dmi_empty_string. Also do not create a new struct dmi_device for each empty string - use one statically define dmi_device with .name=dmi_empty_string and add that to the dmi_devices list. On x64 this should stop the OOM with same current size of DMI_MAX_DATA and on x86 this should save a good amount of (27*65 bytes + 27*sizeof(struct dmi_device) bootmem. Compile and boot tested on both 32-bit and 64-bit x86. Signed-off-by: Parag Warudkar Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- drivers/firmware/dmi_scan.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 5e596a7e360..0b24a114100 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -8,6 +8,8 @@ #include #include +static char dmi_empty_string[] = " "; + static char * __init dmi_string(const struct dmi_header *dm, u8 s) { const u8 *bp = ((u8 *) dm) + dm->length; @@ -21,11 +23,16 @@ static char * __init dmi_string(const struct dmi_header *dm, u8 s) } if (*bp != 0) { - str = dmi_alloc(strlen(bp) + 1); + size_t len = strlen(bp)+1; + size_t cmp_len = len > 8 ? 8 : len; + + if (!memcmp(bp, dmi_empty_string, cmp_len)) + return dmi_empty_string; + str = dmi_alloc(len); if (str != NULL) strcpy(str, bp); else - printk(KERN_ERR "dmi_string: out of memory.\n"); + printk(KERN_ERR "dmi_string: cannot allocate %Zu bytes.\n", len); } } @@ -175,12 +182,23 @@ static void __init dmi_save_devices(const struct dmi_header *dm) } } +static struct dmi_device empty_oem_string_dev = { + .name = dmi_empty_string, +}; + static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm) { int i, count = *(u8 *)(dm + 1); struct dmi_device *dev; for (i = 1; i <= count; i++) { + char *devname = dmi_string(dm, i); + + if (!strcmp(devname, dmi_empty_string)) { + list_add(&empty_oem_string_dev.list, &dmi_devices); + continue; + } + dev = dmi_alloc(sizeof(*dev)); if (!dev) { printk(KERN_ERR @@ -189,7 +207,7 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm) } dev->type = DMI_DEV_TYPE_OEM_STRING; - dev->name = dmi_string(dm, i); + dev->name = devname; dev->device_data = NULL; list_add(&dev->list, &dmi_devices); -- cgit v1.2.3 From 0d64484f7ea12ca04211b497e94634c3d27cf3fb Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 30 Jan 2008 13:33:09 +0100 Subject: x86: fix DMI ioremap leak Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- drivers/firmware/dmi_scan.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/firmware') diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 0b24a114100..5f9d0bc839b 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -349,6 +349,7 @@ void __init dmi_scan_machine(void) rc = dmi_present(q); if (!rc) { dmi_available = 1; + dmi_iounmap(p, 0x10000); return; } } -- cgit v1.2.3 From 3212bff370c2f22e4987c6679ba485654cefb178 Mon Sep 17 00:00:00 2001 From: Yinghai Lu Date: Wed, 30 Jan 2008 13:33:32 +0100 Subject: x86: left over fix for leak of early_ioremp in dmi_scan Signed-off-by: Yinghai Lu Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- drivers/firmware/dmi_scan.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/firmware') diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 5f9d0bc839b..9008ed5ef4c 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -353,6 +353,7 @@ void __init dmi_scan_machine(void) return; } } + dmi_iounmap(p, 0x10000); } out: printk(KERN_INFO "DMI not present or invalid.\n"); } -- cgit v1.2.3