aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/common.c')
-rw-r--r--drivers/isdn/gigaset/common.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index 15dc0fc28a96..1d2ae2e05e0b 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -207,6 +207,32 @@ int gigaset_get_channel(struct bc_state *bcs)
207 return 1; 207 return 1;
208} 208}
209 209
210struct bc_state *gigaset_get_free_channel(struct cardstate *cs)
211{
212 unsigned long flags;
213 int i;
214
215 spin_lock_irqsave(&cs->lock, flags);
216 if (!try_module_get(cs->driver->owner)) {
217 gig_dbg(DEBUG_ANY,
218 "could not get module for allocating channel");
219 spin_unlock_irqrestore(&cs->lock, flags);
220 return NULL;
221 }
222 for (i = 0; i < cs->channels; ++i)
223 if (!cs->bcs[i].use_count) {
224 ++cs->bcs[i].use_count;
225 cs->bcs[i].busy = 1;
226 spin_unlock_irqrestore(&cs->lock, flags);
227 gig_dbg(DEBUG_ANY, "allocated channel %d", i);
228 return cs->bcs + i;
229 }
230 module_put(cs->driver->owner);
231 spin_unlock_irqrestore(&cs->lock, flags);
232 gig_dbg(DEBUG_ANY, "no free channel");
233 return NULL;
234}
235
210void gigaset_free_channel(struct bc_state *bcs) 236void gigaset_free_channel(struct bc_state *bcs)
211{ 237{
212 unsigned long flags; 238 unsigned long flags;