summaryrefslogtreecommitdiffstats
path: root/fs/sysfs/dir.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <m.b.lankhorst@gmail.com>2013-03-08 16:07:27 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-25 10:42:36 -0700
commit3db3c62584fbafee52a068035cc4c57e7b921acf (patch)
treeb4d77f9833981ec5a089a3f29672dfce44687c4c /fs/sysfs/dir.c
parent91721197def2fc69abf152c47dbb87eed0f13333 (diff)
downloadop-kernel-dev-3db3c62584fbafee52a068035cc4c57e7b921acf.zip
op-kernel-dev-3db3c62584fbafee52a068035cc4c57e7b921acf.tar.gz
sysfs: use atomic_inc_unless_negative in sysfs_get_active
It seems that sysfs has an interesting way of doing the same thing. This removes the cpu_relax unfortunately, but if it's really needed, it would be better to add this to include/linux/atomic.h to benefit all atomic ops users. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs/dir.c')
-rw-r--r--fs/sysfs/dir.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 2fbdff6..7f968ed 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -165,21 +165,8 @@ struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd)
if (unlikely(!sd))
return NULL;
- while (1) {
- int v, t;
-
- v = atomic_read(&sd->s_active);
- if (unlikely(v < 0))
- return NULL;
-
- t = atomic_cmpxchg(&sd->s_active, v, v + 1);
- if (likely(t == v))
- break;
- if (t < 0)
- return NULL;
-
- cpu_relax();
- }
+ if (!atomic_inc_unless_negative(&sd->s_active))
+ return NULL;
if (likely(!ignore_lockdep(sd)))
rwsem_acquire_read(&sd->dep_map, 0, 1, _RET_IP_);
OpenPOWER on IntegriCloud