From: Andrew Morton Signed-off-by: Andrew Morton --- fs/sysfs/dir.c | 30 +----------------------------- fs/sysfs/file.c | 6 ++---- fs/sysfs/symlink.c | 5 ++--- fs/sysfs/sysfs.h | 1 - 4 files changed, 5 insertions(+), 37 deletions(-) diff -puN fs/sysfs/dir.c~revert-gregkh-driver-sysfs-fix-problem-with-duplicate-sysfs-directories-and-files fs/sysfs/dir.c --- devel/fs/sysfs/dir.c~revert-gregkh-driver-sysfs-fix-problem-with-duplicate-sysfs-directories-and-files 2006-03-12 15:41:22.000000000 -0800 +++ devel-akpm/fs/sysfs/dir.c 2006-03-12 15:41:22.000000000 -0800 @@ -50,30 +50,6 @@ static struct sysfs_dirent * sysfs_new_d return sd; } -/** - * - * Return -EEXIST if there is already a sysfs element with the same name for - * the same parent. - * - * called with parent inode's i_mutex held - */ -int sysfs_dirent_exist(struct sysfs_dirent *parent_sd, - const unsigned char *new) -{ - struct sysfs_dirent * sd; - - list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { - const unsigned char * existing = sysfs_get_name(sd); - if (strcmp(existing, new)) - continue; - else - return -EEXIST; - } - - return 0; -} - - int sysfs_make_dirent(struct sysfs_dirent * parent_sd, struct dentry * dentry, void * element, umode_t mode, int type) { @@ -140,11 +116,7 @@ static int create_dir(struct kobject * k mutex_lock(&p->d_inode->i_mutex); *d = lookup_one_len(n, p, strlen(n)); if (!IS_ERR(*d)) { - if (sysfs_dirent_exist(p->d_fsdata, n)) - error = -EEXIST; - else - error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, - SYSFS_DIR); + error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR); if (!error) { error = sysfs_create(*d, mode, init_dir); if (!error) { diff -puN fs/sysfs/file.c~revert-gregkh-driver-sysfs-fix-problem-with-duplicate-sysfs-directories-and-files fs/sysfs/file.c --- devel/fs/sysfs/file.c~revert-gregkh-driver-sysfs-fix-problem-with-duplicate-sysfs-directories-and-files 2006-03-12 15:41:22.000000000 -0800 +++ devel-akpm/fs/sysfs/file.c 2006-03-12 15:41:22.000000000 -0800 @@ -375,12 +375,10 @@ int sysfs_add_file(struct dentry * dir, { struct sysfs_dirent * parent_sd = dir->d_fsdata; umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG; - int error = -EEXIST; + int error = 0; mutex_lock(&dir->d_inode->i_mutex); - if (!sysfs_dirent_exist(parent_sd, attr->name)) - error = sysfs_make_dirent(parent_sd, NULL, (void *)attr, - mode, type); + error = sysfs_make_dirent(parent_sd, NULL, (void *) attr, mode, type); mutex_unlock(&dir->d_inode->i_mutex); return error; diff -puN fs/sysfs/symlink.c~revert-gregkh-driver-sysfs-fix-problem-with-duplicate-sysfs-directories-and-files fs/sysfs/symlink.c --- devel/fs/sysfs/symlink.c~revert-gregkh-driver-sysfs-fix-problem-with-duplicate-sysfs-directories-and-files 2006-03-12 15:41:22.000000000 -0800 +++ devel-akpm/fs/sysfs/symlink.c 2006-03-12 15:41:22.000000000 -0800 @@ -82,13 +82,12 @@ exit1: int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) { struct dentry * dentry = kobj->dentry; - int error = -EEXIST; + int error = 0; BUG_ON(!kobj || !kobj->dentry || !name); mutex_lock(&dentry->d_inode->i_mutex); - if (!sysfs_dirent_exist(dentry->d_fsdata, name)) - error = sysfs_add_link(dentry, name, target); + error = sysfs_add_link(dentry, name, target); mutex_unlock(&dentry->d_inode->i_mutex); return error; } diff -puN fs/sysfs/sysfs.h~revert-gregkh-driver-sysfs-fix-problem-with-duplicate-sysfs-directories-and-files fs/sysfs/sysfs.h --- devel/fs/sysfs/sysfs.h~revert-gregkh-driver-sysfs-fix-problem-with-duplicate-sysfs-directories-and-files 2006-03-12 15:41:22.000000000 -0800 +++ devel-akpm/fs/sysfs/sysfs.h 2006-03-12 15:41:22.000000000 -0800 @@ -5,7 +5,6 @@ extern kmem_cache_t *sysfs_dir_cachep; extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *); extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *)); -extern int sysfs_dirent_exist(struct sysfs_dirent *, const unsigned char *); extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *, umode_t, int); _