[svn-commits] sruffell: branch linux/sruffell/chan_list r9342 - /linux/team/sruffell/chan_l...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Sep 17 14:11:51 CDT 2010
Author: sruffell
Date: Fri Sep 17 14:11:40 2010
New Revision: 9342
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9342
Log:
dahdi: Move the slave channel processing into separate functions.
IMO this improves readability of dahdi_receive and dahdi_transmit, and
the compiler can decide if it is better to inline this in with the
caller or break it out into a separate function.
Modified:
linux/team/sruffell/chan_list/drivers/dahdi/dahdi-base.c
Modified: linux/team/sruffell/chan_list/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/chan_list/drivers/dahdi/dahdi-base.c?view=diff&rev=9342&r1=9341&r2=9342
==============================================================================
--- linux/team/sruffell/chan_list/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/sruffell/chan_list/drivers/dahdi/dahdi-base.c Fri Sep 17 14:11:40 2010
@@ -8454,6 +8454,27 @@
}
}
+/**
+ * __transmit_to_slaves() - Distribute the tx data to all the slave channels.
+ *
+ */
+static void __transmit_to_slaves(struct dahdi_chan *const chan)
+{
+ u_char data[DAHDI_CHUNKSIZE];
+ int i;
+ int pos = DAHDI_CHUNKSIZE;
+ struct dahdi_chan *slave;
+ for (i = 0; i < DAHDI_CHUNKSIZE; i++) {
+ for (slave = chan; (NULL != slave); slave = slave->nextslave) {
+ if (pos == DAHDI_CHUNKSIZE) {
+ __dahdi_transmit_chunk(chan, data);
+ pos = 0;
+ }
+ slave->writechunk[i] = data[pos++];
+ }
+ }
+}
+
int dahdi_transmit(struct dahdi_span *span)
{
unsigned long flags;
@@ -8484,22 +8505,7 @@
spin_unlock_irqrestore(&chan->lock, flags);
continue;
} else if (chan->nextslave) {
- u_char data[DAHDI_CHUNKSIZE];
- int pos = DAHDI_CHUNKSIZE;
- int y;
- struct dahdi_chan *z;
- /* Process master/slaves one way */
- for (y = 0; y < DAHDI_CHUNKSIZE; y++) {
- /* Process slaves for this byte too */
- for (z = chan; z; z = z->nextslave) {
- if (pos == DAHDI_CHUNKSIZE) {
- /* Get next chunk */
- __dahdi_transmit_chunk(chan, data);
- pos = 0;
- }
- z->writechunk[y] = data[pos++];
- }
- }
+ __transmit_to_slaves(chan);
} else {
/* Process a normal channel */
__dahdi_real_transmit(chan);
@@ -8742,6 +8748,27 @@
#endif /* CONFIG_DAHDI_CORE_TIMER */
+/**
+ * __receive_from_slaves() - Collect the rx data from all the slave channels.
+ *
+ */
+static void __receive_from_slaves(struct dahdi_chan *const chan)
+{
+ u_char data[DAHDI_CHUNKSIZE];
+ int i;
+ int pos = 0;
+ struct dahdi_chan *slave;
+
+ for (i = 0; i < DAHDI_CHUNKSIZE; ++i) {
+ for (slave = chan; (NULL != slave); slave = slave->nextslave) {
+ data[pos++] = slave->readchunk[i];
+ if (pos == DAHDI_CHUNKSIZE) {
+ __dahdi_receive_chunk(chan, data);
+ pos = 0;
+ }
+ }
+ }
+}
int dahdi_receive(struct dahdi_span *span)
{
@@ -8764,21 +8791,7 @@
spin_unlock_irqrestore(&chan->lock, flags);
continue;
} else if (chan->nextslave) {
- /* Must process each slave at the same time */
- u_char data[DAHDI_CHUNKSIZE];
- int pos = 0;
- int y;
- struct dahdi_chan *z;
- for (y=0;y<DAHDI_CHUNKSIZE;y++) {
- /* Put all its slaves, too */
- for (z = chan; z; z = z->nextslave) {
- data[pos++] = z->readchunk[y];
- if (pos == DAHDI_CHUNKSIZE) {
- __dahdi_receive_chunk(chan, data);
- pos = 0;
- }
- }
- }
+ __receive_from_slaves(chan);
} else {
/* Process a normal channel */
__dahdi_real_receive(chan);
More information about the svn-commits
mailing list