aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 8aa090da1cd7..b78fc1e68264 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -252,7 +252,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
252 struct kobject *top_kobj; 252 struct kobject *top_kobj;
253 struct kset *kset; 253 struct kset *kset;
254 char *envp[32]; 254 char *envp[32];
255 char data[PAGE_SIZE]; 255 char *data = NULL;
256 char *pos; 256 char *pos;
257 int i; 257 int i;
258 size_t count = 0; 258 size_t count = 0;
@@ -276,6 +276,10 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
276 if (!kset->uevent_ops->filter(kset, &dev->kobj)) 276 if (!kset->uevent_ops->filter(kset, &dev->kobj))
277 goto out; 277 goto out;
278 278
279 data = (char *)get_zeroed_page(GFP_KERNEL);
280 if (!data)
281 return -ENOMEM;
282
279 /* let the kset specific function add its keys */ 283 /* let the kset specific function add its keys */
280 pos = data; 284 pos = data;
281 retval = kset->uevent_ops->uevent(kset, &dev->kobj, 285 retval = kset->uevent_ops->uevent(kset, &dev->kobj,
@@ -290,6 +294,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
290 count += sprintf(pos, "%s\n", envp[i]); 294 count += sprintf(pos, "%s\n", envp[i]);
291 } 295 }
292out: 296out:
297 free_page((unsigned long)data);
293 return count; 298 return count;
294} 299}
295 300
@@ -560,7 +565,7 @@ static struct kobject * get_device_parent(struct device *dev,
560 /* Set the parent to the class, not the parent device */ 565 /* Set the parent to the class, not the parent device */
561 /* this keeps sysfs from having a symlink to make old udevs happy */ 566 /* this keeps sysfs from having a symlink to make old udevs happy */
562 if (dev->class) 567 if (dev->class)
563 return &dev->class->subsys.kset.kobj; 568 return &dev->class->subsys.kobj;
564 else if (parent) 569 else if (parent)
565 return &parent->kobj; 570 return &parent->kobj;
566 571
@@ -572,7 +577,7 @@ static struct kobject *virtual_device_parent(struct device *dev)
572 static struct kobject *virtual_dir = NULL; 577 static struct kobject *virtual_dir = NULL;
573 578
574 if (!virtual_dir) 579 if (!virtual_dir)
575 virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual"); 580 virtual_dir = kobject_add_dir(&devices_subsys.kobj, "virtual");
576 581
577 return virtual_dir; 582 return virtual_dir;
578} 583}
@@ -706,12 +711,12 @@ int device_add(struct device *dev)
706 } 711 }
707 712
708 if (dev->class) { 713 if (dev->class) {
709 sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj, 714 sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj,
710 "subsystem"); 715 "subsystem");
711 /* If this is not a "fake" compatible device, then create the 716 /* If this is not a "fake" compatible device, then create the
712 * symlink from the class to the device. */ 717 * symlink from the class to the device. */
713 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 718 if (dev->kobj.parent != &dev->class->subsys.kobj)
714 sysfs_create_link(&dev->class->subsys.kset.kobj, 719 sysfs_create_link(&dev->class->subsys.kobj,
715 &dev->kobj, dev->bus_id); 720 &dev->kobj, dev->bus_id);
716 if (parent) { 721 if (parent) {
717 sysfs_create_link(&dev->kobj, &dev->parent->kobj, 722 sysfs_create_link(&dev->kobj, &dev->parent->kobj,
@@ -769,8 +774,8 @@ int device_add(struct device *dev)
769 sysfs_remove_link(&dev->kobj, "subsystem"); 774 sysfs_remove_link(&dev->kobj, "subsystem");
770 /* If this is not a "fake" compatible device, remove the 775 /* If this is not a "fake" compatible device, remove the
771 * symlink from the class to the device. */ 776 * symlink from the class to the device. */
772 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 777 if (dev->kobj.parent != &dev->class->subsys.kobj)
773 sysfs_remove_link(&dev->class->subsys.kset.kobj, 778 sysfs_remove_link(&dev->class->subsys.kobj,
774 dev->bus_id); 779 dev->bus_id);
775 if (parent) { 780 if (parent) {
776#ifdef CONFIG_SYSFS_DEPRECATED 781#ifdef CONFIG_SYSFS_DEPRECATED
@@ -870,8 +875,8 @@ void device_del(struct device * dev)
870 sysfs_remove_link(&dev->kobj, "subsystem"); 875 sysfs_remove_link(&dev->kobj, "subsystem");
871 /* If this is not a "fake" compatible device, remove the 876 /* If this is not a "fake" compatible device, remove the
872 * symlink from the class to the device. */ 877 * symlink from the class to the device. */
873 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 878 if (dev->kobj.parent != &dev->class->subsys.kobj)
874 sysfs_remove_link(&dev->class->subsys.kset.kobj, 879 sysfs_remove_link(&dev->class->subsys.kobj,
875 dev->bus_id); 880 dev->bus_id);
876 if (parent) { 881 if (parent) {
877#ifdef CONFIG_SYSFS_DEPRECATED 882#ifdef CONFIG_SYSFS_DEPRECATED
@@ -1187,9 +1192,9 @@ int device_rename(struct device *dev, char *new_name)
1187#endif 1192#endif
1188 1193
1189 if (dev->class) { 1194 if (dev->class) {
1190 sysfs_remove_link(&dev->class->subsys.kset.kobj, 1195 sysfs_remove_link(&dev->class->subsys.kobj,
1191 old_symlink_name); 1196 old_symlink_name);
1192 sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, 1197 sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
1193 dev->bus_id); 1198 dev->bus_id);
1194 } 1199 }
1195 put_device(dev); 1200 put_device(dev);