aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2011-07-21 20:01:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-22 20:43:52 -0400
commit58f2a4c7932d8bec866d0394f806004146cde827 (patch)
treeedbd5b8fb32005bc1b7ccc849fee23e97172ce53 /fs/sysfs
parent4f72c0cab40536a0be501d85ea4918467ab82ad5 (diff)
sysfs: remove s_sibling hacks
sysfs: remove s_sibling hacks s_sibling was used for three different purposes: 1) as a linked list of entries in the directory 2) as a linked list of entries to be deleted 3) as a pointer to "struct completion" This patch removes the hack and introduces new union u which holds pointers for cases 2) and 3). This change is needed for the following patch that removes s_sibling at all and replaces it with a rb tree. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs')
-rw-r--r--fs/sysfs/dir.c19
-rw-r--r--fs/sysfs/sysfs.h5
2 files changed, 12 insertions, 12 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 3e937da224d4..a4846979d4e8 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -154,7 +154,6 @@ struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd)
154 */ 154 */
155void sysfs_put_active(struct sysfs_dirent *sd) 155void sysfs_put_active(struct sysfs_dirent *sd)
156{ 156{
157 struct completion *cmpl;
158 int v; 157 int v;
159 158
160 if (unlikely(!sd)) 159 if (unlikely(!sd))
@@ -166,10 +165,9 @@ void sysfs_put_active(struct sysfs_dirent *sd)
166 return; 165 return;
167 166
168 /* atomic_dec_return() is a mb(), we'll always see the updated 167 /* atomic_dec_return() is a mb(), we'll always see the updated
169 * sd->s_sibling. 168 * sd->u.completion.
170 */ 169 */
171 cmpl = (void *)sd->s_sibling; 170 complete(sd->u.completion);
172 complete(cmpl);
173} 171}
174 172
175/** 173/**
@@ -183,16 +181,16 @@ static void sysfs_deactivate(struct sysfs_dirent *sd)
183 DECLARE_COMPLETION_ONSTACK(wait); 181 DECLARE_COMPLETION_ONSTACK(wait);
184 int v; 182 int v;
185 183
186 BUG_ON(sd->s_sibling || !(sd->s_flags & SYSFS_FLAG_REMOVED)); 184 BUG_ON(!(sd->s_flags & SYSFS_FLAG_REMOVED));
187 185
188 if (!(sysfs_type(sd) & SYSFS_ACTIVE_REF)) 186 if (!(sysfs_type(sd) & SYSFS_ACTIVE_REF))
189 return; 187 return;
190 188
191 sd->s_sibling = (void *)&wait; 189 sd->u.completion = (void *)&wait;
192 190
193 rwsem_acquire(&sd->dep_map, 0, 0, _RET_IP_); 191 rwsem_acquire(&sd->dep_map, 0, 0, _RET_IP_);
194 /* atomic_add_return() is a mb(), put_active() will always see 192 /* atomic_add_return() is a mb(), put_active() will always see
195 * the updated sd->s_sibling. 193 * the updated sd->u.completion.
196 */ 194 */
197 v = atomic_add_return(SD_DEACTIVATED_BIAS, &sd->s_active); 195 v = atomic_add_return(SD_DEACTIVATED_BIAS, &sd->s_active);
198 196
@@ -201,8 +199,6 @@ static void sysfs_deactivate(struct sysfs_dirent *sd)
201 wait_for_completion(&wait); 199 wait_for_completion(&wait);
202 } 200 }
203 201
204 sd->s_sibling = NULL;
205
206 lock_acquired(&sd->dep_map, _RET_IP_); 202 lock_acquired(&sd->dep_map, _RET_IP_);
207 rwsem_release(&sd->dep_map, 1, _RET_IP_); 203 rwsem_release(&sd->dep_map, 1, _RET_IP_);
208} 204}
@@ -518,7 +514,7 @@ void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
518 } 514 }
519 515
520 sd->s_flags |= SYSFS_FLAG_REMOVED; 516 sd->s_flags |= SYSFS_FLAG_REMOVED;
521 sd->s_sibling = acxt->removed; 517 sd->u.removed_list = acxt->removed;
522 acxt->removed = sd; 518 acxt->removed = sd;
523} 519}
524 520
@@ -542,8 +538,7 @@ void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt)
542 while (acxt->removed) { 538 while (acxt->removed) {
543 struct sysfs_dirent *sd = acxt->removed; 539 struct sysfs_dirent *sd = acxt->removed;
544 540
545 acxt->removed = sd->s_sibling; 541 acxt->removed = sd->u.removed_list;
546 sd->s_sibling = NULL;
547 542
548 sysfs_deactivate(sd); 543 sysfs_deactivate(sd);
549 unmap_bin_file(sd); 544 unmap_bin_file(sd);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index fe1a9e8650bf..3c261681713b 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -66,6 +66,11 @@ struct sysfs_dirent {
66 66
67 struct rb_node name_node; 67 struct rb_node name_node;
68 68
69 union {
70 struct completion *completion;
71 struct sysfs_dirent *removed_list;
72 } u;
73
69 const void *s_ns; /* namespace tag */ 74 const void *s_ns; /* namespace tag */
70 union { 75 union {
71 struct sysfs_elem_dir s_dir; 76 struct sysfs_elem_dir s_dir;