[svn-commits] sruffell: branch linux/sruffell/chan_list_refactoring r9290 - /linux/team/sru...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Sep 2 12:41:37 CDT 2010
Author: sruffell
Date: Thu Sep 2 12:41:26 2010
New Revision: 9290
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9290
Log:
dahdi: Keep psuedo channels on pseudo_chan_list.
Since pseudo channels are without spans and we would like to use the
span list to enumerate through all the channels, keeping the psuedo
channels on their own list is required. I believe this is a more
natural choice than making a dummy spans for pseudos since pseudo
channels should *really* just be an implementation detail that the user
shouldn't care about.
Modified:
linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c
Modified: linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c?view=diff&rev=9290&r1=9289&r2=9290
==============================================================================
--- linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c Thu Sep 2 12:41:26 2010
@@ -409,6 +409,19 @@
static rwlock_t zone_lock = RW_LOCK_UNLOCKED;
static rwlock_t chan_lock = RW_LOCK_UNLOCKED;
#endif
+
+struct pseudo_chan {
+ struct dahdi_chan chan;
+ struct list_head node;
+};
+
+static inline struct pseudo_chan *chan_to_pseudo(struct dahdi_chan *chan)
+{
+ return container_of(chan, struct pseudo_chan, chan);
+}
+
+/* This is protected by the chan_lock. */
+static LIST_HEAD(pseudo_chans);
/**
* is_pseudo_chan() - By definition psuedo channels are not on a span.
@@ -2896,7 +2909,8 @@
static struct dahdi_chan *dahdi_alloc_pseudo(void)
{
- struct dahdi_chan *pseudo;
+ struct pseudo_chan *pseudo;
+ unsigned long flags;
/* Don't allow /dev/dahdi/pseudo to open if there is not a timing
* source. */
@@ -2906,27 +2920,44 @@
if (!(pseudo = kzalloc(sizeof(*pseudo), GFP_KERNEL)))
return NULL;
- pseudo->sig = DAHDI_SIG_CLEAR;
- pseudo->sigcap = DAHDI_SIG_CLEAR;
- pseudo->flags = DAHDI_FLAG_AUDIO;
- pseudo->span = NULL; /* No span == psuedo channel */
-
- if (dahdi_chan_reg(pseudo)) {
+ INIT_LIST_HEAD(&pseudo->node);
+
+ pseudo->chan.sig = DAHDI_SIG_CLEAR;
+ pseudo->chan.sigcap = DAHDI_SIG_CLEAR;
+ pseudo->chan.flags = DAHDI_FLAG_AUDIO;
+ pseudo->chan.span = NULL; /* No span == psuedo channel */
+
+ if (dahdi_chan_reg(&pseudo->chan)) {
kfree(pseudo);
- pseudo = NULL;
- } else {
- snprintf(pseudo->name, sizeof(pseudo->name)-1,"Pseudo/%d", pseudo->channo);
- }
-
- return pseudo;
-}
-
-static void dahdi_free_pseudo(struct dahdi_chan *pseudo)
-{
- if (pseudo) {
- dahdi_chan_unreg(pseudo);
- kfree(pseudo);
- }
+ return NULL;
+ }
+
+ write_lock_irqsave(&chan_lock, flags);
+ list_add_tail(&pseudo->node, &pseudo_chans);
+ write_unlock_irqrestore(&chan_lock, flags);
+
+ snprintf(pseudo->chan.name, sizeof(pseudo->chan.name)-1,
+ "Pseudo/%d", pseudo->chan.channo);
+
+ return &pseudo->chan;
+}
+
+static void dahdi_free_pseudo(struct dahdi_chan *chan)
+{
+ struct pseudo_chan *pseudo;
+ unsigned long flags;
+
+ if (!chan)
+ return;
+
+ pseudo = chan_to_pseudo(chan);
+
+ write_lock_irqsave(&chan_lock, flags);
+ list_del(&pseudo->node);
+ write_unlock_irqrestore(&chan_lock, flags);
+
+ dahdi_chan_unreg(chan);
+ kfree(pseudo);
}
static int dahdi_open(struct inode *inode, struct file *file)
More information about the svn-commits
mailing list