[dahdi-commits] sruffell: linux/trunk r10245 - /linux/trunk/drivers/dahdi/wct4xxp/base.c
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Thu Oct 20 15:53:08 CDT 2011
Author: sruffell
Date: Thu Oct 20 15:53:05 2011
New Revision: 10245
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10245
Log:
wct4xxp: Trivial refactoring in t4_init_one().
Use some convenience pointers to make the function easier to read as opposed
to indexing into the arrays.
Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Michael Spiceland <mspiceland at digium.com>
Acked-by: Russ Meyerriecks <rmeyerriecks at digium.com>
Modified:
linux/trunk/drivers/dahdi/wct4xxp/base.c
Modified: linux/trunk/drivers/dahdi/wct4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wct4xxp/base.c?view=diff&rev=10245&r1=10244&r2=10245
==============================================================================
--- linux/trunk/drivers/dahdi/wct4xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wct4xxp/base.c Thu Oct 20 15:53:05 2011
@@ -4173,39 +4173,43 @@
/* Allocate pieces we need here */
for (x = 0; x < PORTS_PER_FRAMER; x++) {
- if (!(wc->tspans[x] = kmalloc(sizeof(*wc->tspans[x]), GFP_KERNEL))) {
+ struct t4_span *ts;
+
+ ts = kzalloc(sizeof(*ts), GFP_KERNEL);
+ if (!ts) {
free_wc(wc);
return -ENOMEM;
}
-
- memset(wc->tspans[x], 0, sizeof(*wc->tspans[x]));
-
- if (wc->t1e1 & (1 << x)) {
- wc->tspans[x]->spantype = TYPE_E1;
- } else {
- if (j1mode)
- wc->tspans[x]->spantype = TYPE_J1;
- else
- wc->tspans[x]->spantype = TYPE_T1;
- }
-
- for (f = 0; f < (wc->tspans[x]->spantype == TYPE_E1 ? 31 : 24); f++) {
- if (!(wc->tspans[x]->chans[f] = kmalloc(sizeof(*wc->tspans[x]->chans[f]), GFP_KERNEL))) {
+ wc->tspans[x] = ts;
+
+ if (wc->t1e1 & (1 << x))
+ ts->spantype = TYPE_E1;
+ else
+ ts->spantype = (j1mode) ? TYPE_J1 : TYPE_T1;
+
+ for (f = 0; f < (ts->spantype == TYPE_E1 ? 31 : 24); f++) {
+ struct dahdi_chan *chan;
+ struct dahdi_echocan_state *ec;
+
+ chan = kzalloc(sizeof(*chan), GFP_KERNEL);
+ if (!chan) {
free_wc(wc);
return -ENOMEM;
}
- memset(wc->tspans[x]->chans[f], 0, sizeof(*wc->tspans[x]->chans[f]));
- if (!(wc->tspans[x]->ec[f] = kmalloc(sizeof(*wc->tspans[x]->ec[f]), GFP_KERNEL))) {
+ ts->chans[f] = chan;
+
+ ec = kzalloc(sizeof(*ec), GFP_KERNEL);
+ if (!ec) {
free_wc(wc);
return -ENOMEM;
}
- memset(wc->tspans[x]->ec[f], 0, sizeof(*wc->tspans[x]->ec[f]));
+ ts->ec[f] = ec;
}
#ifdef ENABLE_WORKQUEUES
- INIT_WORK(&wc->tspans[x]->swork, workq_handlespan, wc->tspans[x]);
+ INIT_WORK(&ts->swork, workq_handlespan, ts);
#endif
- wc->tspans[x]->spanflags |= wc->devtype->flags;
+ ts->spanflags |= wc->devtype->flags;
}
/* Continue hardware intiialization */
More information about the dahdi-commits
mailing list