diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2007-01-08 14:16:44 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-07 13:37:11 -0500 |
commit | c744aeae9d173a953b771a7ad5c872f91fa99dec (patch) | |
tree | 83d36e211ff6d0109f3aeb29d4fd1bb2dbb2a9b3 /lib | |
parent | 717e48c29d9a58f4d31c1651bec364212da5f6b2 (diff) |
driver core: Allow device_move(dev, NULL).
If we allow NULL as the new parent in device_move(), we need to make sure
that the device is placed into the same place as it would if it was
newly registered:
- Consider the device virtual tree. In order to be able to reuse code,
setup_parent() has been tweaked a bit.
- kobject_move() can fall back to the kset's kobject.
- sysfs_move_dir() uses the sysfs root dir as fallback.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kobject.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 9aed594bfcac..c033dc8fa9af 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -314,7 +314,7 @@ int kobject_rename(struct kobject * kobj, const char *new_name) | |||
314 | /** | 314 | /** |
315 | * kobject_move - move object to another parent | 315 | * kobject_move - move object to another parent |
316 | * @kobj: object in question. | 316 | * @kobj: object in question. |
317 | * @new_parent: object's new parent | 317 | * @new_parent: object's new parent (can be NULL) |
318 | */ | 318 | */ |
319 | 319 | ||
320 | int kobject_move(struct kobject *kobj, struct kobject *new_parent) | 320 | int kobject_move(struct kobject *kobj, struct kobject *new_parent) |
@@ -330,8 +330,8 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) | |||
330 | return -EINVAL; | 330 | return -EINVAL; |
331 | new_parent = kobject_get(new_parent); | 331 | new_parent = kobject_get(new_parent); |
332 | if (!new_parent) { | 332 | if (!new_parent) { |
333 | error = -EINVAL; | 333 | if (kobj->kset) |
334 | goto out; | 334 | new_parent = kobject_get(&kobj->kset->kobj); |
335 | } | 335 | } |
336 | /* old object path */ | 336 | /* old object path */ |
337 | devpath = kobject_get_path(kobj, GFP_KERNEL); | 337 | devpath = kobject_get_path(kobj, GFP_KERNEL); |