aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/ref.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/ref.c')
-rw-r--r--net/tipc/ref.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/net/tipc/ref.c b/net/tipc/ref.c
index e6d6ae22ea49..6704a58c7851 100644
--- a/net/tipc/ref.c
+++ b/net/tipc/ref.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * net/tipc/ref.c: TIPC object registry code 2 * net/tipc/ref.c: TIPC object registry code
3 * 3 *
4 * Copyright (c) 1991-2006, Ericsson AB 4 * Copyright (c) 1991-2006, Ericsson AB
5 * Copyright (c) 2004-2005, Wind River Systems 5 * Copyright (c) 2004-2005, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
@@ -50,11 +50,11 @@
50 * Object reference table consists of 2**N entries. 50 * Object reference table consists of 2**N entries.
51 * 51 *
52 * A used entry has object ptr != 0, reference == XXXX|own index 52 * A used entry has object ptr != 0, reference == XXXX|own index
53 * (XXXX changes each time entry is acquired) 53 * (XXXX changes each time entry is acquired)
54 * A free entry has object ptr == 0, reference == YYYY|next free index 54 * A free entry has object ptr == 0, reference == YYYY|next free index
55 * (YYYY is one more than last used XXXX) 55 * (YYYY is one more than last used XXXX)
56 * 56 *
57 * Free list is initially chained from entry (2**N)-1 to entry 1. 57 * Free list is initially chained from entry (2**N)-1 to entry 1.
58 * Entry 0 is not used to allow index 0 to indicate the end of the free list. 58 * Entry 0 is not used to allow index 0 to indicate the end of the free list.
59 * 59 *
60 * Note: Any accidental reference of the form XXXX|0--0 won't match entry 0 60 * Note: Any accidental reference of the form XXXX|0--0 won't match entry 0
@@ -113,9 +113,9 @@ void tipc_ref_table_stop(void)
113 113
114/** 114/**
115 * tipc_ref_acquire - create reference to an object 115 * tipc_ref_acquire - create reference to an object
116 * 116 *
117 * Return a unique reference value which can be translated back to the pointer 117 * Return a unique reference value which can be translated back to the pointer
118 * 'object' at a later time. Also, pass back a pointer to the lock protecting 118 * 'object' at a later time. Also, pass back a pointer to the lock protecting
119 * the object, but without locking it. 119 * the object, but without locking it.
120 */ 120 */
121 121
@@ -141,15 +141,15 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
141 index = tipc_ref_table.first_free; 141 index = tipc_ref_table.first_free;
142 entry = &(tipc_ref_table.entries[index]); 142 entry = &(tipc_ref_table.entries[index]);
143 index_mask = tipc_ref_table.index_mask; 143 index_mask = tipc_ref_table.index_mask;
144 /* take lock in case a previous user of entry still holds it */ 144 /* take lock in case a previous user of entry still holds it */
145 spin_lock_bh(&entry->lock); 145 spin_lock_bh(&entry->lock);
146 next_plus_upper = entry->data.next_plus_upper; 146 next_plus_upper = entry->data.next_plus_upper;
147 tipc_ref_table.first_free = next_plus_upper & index_mask; 147 tipc_ref_table.first_free = next_plus_upper & index_mask;
148 reference = (next_plus_upper & ~index_mask) + index; 148 reference = (next_plus_upper & ~index_mask) + index;
149 entry->data.reference = reference; 149 entry->data.reference = reference;
150 entry->object = object; 150 entry->object = object;
151 if (lock != 0) 151 if (lock != 0)
152 *lock = &entry->lock; 152 *lock = &entry->lock;
153 spin_unlock_bh(&entry->lock); 153 spin_unlock_bh(&entry->lock);
154 } 154 }
155 write_unlock_bh(&ref_table_lock); 155 write_unlock_bh(&ref_table_lock);
@@ -158,7 +158,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
158 158
159/** 159/**
160 * tipc_ref_discard - invalidate references to an object 160 * tipc_ref_discard - invalidate references to an object
161 * 161 *
162 * Disallow future references to an object and free up the entry for re-use. 162 * Disallow future references to an object and free up the entry for re-use.
163 * Note: The entry's spin_lock may still be busy after discard 163 * Note: The entry's spin_lock may still be busy after discard
164 */ 164 */
@@ -166,7 +166,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
166void tipc_ref_discard(u32 ref) 166void tipc_ref_discard(u32 ref)
167{ 167{
168 struct reference *entry; 168 struct reference *entry;
169 u32 index; 169 u32 index;
170 u32 index_mask; 170 u32 index_mask;
171 171
172 if (!ref) { 172 if (!ref) {
@@ -198,7 +198,7 @@ void tipc_ref_discard(u32 ref)
198 tipc_ref_table.first_free = index; 198 tipc_ref_table.first_free = index;
199 else 199 else
200 /* next_plus_upper is always XXXX|0--0 for last free entry */ 200 /* next_plus_upper is always XXXX|0--0 for last free entry */
201 tipc_ref_table.entries[tipc_ref_table.last_free].data.next_plus_upper 201 tipc_ref_table.entries[tipc_ref_table.last_free].data.next_plus_upper
202 |= index; 202 |= index;
203 tipc_ref_table.last_free = index; 203 tipc_ref_table.last_free = index;
204 204