diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2012-04-26 17:53:03 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2012-04-26 18:15:47 -0400 |
commit | f7fb9d20ade55e538efe91477014b6b367ecd802 (patch) | |
tree | 7cac6b8fff5f461355a5913c171f801733bf4a80 | |
parent | bbe6a295d0a987068c89ca7e7b7291b754995754 (diff) |
tipc: Create helper routine to delete unused name sequence structure
Replaces two identical chunks of code that delete an unused name
sequence structure from TIPC's name table with calls to a new routine
that performs this operation.
This change is cosmetic and doesn't impact the operation of TIPC.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r-- | net/tipc/name_table.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 25c2975d86ee..42221219275c 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -186,7 +186,19 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea | |||
186 | return nseq; | 186 | return nseq; |
187 | } | 187 | } |
188 | 188 | ||
189 | /** | 189 | /* |
190 | * nameseq_delete_empty - deletes a name sequence structure if now unused | ||
191 | */ | ||
192 | static void nameseq_delete_empty(struct name_seq *seq) | ||
193 | { | ||
194 | if (!seq->first_free && list_empty(&seq->subscriptions)) { | ||
195 | hlist_del_init(&seq->ns_list); | ||
196 | kfree(seq->sseqs); | ||
197 | kfree(seq); | ||
198 | } | ||
199 | } | ||
200 | |||
201 | /* | ||
190 | * nameseq_find_subseq - find sub-sequence (if any) matching a name instance | 202 | * nameseq_find_subseq - find sub-sequence (if any) matching a name instance |
191 | * | 203 | * |
192 | * Very time-critical, so binary searches through sub-sequence array. | 204 | * Very time-critical, so binary searches through sub-sequence array. |
@@ -529,12 +541,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, | |||
529 | return NULL; | 541 | return NULL; |
530 | 542 | ||
531 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); | 543 | publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key); |
532 | 544 | nameseq_delete_empty(seq); | |
533 | if (!seq->first_free && list_empty(&seq->subscriptions)) { | ||
534 | hlist_del_init(&seq->ns_list); | ||
535 | kfree(seq->sseqs); | ||
536 | kfree(seq); | ||
537 | } | ||
538 | return publ; | 545 | return publ; |
539 | } | 546 | } |
540 | 547 | ||
@@ -768,11 +775,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s) | |||
768 | spin_lock_bh(&seq->lock); | 775 | spin_lock_bh(&seq->lock); |
769 | list_del_init(&s->nameseq_list); | 776 | list_del_init(&s->nameseq_list); |
770 | spin_unlock_bh(&seq->lock); | 777 | spin_unlock_bh(&seq->lock); |
771 | if ((seq->first_free == 0) && list_empty(&seq->subscriptions)) { | 778 | nameseq_delete_empty(seq); |
772 | hlist_del_init(&seq->ns_list); | ||
773 | kfree(seq->sseqs); | ||
774 | kfree(seq); | ||
775 | } | ||
776 | } | 779 | } |
777 | write_unlock_bh(&tipc_nametbl_lock); | 780 | write_unlock_bh(&tipc_nametbl_lock); |
778 | } | 781 | } |