aboutsummaryrefslogtreecommitdiffstats
diff options
authorGreg Kroah-Hartman <gregkh@suse.de>2008-09-11 04:33:49 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2008-09-11 04:33:49 -0700
commit43d2c0bc0e8a31ed5daa1bc90088d7b0f7eb4078 (patch)
tree1c7837654e364138c0370540cbd0c66d241d491b
parent48413f29c85b608d373870ddd2ffedabc6f109f7 (diff)
downloadpatches-43d2c0bc0e8a31ed5daa1bc90088d7b0f7eb4078.tar.gz
more sysfs fun
-rw-r--r--driver-core/driver-core-add-bus_sort_breadthfirst-function.patch2
-rw-r--r--driver-core/driver-core-implement-tagged-directory-support-for-device-classes.patch205
-rw-r--r--driver-core/driver-core-remove-suspend-resume-callbacks-for-device-type.patch2
-rw-r--r--driver-core/driver-core-use-klist-for-class-device-list-and-implement-iterator.patch34
-rw-r--r--driver-core/sysfs-implement-sysfs_delete_link-and-sysfs_rename_link.patch117
-rw-r--r--driver-core/sysfs-remove-sysfs_create_link_nowarn.patch73
-rw-r--r--driver-core/sysfs-revert-netns-fix-device-renaming-for-sysfs.patch97
-rw-r--r--series6
8 files changed, 517 insertions, 19 deletions
diff --git a/driver-core/driver-core-add-bus_sort_breadthfirst-function.patch b/driver-core/driver-core-add-bus_sort_breadthfirst-function.patch
index a5b04451c6cad8..42b95202e26733 100644
--- a/driver-core/driver-core-add-bus_sort_breadthfirst-function.patch
+++ b/driver-core/driver-core-add-bus_sort_breadthfirst-function.patch
@@ -10,7 +10,7 @@ anyone else can also do this if needed. This also lets us change how
struct device is attached to drivers in the future without messing with
the PCI core.
-Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
+Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
diff --git a/driver-core/driver-core-implement-tagged-directory-support-for-device-classes.patch b/driver-core/driver-core-implement-tagged-directory-support-for-device-classes.patch
new file mode 100644
index 00000000000000..d7870c3c9889a3
--- /dev/null
+++ b/driver-core/driver-core-implement-tagged-directory-support-for-device-classes.patch
@@ -0,0 +1,205 @@
+From ebiederm@xmission.com Thu Sep 11 04:21:54 2008
+From: Eric W. Biederman <ebiederm@xmission.com>
+Date: Wed, 20 Aug 2008 23:37:55 -0700
+Subject: driver core: Implement tagged directory support for device classes.
+To: Greg KH <greg@kroah.com>
+Cc: Greg Kroah-Hartman <gregkh@suse.de>, Andrew Morton <akpm@linux-foundation.org>, Tejun Heo <htejun@gmail.com>, Daniel Lezcano <dlezcano@fr.ibm.com>, Al Viro <viro@ftp.linux.org.uk>, Benjamin Thery <benjamin.thery@bull.net>
+Message-ID: <m1zln6zxdo.fsf_-_@frodo.ebiederm.org>
+
+From: Eric W. Biederman <ebiederm@xmission.com>
+
+This patch enables tagging on every class directory if struct class
+has a tag_type.
+
+In addition device_del and device_rename were modified to use
+sysfs_delete_link and sysfs_rename_link respectively to ensure
+when these operations happen on devices whose classes have
+tag_ops that they work properly.
+
+Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
+Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/base/class.c | 30 ++++++++++++++++++++++----
+ drivers/base/core.c | 56 ++++++++++++++++++++++++++++++-------------------
+ include/linux/device.h | 3 ++
+ 3 files changed, 64 insertions(+), 25 deletions(-)
+
+--- a/drivers/base/class.c
++++ b/drivers/base/class.c
+@@ -135,6 +135,17 @@ static void remove_class_attrs(struct cl
+ }
+ }
+
++static int class_setup_tagging(struct class *cls)
++{
++ enum sysfs_tag_type type;
++
++ type = cls->tag_type;
++ if (type == SYSFS_TAG_TYPE_NONE)
++ return 0;
++
++ return sysfs_make_tagged_dir(&cls->p->class_subsys.kobj, type);
++}
++
+ int __class_register(struct class *cls, struct lock_class_key *key)
+ {
+ struct class_private *cp;
+@@ -171,13 +182,24 @@ int __class_register(struct class *cls,
+ cls->p = cp;
+
+ error = kset_register(&cp->class_subsys);
+- if (error) {
+- kfree(cp);
+- return error;
+- }
++ if (error)
++ goto out_free_cp;
++
++ error = class_setup_tagging(cls);
++ if (error)
++ goto out_unregister;
++
+ error = add_class_attrs(class_get(cls));
+ class_put(cls);
++ if (error)
++ goto out_unregister;
++out:
+ return error;
++out_unregister:
++ kset_unregister(&cp->class_subsys);
++out_free_cp:
++ kfree(cp);
++ goto out;
+ }
+ EXPORT_SYMBOL_GPL(__class_register);
+
+--- a/drivers/base/core.c
++++ b/drivers/base/core.c
+@@ -122,9 +122,21 @@ static void device_release(struct kobjec
+ dev->bus_id);
+ }
+
++static const void *device_sysfs_tag(struct kobject *kobj)
++{
++ struct device *dev = to_dev(kobj);
++ const void *tag = NULL;
++
++ if (dev->class && dev->class->tag_type)
++ tag = dev->class->sysfs_tag(dev);
++
++ return tag;
++}
++
+ static struct kobj_type device_ktype = {
+ .release = device_release,
+ .sysfs_ops = &dev_sysfs_ops,
++ .sysfs_tag = device_sysfs_tag,
+ };
+
+
+@@ -622,6 +634,10 @@ static struct kobject *get_device_parent
+ kobject_put(k);
+ return NULL;
+ }
++ /* If we created a new class-directory setup tagging */
++ if (dev->class->tag_type)
++ sysfs_make_tagged_dir(k, dev->class->tag_type);
++
+ /* do not emit an uevent for this simple "glue" directory */
+ return k;
+ }
+@@ -712,7 +728,7 @@ out_device:
+ out_busid:
+ if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
+ device_is_not_partition(dev))
+- sysfs_remove_link(&dev->class->p->class_subsys.kobj,
++ sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj,
+ dev->bus_id);
+ #else
+ /* link in the class directory pointing to the device */
+@@ -730,7 +746,7 @@ out_busid:
+ return 0;
+
+ out_busid:
+- sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
++ sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev->bus_id);
+ #endif
+
+ out_subsys:
+@@ -758,13 +774,13 @@ static void device_remove_class_symlinks
+
+ if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
+ device_is_not_partition(dev))
+- sysfs_remove_link(&dev->class->p->class_subsys.kobj,
++ sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj,
+ dev->bus_id);
+ #else
+ if (dev->parent && device_is_not_partition(dev))
+ sysfs_remove_link(&dev->kobj, "device");
+
+- sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
++ sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev->bus_id);
+ #endif
+
+ sysfs_remove_link(&dev->kobj, "subsystem");
+@@ -1360,6 +1376,15 @@ int device_rename(struct device *dev, ch
+ strlcpy(old_device_name, dev->bus_id, BUS_ID_SIZE);
+ strlcpy(dev->bus_id, new_name, BUS_ID_SIZE);
+
++#ifndef CONFIG_SYSFS_DEPRECATED
++ if (dev->class) {
++ error = sysfs_rename_link(&dev->class->p->class_subsys.kobj,
++ &dev->kobj, old_device_name, new_name);
++ if (error)
++ goto out;
++ }
++#endif
++
+ error = kobject_rename(&dev->kobj, new_name);
+ if (error) {
+ strlcpy(dev->bus_id, old_device_name, BUS_ID_SIZE);
+@@ -1368,24 +1393,13 @@ int device_rename(struct device *dev, ch
+
+ #ifdef CONFIG_SYSFS_DEPRECATED
+ if (old_class_name) {
++ error = -ENOMEM;
+ new_class_name = make_class_name(dev->class->name, &dev->kobj);
+- if (new_class_name) {
+- error = sysfs_create_link_nowarn(&dev->parent->kobj,
+- &dev->kobj,
+- new_class_name);
+- if (error)
+- goto out;
+- sysfs_remove_link(&dev->parent->kobj, old_class_name);
+- }
+- }
+-#else
+- if (dev->class) {
+- error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj,
+- &dev->kobj, dev->bus_id);
+- if (error)
+- goto out;
+- sysfs_remove_link(&dev->class->p->class_subsys.kobj,
+- old_device_name);
++ if (new_class_name)
++ error = sysfs_rename_link(&dev->parent->kobj,
++ &dev->kobj,
++ old_class_name,
++ new_class_name);
+ }
+ #endif
+
+--- a/include/linux/device.h
++++ b/include/linux/device.h
+@@ -195,6 +195,9 @@ struct class {
+ int (*suspend)(struct device *dev, pm_message_t state);
+ int (*resume)(struct device *dev);
+
++ enum sysfs_tag_type tag_type;
++ const void *(*sysfs_tag)(struct device *dev);
++
+ struct pm_ops *pm;
+ struct class_private *p;
+ };
diff --git a/driver-core/driver-core-remove-suspend-resume-callbacks-for-device-type.patch b/driver-core/driver-core-remove-suspend-resume-callbacks-for-device-type.patch
index b48947026468e9..b7182212450a0b 100644
--- a/driver-core/driver-core-remove-suspend-resume-callbacks-for-device-type.patch
+++ b/driver-core/driver-core-remove-suspend-resume-callbacks-for-device-type.patch
@@ -60,7 +60,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
pm_dev_dbg(dev, state, "");
--- a/include/linux/device.h
+++ b/include/linux/device.h
-@@ -273,9 +273,6 @@ struct device_type {
+@@ -276,9 +276,6 @@ struct device_type {
int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
void (*release)(struct device *dev);
diff --git a/driver-core/driver-core-use-klist-for-class-device-list-and-implement-iterator.patch b/driver-core/driver-core-use-klist-for-class-device-list-and-implement-iterator.patch
index e87fbd1375a9eb..81d2da6d4c6e82 100644
--- a/driver-core/driver-core-use-klist-for-class-device-list-and-implement-iterator.patch
+++ b/driver-core/driver-core-use-klist-for-class-device-list-and-implement-iterator.patch
@@ -47,8 +47,8 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
struct mutex class_mutex;
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
-@@ -135,6 +135,20 @@ static void remove_class_attrs(struct cl
- }
+@@ -146,6 +146,20 @@ static int class_setup_tagging(struct cl
+ return sysfs_make_tagged_dir(&cls->p->class_subsys.kobj, type);
}
+static void klist_class_dev_get(struct klist_node *n)
@@ -68,7 +68,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
int __class_register(struct class *cls, struct lock_class_key *key)
{
struct class_private *cp;
-@@ -145,7 +159,7 @@ int __class_register(struct class *cls,
+@@ -156,7 +170,7 @@ int __class_register(struct class *cls,
cp = kzalloc(sizeof(*cp), GFP_KERNEL);
if (!cp)
return -ENOMEM;
@@ -77,7 +77,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
INIT_LIST_HEAD(&cp->class_interfaces);
kset_init(&cp->class_dirs);
__mutex_init(&cp->class_mutex, "struct class mutex", key);
-@@ -269,6 +283,71 @@ char *make_class_name(const char *name,
+@@ -291,6 +305,71 @@ char *make_class_name(const char *name,
#endif
/**
@@ -149,7 +149,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* class_for_each_device - device iterator
* @class: the class we're iterating
* @start: the device to start with in the list, if any.
-@@ -283,13 +362,13 @@ char *make_class_name(const char *name,
+@@ -305,13 +384,13 @@ char *make_class_name(const char *name,
* We check the return of @fn each time. If it returns anything
* other than 0, we break out and return that value.
*
@@ -166,7 +166,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
struct device *dev;
int error = 0;
-@@ -301,20 +380,13 @@ int class_for_each_device(struct class *
+@@ -323,20 +402,13 @@ int class_for_each_device(struct class *
return -EINVAL;
}
@@ -190,7 +190,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
return error;
}
-@@ -337,16 +409,15 @@ EXPORT_SYMBOL_GPL(class_for_each_device)
+@@ -359,16 +431,15 @@ EXPORT_SYMBOL_GPL(class_for_each_device)
*
* Note, you will need to drop the reference with put_device() after use.
*
@@ -210,7 +210,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
if (!class)
return NULL;
-@@ -356,29 +427,23 @@ struct device *class_find_device(struct
+@@ -378,29 +449,23 @@ struct device *class_find_device(struct
return NULL;
}
@@ -247,7 +247,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
struct device *dev;
if (!class_intf || !class_intf->class)
-@@ -391,8 +456,10 @@ int class_interface_register(struct clas
+@@ -413,8 +478,10 @@ int class_interface_register(struct clas
mutex_lock(&parent->p->class_mutex);
list_add_tail(&class_intf->node, &parent->p->class_interfaces);
if (class_intf->add_dev) {
@@ -259,7 +259,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
}
mutex_unlock(&parent->p->class_mutex);
-@@ -402,6 +469,7 @@ int class_interface_register(struct clas
+@@ -424,6 +491,7 @@ int class_interface_register(struct clas
void class_interface_unregister(struct class_interface *class_intf)
{
struct class *parent = class_intf->class;
@@ -267,7 +267,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
struct device *dev;
if (!parent)
-@@ -410,8 +478,10 @@ void class_interface_unregister(struct c
+@@ -432,8 +500,10 @@ void class_interface_unregister(struct c
mutex_lock(&parent->p->class_mutex);
list_del_init(&class_intf->node);
if (class_intf->remove_dev) {
@@ -281,7 +281,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
-@@ -541,7 +541,6 @@ void device_initialize(struct device *de
+@@ -553,7 +553,6 @@ void device_initialize(struct device *de
klist_init(&dev->klist_children, klist_children_get,
klist_children_put);
INIT_LIST_HEAD(&dev->dma_pools);
@@ -289,7 +289,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
init_MUTEX(&dev->sem);
spin_lock_init(&dev->devres_lock);
INIT_LIST_HEAD(&dev->devres_head);
-@@ -925,7 +924,8 @@ int device_add(struct device *dev)
+@@ -941,7 +940,8 @@ int device_add(struct device *dev)
if (dev->class) {
mutex_lock(&dev->class->p->class_mutex);
/* tie the class to the device */
@@ -299,7 +299,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
/* notify any interfaces that the device is here */
list_for_each_entry(class_intf,
-@@ -1045,7 +1045,7 @@ void device_del(struct device *dev)
+@@ -1061,7 +1061,7 @@ void device_del(struct device *dev)
if (class_intf->remove_dev)
class_intf->remove_dev(dev, class_intf);
/* remove the device from the class list */
@@ -310,7 +310,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
device_remove_file(dev, &uevent_attr);
--- a/include/linux/device.h
+++ b/include/linux/device.h
-@@ -199,6 +199,11 @@ struct class {
+@@ -202,6 +202,11 @@ struct class {
struct class_private *p;
};
@@ -322,7 +322,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
extern struct kobject *sysfs_dev_block_kobj;
extern struct kobject *sysfs_dev_char_kobj;
extern int __must_check __class_register(struct class *class,
-@@ -213,6 +218,13 @@ extern void class_unregister(struct clas
+@@ -216,6 +221,13 @@ extern void class_unregister(struct clas
__class_register(class, &__key); \
})
@@ -336,7 +336,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
extern int class_for_each_device(struct class *class, struct device *start,
void *data,
int (*fn)(struct device *dev, void *data));
-@@ -393,7 +405,7 @@ struct device {
+@@ -396,7 +408,7 @@ struct device {
spinlock_t devres_lock;
struct list_head devres_head;
diff --git a/driver-core/sysfs-implement-sysfs_delete_link-and-sysfs_rename_link.patch b/driver-core/sysfs-implement-sysfs_delete_link-and-sysfs_rename_link.patch
new file mode 100644
index 00000000000000..48a8d402dd80b7
--- /dev/null
+++ b/driver-core/sysfs-implement-sysfs_delete_link-and-sysfs_rename_link.patch
@@ -0,0 +1,117 @@
+From ebiederm@xmission.com Thu Sep 11 04:20:35 2008
+From: Eric W. Biederman <ebiederm@xmission.com>
+Date: Wed, 20 Aug 2008 23:35:48 -0700
+Subject: sysfs: Implement sysfs_delete_link and sysfs_rename_link
+To: Greg KH <greg@kroah.com>
+Cc: Greg Kroah-Hartman <gregkh@suse.de>, Andrew Morton <akpm@linux-foundation.org>, Tejun Heo <htejun@gmail.com>, Daniel Lezcano <dlezcano@fr.ibm.com>, Al Viro <viro@ftp.linux.org.uk>, Benjamin Thery <benjamin.thery@bull.net>
+Message-ID: <m18wuq27uj.fsf_-_@frodo.ebiederm.org>
+
+From: Eric W. Biederman <ebiederm@xmission.com>
+
+When removing a symlink sysfs_remove_link does not provide
+enough information to figure out which tagged directory the symlink
+falls in. So I need sysfs_delete_link which is passed the target
+of the symlink to delete.
+
+Further half the time when we are removing a symlink the code is
+actually renaming the symlink but not doing so explicitly because
+we don't have a symlink rename method. So I have added sysfs_rename_link
+as well.
+
+Both of these functions now have enough information to find a symlink
+in a tagged directory. The only restriction is that they must be called
+before the target kobject is renamed or deleted. If they are called
+later I loose track of which tag the target kobject was marked with
+and can no longer find the old symlink to remove it.
+
+Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
+Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
+Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
+Acked-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/sysfs/symlink.c | 31 +++++++++++++++++++++++++++++++
+ include/linux/sysfs.h | 17 +++++++++++++++++
+ 2 files changed, 48 insertions(+)
+
+--- a/fs/sysfs/symlink.c
++++ b/fs/sysfs/symlink.c
+@@ -105,6 +105,21 @@ int sysfs_create_link_nowarn(struct kobj
+ }
+
+ /**
++ * sysfs_delete_link - remove symlink in object's directory.
++ * @kobj: object we're acting for.
++ * @targ: object we're pointing to.
++ * @name: name of the symlink to remove.
++ *
++ * Unlike sysfs_remove_link sysfs_delete_link has enough information
++ * to successfully delete symlinks in tagged directories.
++ */
++void sysfs_delete_link(struct kobject *kobj, struct kobject *targ,
++ const char *name)
++{
++ sysfs_hash_and_remove(targ, kobj->sd, name);
++}
++
++/**
+ * sysfs_remove_link - remove symlink in object's directory.
+ * @kobj: object we're acting for.
+ * @name: name of the symlink to remove.
+@@ -122,6 +137,22 @@ void sysfs_remove_link(struct kobject *
+ sysfs_hash_and_remove(kobj, parent_sd, name);
+ }
+
++/**
++ * sysfs_rename_link - rename symlink in object's directory.
++ * @kobj: object we're acting for.
++ * @targ: object we're pointing to.
++ * @old: previous name of the symlink.
++ * @new: new name of the symlink.
++ *
++ * A helper function for the common rename symlink idiom.
++ */
++int sysfs_rename_link(struct kobject *kobj, struct kobject *targ,
++ const char *old, const char *new)
++{
++ sysfs_delete_link(kobj, targ, old);
++ return sysfs_create_link(kobj, targ, new);
++}
++
+ static int sysfs_get_target_path(struct sysfs_dirent *parent_sd,
+ struct sysfs_dirent *target_sd, char *path)
+ {
+--- a/include/linux/sysfs.h
++++ b/include/linux/sysfs.h
+@@ -117,6 +117,12 @@ int __must_check sysfs_create_link_nowar
+ const char *name);
+ void sysfs_remove_link(struct kobject *kobj, const char *name);
+
++int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
++ const char *old_name, const char *new_name);
++
++void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
++ const char *name);
++
+ int __must_check sysfs_create_group(struct kobject *kobj,
+ const struct attribute_group *grp);
+ int sysfs_update_group(struct kobject *kobj,
+@@ -216,6 +222,17 @@ static inline void sysfs_remove_link(str
+ {
+ }
+
++static inline int sysfs_rename_link(struct kobject *k, struct kobject *t,
++ const char *old_name, const char *new_name)
++{
++ return 0;
++}
++
++static inline void sysfs_delete_link(struct kobject *k, struct kobject *t,
++ const char *name)
++{
++}
++
+ static inline int sysfs_create_group(struct kobject *kobj,
+ const struct attribute_group *grp)
+ {
diff --git a/driver-core/sysfs-remove-sysfs_create_link_nowarn.patch b/driver-core/sysfs-remove-sysfs_create_link_nowarn.patch
new file mode 100644
index 00000000000000..6785c4c7ce2156
--- /dev/null
+++ b/driver-core/sysfs-remove-sysfs_create_link_nowarn.patch
@@ -0,0 +1,73 @@
+From ebiederm@xmission.com Thu Sep 11 04:22:48 2008
+From: Eric W. Biederman <ebiederm@xmission.com>
+Date: Wed, 20 Aug 2008 23:36:32 -0700
+Subject: sysfs: Remove sysfs_create_link_nowarn
+To: Greg KH <greg@kroah.com>
+Cc: Greg Kroah-Hartman <gregkh@suse.de>, Andrew Morton <akpm@linux-foundation.org>, Tejun Heo <htejun@gmail.com>, Daniel Lezcano <dlezcano@fr.ibm.com>, Al Viro <viro@ftp.linux.org.uk>, Benjamin Thery <benjamin.thery@bull.net>
+Message-ID: <m14p5e27tb.fsf_-_@frodo.ebiederm.org>
+
+
+From: Eric W. Biederman <ebiederm@xmission.com>
+
+All of the uses have been replaced by sysfs_rename_link which
+is a clearer primitive to is also needed for the tagged directory
+support.
+
+Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/sysfs/symlink.c | 15 ---------------
+ include/linux/sysfs.h | 10 ----------
+ 2 files changed, 25 deletions(-)
+
+--- a/fs/sysfs/symlink.c
++++ b/fs/sysfs/symlink.c
+@@ -90,21 +90,6 @@ int sysfs_create_link(struct kobject *ko
+ }
+
+ /**
+- * sysfs_create_link_nowarn - create symlink between two objects.
+- * @kobj: object whose directory we're creating the link in.
+- * @target: object we're pointing to.
+- * @name: name of the symlink.
+- *
+- * This function does the same as sysf_create_link(), but it
+- * doesn't warn if the link already exists.
+- */
+-int sysfs_create_link_nowarn(struct kobject *kobj, struct kobject *target,
+- const char *name)
+-{
+- return sysfs_do_create_link(kobj, target, name, 0);
+-}
+-
+-/**
+ * sysfs_delete_link - remove symlink in object's directory.
+ * @kobj: object we're acting for.
+ * @targ: object we're pointing to.
+--- a/include/linux/sysfs.h
++++ b/include/linux/sysfs.h
+@@ -112,9 +112,6 @@ void sysfs_remove_bin_file(struct kobjec
+
+ int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
+ const char *name);
+-int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
+- struct kobject *target,
+- const char *name);
+ void sysfs_remove_link(struct kobject *kobj, const char *name);
+
+ int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
+@@ -211,13 +208,6 @@ static inline int sysfs_create_link(stru
+ return 0;
+ }
+
+-static inline int sysfs_create_link_nowarn(struct kobject *kobj,
+- struct kobject *target,
+- const char *name)
+-{
+- return 0;
+-}
+-
+ static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
+ {
+ }
diff --git a/driver-core/sysfs-revert-netns-fix-device-renaming-for-sysfs.patch b/driver-core/sysfs-revert-netns-fix-device-renaming-for-sysfs.patch
new file mode 100644
index 00000000000000..dafdd64a19532e
--- /dev/null
+++ b/driver-core/sysfs-revert-netns-fix-device-renaming-for-sysfs.patch
@@ -0,0 +1,97 @@
+From ebiederm@xmission.com Thu Sep 11 04:23:39 2008
+From: Eric W. Biederman <ebiederm@xmission.com>
+Date: Wed, 20 Aug 2008 23:38:31 -0700
+Subject: sysfs: Revert "netns: Fix device renaming for sysfs"
+To: Greg KH <greg@kroah.com>
+Cc: Greg Kroah-Hartman <gregkh@suse.de>, Andrew Morton <akpm@linux-foundation.org>, Tejun Heo <htejun@gmail.com>, Daniel Lezcano <dlezcano@fr.ibm.com>, Al Viro <viro@ftp.linux.org.uk>, Benjamin Thery <benjamin.thery@bull.net>
+Message-ID: <m1vdxuzxco.fsf_-_@frodo.ebiederm.org>
+
+From: Eric W. Biederman <ebiederm@xmission.com>
+
+This reverts commit aaf8cdc34ddba08122f02217d9d684e2f9f5d575.
+
+Drivers like the ipw2100 call device_create_group when they
+are initialized and device_remove_group when they are shutdown.
+Moving them between namespaces deletes their sysfs groups early.
+
+In particular the following call chain results.
+netdev_unregister_kobject -> device_del -> kobject_del -> sysfs_remove_dir
+With sysfs_remove_dir recursively deleting all of it's subdirectories,
+and nothing adding them back.
+
+Ouch!
+
+Therefore we need to call something that ultimate calls sysfs_mv_dir
+as that sysfs function can move sysfs directories between namespaces
+without deleting their subdirectories or their contents. Allowing
+us to avoid placing extra boiler plate into every driver that does
+something interesting with sysfs.
+
+Currently the function that provides that capability is device_rename.
+That is the code works without nasty side effects as originally written.
+
+So remove the misguided fix for moving devices between namespaces. The
+bug in the kobject layer that inspired it has now been recognized and
+fixed.
+
+Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
+Acked-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ net/core/dev.c | 4 +---
+ net/core/net-sysfs.c | 7 +------
+ net/core/net-sysfs.h | 1 -
+ 3 files changed, 2 insertions(+), 10 deletions(-)
+
+--- a/net/core/dev.c
++++ b/net/core/dev.c
+@@ -4005,7 +4005,6 @@ int register_netdevice(struct net_device
+ if (dev->features & NETIF_F_SG)
+ dev->features |= NETIF_F_GSO;
+
+- netdev_initialize_kobject(dev);
+ ret = netdev_register_kobject(dev);
+ if (ret)
+ goto err_uninit;
+@@ -4467,8 +4466,7 @@ int dev_change_net_namespace(struct net_
+ }
+
+ /* Fixup kobjects */
+- netdev_unregister_kobject(dev);
+- err = netdev_register_kobject(dev);
++ err = device_rename(&dev->dev, dev->name);
+ WARN_ON(err);
+
+ /* Add the device back in the hashes */
+--- a/net/core/net-sysfs.c
++++ b/net/core/net-sysfs.c
+@@ -449,6 +449,7 @@ int netdev_register_kobject(struct net_d
+ struct device *dev = &(net->dev);
+ struct attribute_group **groups = net->sysfs_groups;
+
++ device_initialize(dev);
+ dev->class = &net_class;
+ dev->platform_data = net;
+ dev->groups = groups;
+@@ -481,12 +482,6 @@ void netdev_class_remove_file(struct cla
+ EXPORT_SYMBOL(netdev_class_create_file);
+ EXPORT_SYMBOL(netdev_class_remove_file);
+
+-void netdev_initialize_kobject(struct net_device *net)
+-{
+- struct device *device = &(net->dev);
+- device_initialize(device);
+-}
+-
+ int netdev_kobject_init(void)
+ {
+ return class_register(&net_class);
+--- a/net/core/net-sysfs.h
++++ b/net/core/net-sysfs.h
+@@ -4,5 +4,4 @@
+ int netdev_kobject_init(void);
+ int netdev_register_kobject(struct net_device *);
+ void netdev_unregister_kobject(struct net_device *);
+-void netdev_initialize_kobject(struct net_device *);
+ #endif
diff --git a/series b/series
index 6efea418254250..a96bdcac4d994f 100644
--- a/series
+++ b/series
@@ -87,6 +87,7 @@ driver-core/driver-core-fix-cleanup-in-device_create_vargs.patch
#driver-core/s390-bus_id-dev_set_name-for-css-and-ccw-busses.patch
#driver-core-provide-a-dev_set_name-that-handles-names-longer-than-20-chars.patch
+# sysfs tagged dirs
driver-core/kobject-fix-kobject_rename-and-config_sysfs.patch
driver-core/kobject-cleanup-kobject_rename-and-config_sysfs.patch
driver-core/sysfs-support-for-preventing-unmounts.patch
@@ -97,6 +98,10 @@ driver-core/sysfs-introduce-sysfs_sd_setattr-and-fix-sysfs_chmod.patch
driver-core/sysfs-sysfs_chmod_file-handle-multiple-superblocks.patch
driver-core/sysfs-implement-sysfs-tagged-directory-support.patch
driver-core/sysfs-merge-sysfs_rename_dir-and-sysfs_move_dir.patch
+driver-core/sysfs-implement-sysfs_delete_link-and-sysfs_rename_link.patch
+driver-core/driver-core-implement-tagged-directory-support-for-device-classes.patch
+driver-core/sysfs-remove-sysfs_create_link_nowarn.patch
+driver-core/sysfs-revert-netns-fix-device-renaming-for-sysfs.patch
# multi driver-to-device series
driver-core/driver-core-use-dev_get_drvdata-accessors.patch
@@ -191,3 +196,4 @@ usb/usb-gotemp.patch
+