diff options
Diffstat (limited to 'net/9p/util.c')
-rw-r--r-- | net/9p/util.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/net/9p/util.c b/net/9p/util.c index ef7215565d88..958fc58cd1ff 100644 --- a/net/9p/util.c +++ b/net/9p/util.c | |||
@@ -32,11 +32,23 @@ | |||
32 | #include <linux/idr.h> | 32 | #include <linux/idr.h> |
33 | #include <net/9p/9p.h> | 33 | #include <net/9p/9p.h> |
34 | 34 | ||
35 | /** | ||
36 | * struct p9_idpool - per-connection accounting for tag idpool | ||
37 | * @lock: protects the pool | ||
38 | * @pool: idr to allocate tag id from | ||
39 | * | ||
40 | */ | ||
41 | |||
35 | struct p9_idpool { | 42 | struct p9_idpool { |
36 | spinlock_t lock; | 43 | spinlock_t lock; |
37 | struct idr pool; | 44 | struct idr pool; |
38 | }; | 45 | }; |
39 | 46 | ||
47 | /** | ||
48 | * p9_idpool_create - create a new per-connection id pool | ||
49 | * | ||
50 | */ | ||
51 | |||
40 | struct p9_idpool *p9_idpool_create(void) | 52 | struct p9_idpool *p9_idpool_create(void) |
41 | { | 53 | { |
42 | struct p9_idpool *p; | 54 | struct p9_idpool *p; |
@@ -52,6 +64,11 @@ struct p9_idpool *p9_idpool_create(void) | |||
52 | } | 64 | } |
53 | EXPORT_SYMBOL(p9_idpool_create); | 65 | EXPORT_SYMBOL(p9_idpool_create); |
54 | 66 | ||
67 | /** | ||
68 | * p9_idpool_destroy - create a new per-connection id pool | ||
69 | * @p: idpool to destory | ||
70 | */ | ||
71 | |||
55 | void p9_idpool_destroy(struct p9_idpool *p) | 72 | void p9_idpool_destroy(struct p9_idpool *p) |
56 | { | 73 | { |
57 | idr_destroy(&p->pool); | 74 | idr_destroy(&p->pool); |
@@ -61,9 +78,9 @@ EXPORT_SYMBOL(p9_idpool_destroy); | |||
61 | 78 | ||
62 | /** | 79 | /** |
63 | * p9_idpool_get - allocate numeric id from pool | 80 | * p9_idpool_get - allocate numeric id from pool |
64 | * @p - pool to allocate from | 81 | * @p: pool to allocate from |
65 | * | 82 | * |
66 | * XXX - This seems to be an awful generic function, should it be in idr.c with | 83 | * Bugs: This seems to be an awful generic function, should it be in idr.c with |
67 | * the lock included in struct idr? | 84 | * the lock included in struct idr? |
68 | */ | 85 | */ |
69 | 86 | ||
@@ -71,7 +88,7 @@ int p9_idpool_get(struct p9_idpool *p) | |||
71 | { | 88 | { |
72 | int i = 0; | 89 | int i = 0; |
73 | int error; | 90 | int error; |
74 | unsigned int flags; | 91 | unsigned long flags; |
75 | 92 | ||
76 | retry: | 93 | retry: |
77 | if (idr_pre_get(&p->pool, GFP_KERNEL) == 0) | 94 | if (idr_pre_get(&p->pool, GFP_KERNEL) == 0) |
@@ -94,15 +111,16 @@ EXPORT_SYMBOL(p9_idpool_get); | |||
94 | 111 | ||
95 | /** | 112 | /** |
96 | * p9_idpool_put - release numeric id from pool | 113 | * p9_idpool_put - release numeric id from pool |
97 | * @p - pool to allocate from | 114 | * @id: numeric id which is being released |
115 | * @p: pool to release id into | ||
98 | * | 116 | * |
99 | * XXX - This seems to be an awful generic function, should it be in idr.c with | 117 | * Bugs: This seems to be an awful generic function, should it be in idr.c with |
100 | * the lock included in struct idr? | 118 | * the lock included in struct idr? |
101 | */ | 119 | */ |
102 | 120 | ||
103 | void p9_idpool_put(int id, struct p9_idpool *p) | 121 | void p9_idpool_put(int id, struct p9_idpool *p) |
104 | { | 122 | { |
105 | unsigned int flags; | 123 | unsigned long flags; |
106 | spin_lock_irqsave(&p->lock, flags); | 124 | spin_lock_irqsave(&p->lock, flags); |
107 | idr_remove(&p->pool, id); | 125 | idr_remove(&p->pool, id); |
108 | spin_unlock_irqrestore(&p->lock, flags); | 126 | spin_unlock_irqrestore(&p->lock, flags); |
@@ -111,11 +129,13 @@ EXPORT_SYMBOL(p9_idpool_put); | |||
111 | 129 | ||
112 | /** | 130 | /** |
113 | * p9_idpool_check - check if the specified id is available | 131 | * p9_idpool_check - check if the specified id is available |
114 | * @id - id to check | 132 | * @id: id to check |
115 | * @p - pool | 133 | * @p: pool to check |
116 | */ | 134 | */ |
135 | |||
117 | int p9_idpool_check(int id, struct p9_idpool *p) | 136 | int p9_idpool_check(int id, struct p9_idpool *p) |
118 | { | 137 | { |
119 | return idr_find(&p->pool, id) != NULL; | 138 | return idr_find(&p->pool, id) != NULL; |
120 | } | 139 | } |
121 | EXPORT_SYMBOL(p9_idpool_check); | 140 | EXPORT_SYMBOL(p9_idpool_check); |
141 | |||