summaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/common.c
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2009-10-06 12:19:17 +0000
committerDavid S. Miller <davem@davemloft.net>2009-10-06 22:43:53 -0700
commit7bb5fdc2fb021e32703ed1ff0269876bde1fa962 (patch)
tree818c29b7ed3ece19165d317050c333bab9f7fadb /drivers/isdn/gigaset/common.c
parentaaba2b3f8213e1d66e71c351fa7a2b1cbd974d3c (diff)
downloadtalos-obmc-linux-7bb5fdc2fb021e32703ed1ff0269876bde1fa962.tar.gz
talos-obmc-linux-7bb5fdc2fb021e32703ed1ff0269876bde1fa962.zip
gigaset: add Kernel CAPI interface (v3)
Add a Kernel CAPI interface to the Gigaset driver. Impact: optional new functionality Signed-off-by: Tilman Schmidt <tilman@imap.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
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)
return 1;
}
+struct bc_state *gigaset_get_free_channel(struct cardstate *cs)
+{
+ unsigned long flags;
+ int i;
+
+ spin_lock_irqsave(&cs->lock, flags);
+ if (!try_module_get(cs->driver->owner)) {
+ gig_dbg(DEBUG_ANY,
+ "could not get module for allocating channel");
+ spin_unlock_irqrestore(&cs->lock, flags);
+ return NULL;
+ }
+ for (i = 0; i < cs->channels; ++i)
+ if (!cs->bcs[i].use_count) {
+ ++cs->bcs[i].use_count;
+ cs->bcs[i].busy = 1;
+ spin_unlock_irqrestore(&cs->lock, flags);
+ gig_dbg(DEBUG_ANY, "allocated channel %d", i);
+ return cs->bcs + i;
+ }
+ module_put(cs->driver->owner);
+ spin_unlock_irqrestore(&cs->lock, flags);
+ gig_dbg(DEBUG_ANY, "no free channel");
+ return NULL;
+}
+
void gigaset_free_channel(struct bc_state *bcs)
{
unsigned long flags;
OpenPOWER on IntegriCloud