summaryrefslogtreecommitdiff
path: root/drivers/dahdi/dahdi-base.c
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-01-03 18:27:58 +0000
committerShaun Ruffell <sruffell@digium.com>2011-01-03 18:27:58 +0000
commite3eeec8102d21ea65b33513d8b8db5d981af5ad5 (patch)
tree4a093617f31551ee6381cd1dbf0d6ae55f6d23c1 /drivers/dahdi/dahdi-base.c
parent2b5d8801af27a1ffa8229ae5707f5ce6f536f595 (diff)
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. Signed-off-by: Shaun Ruffell <sruffell@digium.com> Acked-by: Kinsey Moore <kmoore@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9605 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/dahdi-base.c')
-rw-r--r--drivers/dahdi/dahdi-base.c75
1 files changed, 44 insertions, 31 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index eefac90..945c594 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -8518,6 +8518,27 @@ static inline void __dahdi_real_receive(struct dahdi_chan *chan)
}
}
+/**
+ * __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;
@@ -8550,22 +8571,7 @@ int dahdi_transmit(struct dahdi_span *span)
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);
@@ -8820,6 +8826,27 @@ static void coretimer_cleanup(void)
#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)
{
@@ -8844,21 +8871,7 @@ int dahdi_receive(struct dahdi_span *span)
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);