aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/dir.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 15:40:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 15:40:26 -0400
commitc813b4e16ead3c3df98ac84419d4df2adf33fe01 (patch)
tree2ca4a5b6966d833b6149e3dda7a4e85d1255779c /fs/sysfs/dir.c
parentc8d8a2321f9c4ee18fbcc399fdc2a77e580a03b9 (diff)
parent02683ffdf655b4ae15245376ba6fea6d9e5829a6 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (46 commits) UIO: Fix mapping of logical and virtual memory UIO: add automata sercos3 pci card support UIO: Change driver name of uio_pdrv UIO: Add alignment warnings for uio-mem Driver core: add bus_sort_breadthfirst() function NET: convert the phy_device file to use bus_find_device_by_name kobject: Cleanup kobject_rename and !CONFIG_SYSFS kobject: Fix kobject_rename and !CONFIG_SYSFS sysfs: Make dir and name args to sysfs_notify() const platform: add new device registration helper sysfs: use ilookup5() instead of ilookup5_nowait() PNP: create device attributes via default device attributes Driver core: make bus_find_device_by_name() more robust usb: turn dev_warn+WARN_ON combos into dev_WARN debug: use dev_WARN() rather than WARN_ON() in device_pm_add() debug: Introduce a dev_WARN() function sysfs: fix deadlock device model: Do a quickcheck for driver binding before doing an expensive check Driver core: Fix cleanup in device_create_vargs(). Driver core: Clarify device cleanup. ...
Diffstat (limited to 'fs/sysfs/dir.c')
-rw-r--r--fs/sysfs/dir.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index aedaeba82ae5..3a05a596e3b4 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -370,17 +370,17 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
370 memset(acxt, 0, sizeof(*acxt)); 370 memset(acxt, 0, sizeof(*acxt));
371 acxt->parent_sd = parent_sd; 371 acxt->parent_sd = parent_sd;
372 372
373 /* Lookup parent inode. inode initialization and I_NEW 373 /* Lookup parent inode. inode initialization is protected by
374 * clearing are protected by sysfs_mutex. By grabbing it and 374 * sysfs_mutex, so inode existence can be determined by
375 * looking up with _nowait variant, inode state can be 375 * looking up inode while holding sysfs_mutex.
376 * determined reliably.
377 */ 376 */
378 mutex_lock(&sysfs_mutex); 377 mutex_lock(&sysfs_mutex);
379 378
380 inode = ilookup5_nowait(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test, 379 inode = ilookup5(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
381 parent_sd); 380 parent_sd);
381 if (inode) {
382 WARN_ON(inode->i_state & I_NEW);
382 383
383 if (inode && !(inode->i_state & I_NEW)) {
384 /* parent inode available */ 384 /* parent inode available */
385 acxt->parent_inode = inode; 385 acxt->parent_inode = inode;
386 386
@@ -393,8 +393,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
393 mutex_lock(&inode->i_mutex); 393 mutex_lock(&inode->i_mutex);
394 mutex_lock(&sysfs_mutex); 394 mutex_lock(&sysfs_mutex);
395 } 395 }
396 } else 396 }
397 iput(inode);
398} 397}
399 398
400/** 399/**
@@ -636,6 +635,7 @@ struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
636 635
637 return sd; 636 return sd;
638} 637}
638EXPORT_SYMBOL_GPL(sysfs_get_dirent);
639 639
640static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, 640static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
641 const char *name, struct sysfs_dirent **p_sd) 641 const char *name, struct sysfs_dirent **p_sd)
@@ -829,16 +829,12 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
829 if (!new_dentry) 829 if (!new_dentry)
830 goto out_unlock; 830 goto out_unlock;
831 831
832 /* rename kobject and sysfs_dirent */ 832 /* rename sysfs_dirent */
833 error = -ENOMEM; 833 error = -ENOMEM;
834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL); 834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL);
835 if (!new_name) 835 if (!new_name)
836 goto out_unlock; 836 goto out_unlock;
837 837
838 error = kobject_set_name(kobj, "%s", new_name);
839 if (error)
840 goto out_unlock;
841
842 dup_name = sd->s_name; 838 dup_name = sd->s_name;
843 sd->s_name = new_name; 839 sd->s_name = new_name;
844 840