From 8682c2a90bd996765326fb6477a2466b63530b73 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Mon, 26 Jul 2010 00:30:39 +0000 Subject: dahdi: Remove the 'pvt' member from dahdi_span. The vast majority of board drivers already keep the dahdi_span structure in a driver specific structure. The others were easily converted. This way board drivers can use the container_of macro to find what was previously pointed to by the "pvt" member of the span. One less thing to think about in the span structure. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8984 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/dahdi_dummy.c | 1 - drivers/dahdi/dahdi_dynamic.c | 14 +- drivers/dahdi/pciradio.c | 3 +- drivers/dahdi/tor2.c | 284 +++++++++++++++++----------------- drivers/dahdi/wcb4xxp/base.c | 11 +- drivers/dahdi/wcfxo.c | 8 +- drivers/dahdi/wct1xxp.c | 14 +- drivers/dahdi/wct4xxp/base.c | 15 +- drivers/dahdi/wctdm.c | 8 +- drivers/dahdi/wctdm24xxp/base.c | 11 +- drivers/dahdi/wctdm24xxp/wctdm24xxp.h | 1 + drivers/dahdi/wctdm24xxp/xhfc.c | 34 ++-- drivers/dahdi/wctdm24xxp/xhfc.h | 1 - drivers/dahdi/wcte11xp.c | 14 +- drivers/dahdi/wcte12xp/base.c | 11 +- drivers/dahdi/xpp/card_bri.c | 6 +- drivers/dahdi/xpp/card_pri.c | 9 +- drivers/dahdi/xpp/xbus-pcm.c | 2 +- drivers/dahdi/xpp/xpp_dahdi.c | 3 +- include/dahdi/kernel.h | 1 - 20 files changed, 230 insertions(+), 221 deletions(-) diff --git a/drivers/dahdi/dahdi_dummy.c b/drivers/dahdi/dahdi_dummy.c index f5b36b1..f50996a 100644 --- a/drivers/dahdi/dahdi_dummy.c +++ b/drivers/dahdi/dahdi_dummy.c @@ -213,7 +213,6 @@ static int dahdi_dummy_initialize(struct dahdi_dummy *ztd) ztd->span.channels = 0; /* no channels on our span */ ztd->span.deflaw = DAHDI_LAW_MULAW; init_waitqueue_head(&ztd->span.maintq); - ztd->span.pvt = ztd; ztd->chan->pvt = ztd; if (dahdi_register(&ztd->span, 0)) { return -1; diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c index f914e21..9b2542c 100644 --- a/drivers/dahdi/dahdi_dynamic.c +++ b/drivers/dahdi/dahdi_dynamic.c @@ -267,9 +267,14 @@ static void ztdynamic_run(void) #define ztdynamic_run __ztdynamic_run #endif +static inline struct dahdi_dynamic *dynamic_from_span(struct dahdi_span *span) +{ + return container_of(span, struct dahdi_dynamic, span); +} + void dahdi_dynamic_receive(struct dahdi_span *span, unsigned char *msg, int msglen) { - struct dahdi_dynamic *ztd = span->pvt; + struct dahdi_dynamic *ztd = dynamic_from_span(span); int newerr=0; int sflags; int xlen; @@ -497,8 +502,7 @@ static int ztd_rbsbits(struct dahdi_chan *chan, int bits) static int ztd_open(struct dahdi_chan *chan) { - struct dahdi_dynamic *z; - z = chan->span->pvt; + struct dahdi_dynamic *z = dynamic_from_span(chan->span); if (likely(z)) { if (unlikely(z->dead)) return -ENODEV; @@ -514,8 +518,7 @@ static int ztd_chanconfig(struct dahdi_chan *chan, int sigtype) static int ztd_close(struct dahdi_chan *chan) { - struct dahdi_dynamic *z; - z = chan->span->pvt; + struct dahdi_dynamic *z = dynamic_from_span(chan->span); if (z) { z->usecount--; if (z->dead && !z->usecount) @@ -584,7 +587,6 @@ static int create_dynamic(struct dahdi_dynamic_span *zds) sprintf(z->span.desc, "Dynamic '%s' span at '%s'", zds->driver, zds->addr); z->span.owner = THIS_MODULE; z->span.channels = zds->numchans; - z->span.pvt = z; z->span.deflaw = DAHDI_LAW_MULAW; z->span.flags |= DAHDI_FLAG_RBS; z->span.chans = z->chans; diff --git a/drivers/dahdi/pciradio.c b/drivers/dahdi/pciradio.c index 8d55f64..901d8f6 100644 --- a/drivers/dahdi/pciradio.c +++ b/drivers/dahdi/pciradio.c @@ -1423,7 +1423,7 @@ static int pciradio_open(struct dahdi_chan *chan) static int pciradio_watchdog(struct dahdi_span *span, int event) { printk(KERN_INFO "PCI RADIO: Restarting DMA\n"); - pciradio_restart_dma(span->pvt); + pciradio_restart_dma(container_of(span, struct pciradio, span)); return 0; } @@ -1486,7 +1486,6 @@ static int pciradio_initialize(struct pciradio *rad) rad->span.watchdog = pciradio_watchdog; init_waitqueue_head(&rad->span.maintq); - rad->span.pvt = rad; if (dahdi_register(&rad->span, 0)) { printk(KERN_NOTICE "Unable to register span with DAHDI\n"); return -1; diff --git a/drivers/dahdi/tor2.c b/drivers/dahdi/tor2.c index cfafa11..ee8ebe9 100644 --- a/drivers/dahdi/tor2.c +++ b/drivers/dahdi/tor2.c @@ -71,6 +71,7 @@ struct tor2_span { span number and pointer to the tor device */ struct tor2 *tor; int span; /* Index from 0 */ + struct dahdi_span dahdi_span; }; struct tor2 { @@ -96,7 +97,6 @@ struct tor2 { unsigned long xilinx8_region; /* 8 bit Region allocated to Xilinx */ unsigned long xilinx8_len; /* Length of 8 bit Xilinx region */ __iomem volatile unsigned char *mem8; /* Virtual representation of 8 bit Xilinx memory area */ - struct dahdi_span spans[SPANS_PER_CARD]; /* Spans */ struct tor2_span tspans[SPANS_PER_CARD]; /* Span data */ struct dahdi_chan **chans[SPANS_PER_CARD]; /* Pointers to card channels */ struct tor2_chan tchans[32 * SPANS_PER_CARD]; /* Channel user data */ @@ -195,7 +195,7 @@ static unsigned datxlt_e1[] = { static int tor2_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) { int i; - struct tor2_span *p = span->pvt; + struct tor2_span *p = container_of(span, struct tor2_span, dahdi_span); if (debug) printk(KERN_INFO "Tor2: Configuring span %d\n", span->spanno); @@ -264,47 +264,47 @@ static void init_spans(struct tor2 *tor) int x, y, c; /* TODO: a debug printk macro */ for (x = 0; x < SPANS_PER_CARD; x++) { - sprintf(tor->spans[x].name, "Tor2/%d/%d", tor->num, x + 1); - snprintf(tor->spans[x].desc, sizeof(tor->spans[x].desc) - 1, + struct dahdi_span *const s = &tor->tspans[x].dahdi_span; + sprintf(s->name, "Tor2/%d/%d", tor->num, x + 1); + snprintf(s->desc, sizeof(s->desc) - 1, "Tormenta 2 (PCI) Quad %s Card %d Span %d", (tor->cardtype == TYPE_T1) ? "T1" : "E1", tor->num, x + 1); - tor->spans[x].manufacturer = "Digium"; - dahdi_copy_string(tor->spans[x].devicetype, tor->type, sizeof(tor->spans[x].devicetype)); - snprintf(tor->spans[x].location, sizeof(tor->spans[x].location) - 1, + s->manufacturer = "Digium"; + dahdi_copy_string(s->devicetype, tor->type, sizeof(s->devicetype)); + snprintf(s->location, sizeof(s->location) - 1, "PCI Bus %02d Slot %02d", tor->pci->bus->number, PCI_SLOT(tor->pci->devfn) + 1); - tor->spans[x].owner = THIS_MODULE; - tor->spans[x].spanconfig = tor2_spanconfig; - tor->spans[x].chanconfig = tor2_chanconfig; - tor->spans[x].startup = tor2_startup; - tor->spans[x].shutdown = tor2_shutdown; - tor->spans[x].rbsbits = tor2_rbsbits; - tor->spans[x].maint = tor2_maint; - tor->spans[x].open = tor2_open; - tor->spans[x].close = tor2_close; + s->owner = THIS_MODULE; + s->spanconfig = tor2_spanconfig; + s->chanconfig = tor2_chanconfig; + s->startup = tor2_startup; + s->shutdown = tor2_shutdown; + s->rbsbits = tor2_rbsbits; + s->maint = tor2_maint; + s->open = tor2_open; + s->close = tor2_close; if (tor->cardtype == TYPE_T1) { - tor->spans[x].channels = 24; - tor->spans[x].deflaw = DAHDI_LAW_MULAW; - tor->spans[x].linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS | DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF; - tor->spans[x].spantype = "T1"; + s->channels = 24; + s->deflaw = DAHDI_LAW_MULAW; + s->linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS | DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF; + s->spantype = "T1"; } else { - tor->spans[x].channels = 31; - tor->spans[x].deflaw = DAHDI_LAW_ALAW; - tor->spans[x].linecompat = DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CCS | DAHDI_CONFIG_CRC4; - tor->spans[x].spantype = "E1"; + s->channels = 31; + s->deflaw = DAHDI_LAW_ALAW; + s->linecompat = DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CCS | DAHDI_CONFIG_CRC4; + s->spantype = "E1"; } - tor->spans[x].chans = tor->chans[x]; - tor->spans[x].flags = DAHDI_FLAG_RBS; - tor->spans[x].ioctl = tor2_ioctl; - tor->spans[x].pvt = &tor->tspans[x]; + s->chans = tor->chans[x]; + s->flags = DAHDI_FLAG_RBS; + s->ioctl = tor2_ioctl; tor->tspans[x].tor = tor; tor->tspans[x].span = x; - init_waitqueue_head(&tor->spans[x].maintq); - for (y=0;yspans[x].channels;y++) { + init_waitqueue_head(&s->maintq); + for (y = 0; y < s->channels; y++) { struct dahdi_chan *mychans = tor->chans[x][y]; sprintf(mychans->name, "Tor2/%d/%d/%d", tor->num, x + 1, y + 1); mychans->sigcap = DAHDI_SIG_EM | DAHDI_SIG_CLEAR | DAHDI_SIG_FXSLS | DAHDI_SIG_FXSGS | DAHDI_SIG_FXSKS | DAHDI_SIG_FXOLS | DAHDI_SIG_FXOGS | DAHDI_SIG_FXOKS | DAHDI_SIG_CAS | DAHDI_SIG_SF | DAHDI_SIG_EM_E1; - c = (x * tor->spans[x].channels) + y; + c = (x * s->channels) + y; mychans->pvt = &tor->tchans[c]; mychans->chanpos = y + 1; tor->tchans[c].span = x; @@ -315,36 +315,34 @@ static void init_spans(struct tor2 *tor) static int __devinit tor2_launch(struct tor2 *tor) { - if (test_bit(DAHDI_FLAGBIT_REGISTERED, &tor->spans[0].flags)) + struct dahdi_span *s; + int i; + + if (test_bit(DAHDI_FLAGBIT_REGISTERED, &tor->tspans[0].dahdi_span.flags)) return 0; + printk(KERN_INFO "Tor2: Launching card: %d\n", tor->order); - if (dahdi_register(&tor->spans[0], 0)) { - printk(KERN_ERR "Unable to register span %s\n", tor->spans[0].name); - return -1; - } - if (dahdi_register(&tor->spans[1], 0)) { - printk(KERN_ERR "Unable to register span %s\n", tor->spans[1].name); - dahdi_unregister(&tor->spans[0]); - return -1; - } - if (dahdi_register(&tor->spans[2], 0)) { - printk(KERN_ERR "Unable to register span %s\n", tor->spans[2].name); - dahdi_unregister(&tor->spans[0]); - dahdi_unregister(&tor->spans[1]); - return -1; - } - if (dahdi_register(&tor->spans[3], 0)) { - printk(KERN_ERR "Unable to register span %s\n", tor->spans[3].name); - dahdi_unregister(&tor->spans[0]); - dahdi_unregister(&tor->spans[1]); - dahdi_unregister(&tor->spans[2]); - return -1; + for (i = 0; i < SPANS_PER_CARD; ++i) { + s = &tor->tspans[i].dahdi_span; + if (dahdi_register(s, 0)) { + printk(KERN_ERR "Unable to register span %s\n", s->name); + goto error_exit; + } } tor->plx[INTCSR] = cpu_to_le16(PLX_INTENA); /* enable PLX interrupt */ + #ifdef ENABLE_TASKLETS tasklet_init(&tor->tor2_tlet, tor2_tasklet, (unsigned long)tor); #endif return 0; + +error_exit: + for (i = 0; i < SPANS_PER_CARD; ++i) { + s = &tor->tspans[i].dahdi_span; + if (test_bit(DAHDI_FLAGBIT_REGISTERED, &s->flags)) + dahdi_unregister(s); + } + return -1; } static void free_tor(struct tor2 *tor) @@ -630,8 +628,9 @@ static void __devexit tor2_remove(struct pci_dev *pdev) tor->plx[INTCSR] = cpu_to_le16(0); free_irq(tor->irq, tor); for (i = 0; i < SPANS_PER_CARD; ++i) { - if (test_bit(DAHDI_FLAGBIT_REGISTERED, &tor->spans[i].flags)) - dahdi_unregister(&tor->spans[i]); + struct dahdi_span *s = &tor->tspans[i].dahdi_span; + if (test_bit(DAHDI_FLAGBIT_REGISTERED, &s->flags)) + dahdi_unregister(s); } release_mem_region(tor->plx_region, tor->plx_len); release_mem_region(tor->xilinx32_region, tor->xilinx32_len); @@ -669,9 +668,10 @@ static void set_clear(struct tor2 *tor) int i,j,s; unsigned short val=0; for (s = 0; s < SPANS_PER_CARD; s++) { + struct dahdi_span *span = &tor->tspans[s].dahdi_span; for (i = 0; i < 24; i++) { j = (i/8); - if (tor->spans[s].chans[i]->flags & DAHDI_FLAG_CLEAR) + if (span->chans[i]->flags & DAHDI_FLAG_CLEAR) val |= 1 << (i % 8); if ((i % 8)==7) { @@ -763,7 +763,8 @@ static int tor2_shutdown(struct dahdi_span *span) int tspan; int wasrunning; unsigned long flags; - struct tor2_span *p = span->pvt; + struct tor2_span *const p = container_of(span, struct tor2_span, dahdi_span); + struct tor2 *const tor = p->tor; tspan = p->span + 1; if (tspan < 0) { @@ -771,27 +772,27 @@ static int tor2_shutdown(struct dahdi_span *span) return -1; } - spin_lock_irqsave(&p->tor->lock, flags); + spin_lock_irqsave(&tor->lock, flags); wasrunning = span->flags & DAHDI_FLAG_RUNNING; span->flags &= ~DAHDI_FLAG_RUNNING; /* Zero out all registers */ - if (p->tor->cardtype == TYPE_E1) { + if (tor->cardtype == TYPE_E1) { for (i = 0; i < 192; i++) - t1out(p->tor,tspan, i, 0); + t1out(tor, tspan, i, 0); } else { for (i = 0; i < 160; i++) - t1out(p->tor,tspan, i, 0); + t1out(tor, tspan, i, 0); } if (wasrunning) - p->tor->spansstarted--; - spin_unlock_irqrestore(&p->tor->lock, flags); - if (!(p->tor->spans[0].flags & DAHDI_FLAG_RUNNING) && - !(p->tor->spans[1].flags & DAHDI_FLAG_RUNNING) && - !(p->tor->spans[2].flags & DAHDI_FLAG_RUNNING) && - !(p->tor->spans[3].flags & DAHDI_FLAG_RUNNING)) + tor->spansstarted--; + spin_unlock_irqrestore(&tor->lock, flags); + if (!(tor->tspans[0].dahdi_span.flags & DAHDI_FLAG_RUNNING) && + !(tor->tspans[1].dahdi_span.flags & DAHDI_FLAG_RUNNING) && + !(tor->tspans[2].dahdi_span.flags & DAHDI_FLAG_RUNNING) && + !(tor->tspans[3].dahdi_span.flags & DAHDI_FLAG_RUNNING)) /* No longer in use, disable interrupts */ - p->tor->mem8[CTLREG] = 0; + tor->mem8[CTLREG] = 0; if (debug) printk(KERN_DEBUG"Span %d (%s) shutdown\n", span->spanno, span->name); return 0; @@ -808,7 +809,7 @@ static int tor2_startup(struct dahdi_span *span) char *framing; char *crcing; int alreadyrunning; - struct tor2_span *p = span->pvt; + struct tor2_span *p = container_of(span, struct tor2_span, dahdi_span); tspan = p->span + 1; if (tspan < 0) { @@ -1011,7 +1012,7 @@ static int tor2_startup(struct dahdi_span *span) static int tor2_maint(struct dahdi_span *span, int cmd) { - struct tor2_span *p = span->pvt; + struct tor2_span *p = container_of(span, struct tor2_span, dahdi_span); int tspan = p->span + 1; @@ -1074,26 +1075,28 @@ static inline void tor2_run(struct tor2 *tor) { int x,y; for (x = 0; x < SPANS_PER_CARD; x++) { - if (tor->spans[x].flags & DAHDI_FLAG_RUNNING) { + struct dahdi_span *const s = &tor->tspans[x].dahdi_span; + if (s->flags & DAHDI_FLAG_RUNNING) { /* since the Tormenta 2 PCI is double-buffered, you need to delay the transmit data 2 entire chunks so that the transmit will be in sync with the receive */ - for (y=0;yspans[x].channels;y++) { - dahdi_ec_chunk(tor->spans[x].chans[y], - tor->spans[x].chans[y]->readchunk, - tor->ec_chunk2[x][y]); + for (y = 0; y < s->channels; y++) { + dahdi_ec_chunk(s->chans[y], + s->chans[y]->readchunk, + tor->ec_chunk2[x][y]); memcpy(tor->ec_chunk2[x][y],tor->ec_chunk1[x][y], DAHDI_CHUNKSIZE); memcpy(tor->ec_chunk1[x][y], - tor->spans[x].chans[y]->writechunk, + s->chans[y]->writechunk, DAHDI_CHUNKSIZE); } - dahdi_receive(&tor->spans[x]); + dahdi_receive(s); } } for (x = 0; x < SPANS_PER_CARD; x++) { - if (tor->spans[x].flags & DAHDI_FLAG_RUNNING) - dahdi_transmit(&tor->spans[x]); + struct dahdi_span *const s = &tor->tspans[x].dahdi_span; + if (s->flags & DAHDI_FLAG_RUNNING) + dahdi_transmit(s); } } @@ -1142,10 +1145,10 @@ static int tor2_findsync(struct tor2 *tor) if (cards[x]->syncpos[i]) { nonzero = 1; if ((cards[x]->syncpos[i] == p) && - !(cards[x]->spans[i].alarms & (DAHDI_ALARM_RED | DAHDI_ALARM_BLUE | DAHDI_ALARM_LOOPBACK)) && - (cards[x]->spans[i].flags & DAHDI_FLAG_RUNNING)) { + !(cards[x]->tspans[i].dahdi_span.alarms & (DAHDI_ALARM_RED | DAHDI_ALARM_BLUE | DAHDI_ALARM_LOOPBACK)) && + (cards[x]->tspans[i].dahdi_span.flags & DAHDI_FLAG_RUNNING)) { /* This makes a good sync source */ - newsyncsrc = cards[x]->spans[i].spanno; + newsyncsrc = cards[x]->tspans[i].dahdi_span.spanno; newsyncnum = x; newsyncspan = i + 1; /* Jump out */ @@ -1173,7 +1176,7 @@ found: tor->syncsrc = syncsrc; /* Update sync sources */ for (i = 0; i < SPANS_PER_CARD; i++) { - tor->spans[i].syncsrc = tor->syncsrc; + tor->tspans[i].dahdi_span.syncsrc = tor->syncsrc; } if (syncnum == tor->num) { #if 1 @@ -1223,16 +1226,16 @@ DAHDI_IRQ_HANDLER(tor2_intr) #endif /* do the transmit output */ - for (n = 0; n < tor->spans[0].channels; n++) { + for (n = 0; n < tor->tspans[0].dahdi_span.channels; n++) { for (i = 0; i < DAHDI_CHUNKSIZE; i++) { /* span 1 */ - txword = tor->spans[0].chans[n]->writechunk[i] << 24; + txword = tor->tspans[0].dahdi_span.chans[n]->writechunk[i] << 24; /* span 2 */ - txword |= tor->spans[1].chans[n]->writechunk[i] << 16; + txword |= tor->tspans[1].dahdi_span.chans[n]->writechunk[i] << 16; /* span 3 */ - txword |= tor->spans[2].chans[n]->writechunk[i] << 8; + txword |= tor->tspans[2].dahdi_span.chans[n]->writechunk[i] << 8; /* span 4 */ - txword |= tor->spans[3].chans[n]->writechunk[i]; + txword |= tor->tspans[3].dahdi_span.chans[n]->writechunk[i]; /* write to part */ #ifdef FIXTHISFOR64 tor->mem32[tor->datxlt[n] + (32 * i)] = txword; @@ -1243,7 +1246,7 @@ DAHDI_IRQ_HANDLER(tor2_intr) } /* Do the receive input */ - for (n = 0; n < tor->spans[0].channels; n++) { + for (n = 0; n < tor->tspans[0].dahdi_span.channels; n++) { for (i = 0; i < DAHDI_CHUNKSIZE; i++) { /* read from */ #ifdef FIXTHISFOR64 @@ -1252,13 +1255,13 @@ DAHDI_IRQ_HANDLER(tor2_intr) rxword = le32_to_cpu(tor->mem32[tor->datxlt[n] + (32 * i)]); #endif /* span 1 */ - tor->spans[0].chans[n]->readchunk[i] = rxword >> 24; + tor->tspans[0].dahdi_span.chans[n]->readchunk[i] = rxword >> 24; /* span 2 */ - tor->spans[1].chans[n]->readchunk[i] = (rxword & 0xff0000) >> 16; + tor->tspans[1].dahdi_span.chans[n]->readchunk[i] = (rxword & 0xff0000) >> 16; /* span 3 */ - tor->spans[2].chans[n]->readchunk[i] = (rxword & 0xff00) >> 8; + tor->tspans[2].dahdi_span.chans[n]->readchunk[i] = (rxword & 0xff00) >> 8; /* span 4 */ - tor->spans[3].chans[n]->readchunk[i] = rxword & 0xff; + tor->tspans[3].dahdi_span.chans[n]->readchunk[i] = rxword & 0xff; } } @@ -1269,16 +1272,16 @@ DAHDI_IRQ_HANDLER(tor2_intr) for (k = 1; k <= SPANS_PER_CARD; k++) { c = t1in(tor,k,0x31 + j); rxc = c & 15; - if (rxc != tor->spans[k - 1].chans[j + 16]->rxsig) { + if (rxc != tor->tspans[k - 1].dahdi_span.chans[j + 16]->rxsig) { /* Check for changes in received bits */ - if (!(tor->spans[k - 1].chans[j + 16]->sig & DAHDI_SIG_CLEAR)) - dahdi_rbsbits(tor->spans[k - 1].chans[j + 16], rxc); + if (!(tor->tspans[k - 1].dahdi_span.chans[j + 16]->sig & DAHDI_SIG_CLEAR)) + dahdi_rbsbits(tor->tspans[k - 1].dahdi_span.chans[j + 16], rxc); } rxc = c >> 4; - if (rxc != tor->spans[k - 1].chans[j]->rxsig) { + if (rxc != tor->tspans[k - 1].dahdi_span.chans[j]->rxsig) { /* Check for changes in received bits */ - if (!(tor->spans[k - 1].chans[j]->sig & DAHDI_SIG_CLEAR)) - dahdi_rbsbits(tor->spans[k - 1].chans[j], rxc); + if (!(tor->tspans[k - 1].dahdi_span.chans[j]->sig & DAHDI_SIG_CLEAR)) + dahdi_rbsbits(tor->tspans[k - 1].dahdi_span.chans[j], rxc); } } } @@ -1296,11 +1299,10 @@ DAHDI_IRQ_HANDLER(tor2_intr) rxc = 0; if (abits & (1 << j)) rxc |= DAHDI_ABIT; if (bbits & (1 << j)) rxc |= DAHDI_BBIT; - if (tor->spans[k].chans[i]->rxsig != rxc) { + if (tor->tspans[k].dahdi_span.chans[i]->rxsig != rxc) { /* Check for changes in received bits */ - if (!(tor->spans[k].chans[i]->sig & DAHDI_SIG_CLEAR)) { - dahdi_rbsbits(tor->spans[k].chans[i], rxc); - } + if (!(tor->tspans[k].dahdi_span.chans[i]->sig & DAHDI_SIG_CLEAR)) + dahdi_rbsbits(tor->tspans[k].dahdi_span.chans[i], rxc); } } } @@ -1310,12 +1312,12 @@ DAHDI_IRQ_HANDLER(tor2_intr) if (tor->alarmtimer[i]) { if (!--tor->alarmtimer[i]) { /* clear recover status */ - tor->spans[i].alarms &= ~DAHDI_ALARM_RECOVER; + tor->tspans[i].dahdi_span.alarms &= ~DAHDI_ALARM_RECOVER; if (tor->cardtype == TYPE_E1) t1out(tor,i + 1,0x21,0x5f); /* turn off yel */ else t1out(tor,i + 1,0x35,0x10); /* turn off yel */ - dahdi_alarm_notify(&tor->spans[i]); /* let them know */ + dahdi_alarm_notify(&tor->tspans[i].dahdi_span); /* let them know */ } } } @@ -1327,31 +1329,31 @@ DAHDI_IRQ_HANDLER(tor2_intr) i -= 10; if (tor->cardtype == TYPE_T1) { c = t1in(tor,i + 1,0x31); /* get RIR2 */ - tor->spans[i].rxlevel = c >> 6; /* get rx level */ + tor->tspans[i].dahdi_span.rxlevel = c >> 6; /* get rx level */ t1out(tor,i + 1,0x20,0xff); c = t1in(tor,i + 1,0x20); /* get the status */ /* detect the code, only if we are not sending one */ - if ((!tor->spans[i].mainttimer) && (c & 0x80)) /* if loop-up code detected */ + if ((!tor->tspans[i].dahdi_span.mainttimer) && (c & 0x80)) /* if loop-up code detected */ { /* set into remote loop, if not there already */ if ((tor->loopupcnt[i]++ > 80) && - (tor->spans[i].maintstat != DAHDI_MAINT_REMOTELOOP)) + (tor->tspans[i].dahdi_span.maintstat != DAHDI_MAINT_REMOTELOOP)) { t1out(tor,i + 1,0x1e,(japan ? 0x80 : 0x00)); /* no local loop */ t1out(tor,i + 1,0x0a,0x40); /* remote loop */ - tor->spans[i].maintstat = DAHDI_MAINT_REMOTELOOP; + tor->tspans[i].dahdi_span.maintstat = DAHDI_MAINT_REMOTELOOP; } } else tor->loopupcnt[i] = 0; /* detect the code, only if we are not sending one */ - if ((!tor->spans[i].mainttimer) && (c & 0x40)) /* if loop-down code detected */ + if ((!tor->tspans[i].dahdi_span.mainttimer) && (c & 0x40)) /* if loop-down code detected */ { /* if in remote loop, get out of it */ if ((tor->loopdowncnt[i]++ > 80) && - (tor->spans[i].maintstat == DAHDI_MAINT_REMOTELOOP)) + (tor->tspans[i].dahdi_span.maintstat == DAHDI_MAINT_REMOTELOOP)) { t1out(tor,i + 1,0x1e,(japan ? 0x80 : 0x00)); /* no local loop */ t1out(tor,i + 1,0x0a,0); /* no remote loop */ - tor->spans[i].maintstat = DAHDI_MAINT_NONE; + tor->tspans[i].dahdi_span.maintstat = DAHDI_MAINT_NONE; } } else tor->loopdowncnt[i] = 0; if (c & 3) /* if red alarm */ @@ -1375,29 +1377,27 @@ DAHDI_IRQ_HANDLER(tor2_intr) } } /* only consider previous carrier alarm state */ - tor->spans[i].alarms &= (DAHDI_ALARM_RED | DAHDI_ALARM_BLUE | DAHDI_ALARM_NOTOPEN); + tor->tspans[i].dahdi_span.alarms &= (DAHDI_ALARM_RED | DAHDI_ALARM_BLUE | DAHDI_ALARM_NOTOPEN); n = 1; /* set to 1 so will not be in yellow alarm if we dont care about open channels */ - /* if to have yellow alarm if nothing open */ - if (tor->spans[i].lineconfig & DAHDI_CONFIG_NOTOPEN) - { - /* go thru all chans, and count # open */ - for (n = 0,k = 0; k < tor->spans[i].channels; k++) - { + /* if to have yellow alarm if nothing open */ + if (tor->tspans[i].dahdi_span.lineconfig & DAHDI_CONFIG_NOTOPEN) { + /* go thru all chans, and count # open */ + for (n = 0, k = 0; k < tor->tspans[i].dahdi_span.channels; k++) { if (((tor->chans[i][k])->flags & DAHDI_FLAG_OPEN) || - ((tor->chans[i][k])->flags & DAHDI_FLAG_NETDEV)) n++; - } - /* if none open, set alarm condition */ - if (!n) j |= DAHDI_ALARM_NOTOPEN; - } + ((tor->chans[i][k])->flags & DAHDI_FLAG_NETDEV)) + n++; + } + /* if none open, set alarm condition */ + if (!n) + j |= DAHDI_ALARM_NOTOPEN; + } /* if no more alarms, and we had some */ - if ((!j) && tor->spans[i].alarms) - { + if ((!j) && tor->tspans[i].dahdi_span.alarms) tor->alarmtimer[i] = DAHDI_ALARMSETTLE_TIME; - } if (tor->alarmtimer[i]) j |= DAHDI_ALARM_RECOVER; /* if going into alarm state, set yellow alarm */ - if ((j) && (!tor->spans[i].alarms)) { + if ((j) && (!tor->tspans[i].dahdi_span.alarms)) { if (tor->cardtype == TYPE_E1) t1out(tor,i + 1,0x21,0x7f); else @@ -1405,18 +1405,19 @@ DAHDI_IRQ_HANDLER(tor2_intr) } if (c & 4) /* if yellow alarm */ j |= DAHDI_ALARM_YELLOW; - if (tor->spans[i].maintstat || tor->spans[i].mainttimer) j |= DAHDI_ALARM_LOOPBACK; - tor->spans[i].alarms = j; + if (tor->tspans[i].dahdi_span.maintstat || tor->tspans[i].dahdi_span.mainttimer) + j |= DAHDI_ALARM_LOOPBACK; + tor->tspans[i].dahdi_span.alarms = j; c = (LEDRED | LEDGREEN) << (2 * i); tor->leds &= ~c; /* mask out bits for this span */ /* light LED's if span configured and running */ - if (tor->spans[i].flags & DAHDI_FLAG_RUNNING) { + if (tor->tspans[i].dahdi_span.flags & DAHDI_FLAG_RUNNING) { if (j & DAHDI_ALARM_RED) tor->leds |= LEDRED << (2 * i); else if (j & DAHDI_ALARM_YELLOW) tor->leds |= (LEDRED | LEDGREEN) << (2 * i); else tor->leds |= LEDGREEN << (2 * i); } tor->mem8[LEDREG] = tor->leds; - dahdi_alarm_notify(&tor->spans[i]); + dahdi_alarm_notify(&tor->tspans[i].dahdi_span); } if (!(tor->passno % 1000)) /* even second boundary */ { @@ -1426,26 +1427,26 @@ DAHDI_IRQ_HANDLER(tor2_intr) if (tor->cardtype == TYPE_E1) { /* add this second's BPV count to total one */ - tor->spans[i - 1].count.bpv += + tor->tspans[i - 1].dahdi_span.count.bpv += t1in(tor, i, 1) + (t1in(tor, i, 0)<<8); - if (tor->spans[i - 1].lineconfig & DAHDI_CONFIG_CRC4) + if (tor->tspans[i - 1].dahdi_span.lineconfig & DAHDI_CONFIG_CRC4) { - tor->spans[i - 1].count.crc4 += + tor->tspans[i - 1].dahdi_span.count.crc4 += t1in(tor, i, 3) + ((t1in(tor, i, 2) & 3) << 8); - tor->spans[i - 1].count.ebit += + tor->tspans[i - 1].dahdi_span.count.ebit += t1in(tor, i, 5) + ((t1in(tor, i, 4) & 3) << 8); } - tor->spans[i - 1].count.fas += + tor->tspans[i - 1].dahdi_span.count.fas += (t1in(tor, i, 4) >> 2) + ((t1in(tor, i, 2) & 0x3F) << 6); } else { /* add this second's BPV count to total one */ - tor->spans[i - 1].count.bpv += + tor->tspans[i - 1].dahdi_span.count.bpv += t1in(tor, i, 0x24) + (t1in(tor, i, 0x23) << 8); } @@ -1459,7 +1460,7 @@ DAHDI_IRQ_HANDLER(tor2_intr) if (tor->psyncs[0]) { /* if no alarms, use it */ - if (!(tor->spans[tor->psyncs[0] - 1].alarms & (DAHDI_ALARM_RED | DAHDI_ALARM_BLUE | + if (!(tor->tspans[tor->psyncs[0] - 1].dahdi_span.alarms & (DAHDI_ALARM_RED | DAHDI_ALARM_BLUE | DAHDI_ALARM_LOOPBACK))) { tor->syncsrc = tor->psyncs[0]; newsyncsrc = tor->syncs[0]; @@ -1470,7 +1471,7 @@ DAHDI_IRQ_HANDLER(tor2_intr) /* if we dont have one yet, and there is one specified at this level, see if we can use it */ if ((!tor->syncsrc) && (tor->psyncs[i])) { /* if no alarms, use it */ - if (!(tor->spans[tor->psyncs[i] - 1].alarms & (DAHDI_ALARM_RED | DAHDI_ALARM_BLUE | + if (!(tor->tspans[tor->psyncs[i] - 1].dahdi_span.alarms & (DAHDI_ALARM_RED | DAHDI_ALARM_BLUE | DAHDI_ALARM_LOOPBACK))) { tor->syncsrc = tor->psyncs[i]; newsyncsrc = tor->syncs[i]; @@ -1478,7 +1479,8 @@ DAHDI_IRQ_HANDLER(tor2_intr) } } /* update sync src info */ - for (i = 0; i < SPANS_PER_CARD; i++) tor->spans[i].syncsrc = newsyncsrc; + for (i = 0; i < SPANS_PER_CARD; i++) + tor->tspans[i].dahdi_span.syncsrc = newsyncsrc; /* actually set the sync register */ tor->mem8[SYNCREG] = tor->syncsrc; diff --git a/drivers/dahdi/wcb4xxp/base.c b/drivers/dahdi/wcb4xxp/base.c index 3e159bb..a4ccaf4 100644 --- a/drivers/dahdi/wcb4xxp/base.c +++ b/drivers/dahdi/wcb4xxp/base.c @@ -2088,7 +2088,7 @@ static void b4xxp_update_leds(struct b4xxp *b4) static int echocan_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp, struct dahdi_echocanparam *p, struct dahdi_echocan_state **ec) { - struct b4xxp_span *bspan = chan->span->pvt; + struct b4xxp_span *bspan = container_of(chan->span, struct b4xxp_span, span); int channel; if (chan->chanpos == 3) { @@ -2117,7 +2117,7 @@ static int echocan_create(struct dahdi_chan *chan, struct dahdi_echocanparams *e static void echocan_free(struct dahdi_chan *chan, struct dahdi_echocan_state *ec) { - struct b4xxp_span *bspan = chan->span->pvt; + struct b4xxp_span *bspan = container_of(chan->span, struct b4xxp_span, span); int channel; memset(ec, 0, sizeof(*ec)); @@ -2145,7 +2145,7 @@ static int b4xxp_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long static int b4xxp_startup(struct dahdi_span *span) { - struct b4xxp_span *bspan = span->pvt; + struct b4xxp_span *bspan = container_of(span, struct b4xxp_span, span); struct b4xxp *b4 = bspan->parent; if (!b4->running) @@ -2156,7 +2156,7 @@ static int b4xxp_startup(struct dahdi_span *span) static int b4xxp_shutdown(struct dahdi_span *span) { - struct b4xxp_span *bspan = span->pvt; + struct b4xxp_span *bspan = container_of(span, struct b4xxp_span, span); hfc_disable_interrupts(bspan->parent); return 0; @@ -2179,7 +2179,7 @@ static void b4xxp_reset_span(struct b4xxp_span *bspan) static int b4xxp_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) { int i; - struct b4xxp_span *bspan = span->pvt; + struct b4xxp_span *bspan = container_of(span, struct b4xxp_span, span); struct b4xxp *b4 = bspan->parent; if (DBG) @@ -2322,7 +2322,6 @@ static void init_spans(struct b4xxp *b4) bspan->parent = b4; bspan->span.irq = b4->pdev->irq; - bspan->span.pvt = bspan; bspan->span.spantype = (bspan->te_mode) ? "TE" : "NT"; bspan->span.offset = i; bspan->span.channels = WCB4XXP_CHANNELS_PER_SPAN; diff --git a/drivers/dahdi/wcfxo.c b/drivers/dahdi/wcfxo.c index 5e61edb..f0f4ee9 100644 --- a/drivers/dahdi/wcfxo.c +++ b/drivers/dahdi/wcfxo.c @@ -564,6 +564,11 @@ static int wcfxo_setreg(struct wcfxo *wc, unsigned char reg, unsigned char value return -1; } +static inline struct wcfxo *wcfxo_from_span(struct dahdi_span *span) +{ + return container_of(span, struct wcfxo, span); +} + static int wcfxo_open(struct dahdi_chan *chan) { struct wcfxo *wc = chan->pvt; @@ -576,7 +581,7 @@ static int wcfxo_open(struct dahdi_chan *chan) static int wcfxo_watchdog(struct dahdi_span *span, int event) { printk(KERN_INFO "FXO: Restarting DMA\n"); - wcfxo_restart_dma(span->pvt); + wcfxo_restart_dma(wcfxo_from_span(span)); return 0; } @@ -660,7 +665,6 @@ static int wcfxo_initialize(struct wcfxo *wc) #endif init_waitqueue_head(&wc->span.maintq); - wc->span.pvt = wc; wc->chan->pvt = wc; if (dahdi_register(&wc->span, 0)) { printk(KERN_NOTICE "Unable to register span with DAHDI\n"); diff --git a/drivers/dahdi/wct1xxp.c b/drivers/dahdi/wct1xxp.c index 8db70e0..30d6457 100644 --- a/drivers/dahdi/wct1xxp.c +++ b/drivers/dahdi/wct1xxp.c @@ -604,9 +604,14 @@ static int t1xxp_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long } } +static inline struct t1xxp *t1xxp_from_span(struct dahdi_span *span) +{ + return container_of(span, struct t1xxp, span); +} + static int t1xxp_startup(struct dahdi_span *span) { - struct t1xxp *wc = span->pvt; + struct t1xxp *wc = t1xxp_from_span(span); int i,alreadyrunning = span->flags & DAHDI_FLAG_RUNNING; @@ -637,7 +642,7 @@ static int t1xxp_startup(struct dahdi_span *span) static int t1xxp_shutdown(struct dahdi_span *span) { - struct t1xxp *wc = span->pvt; + struct t1xxp *wc = t1xxp_from_span(span); unsigned long flags; spin_lock_irqsave(&wc->lock, flags); @@ -652,7 +657,7 @@ static int t1xxp_shutdown(struct dahdi_span *span) static int t1xxp_maint(struct dahdi_span *span, int cmd) { - struct t1xxp *wc = span->pvt; + struct t1xxp *wc = t1xxp_from_span(span); int res = 0; unsigned long flags; spin_lock_irqsave(&wc->lock, flags); @@ -730,7 +735,7 @@ static int t1xxp_chanconfig(struct dahdi_chan *chan, int sigtype) static int t1xxp_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) { - struct t1xxp *wc = span->pvt; + struct t1xxp *wc = t1xxp_from_span(span); /* Do we want to SYNC on receive or not */ wc->sync = (lc->sync) ? 1 : 0; @@ -772,7 +777,6 @@ static int t1xxp_software_init(struct t1xxp *wc) wc->span.chans = wc->chans; wc->span.flags = DAHDI_FLAG_RBS; wc->span.ioctl = t1xxp_ioctl; - wc->span.pvt = wc; if (wc->ise1) { wc->span.channels = 31; wc->span.deflaw = DAHDI_LAW_ALAW; diff --git a/drivers/dahdi/wct4xxp/base.c b/drivers/dahdi/wct4xxp/base.c index d2a07ca..d76dffd 100644 --- a/drivers/dahdi/wct4xxp/base.c +++ b/drivers/dahdi/wct4xxp/base.c @@ -1236,7 +1236,7 @@ static int echocan_create(struct dahdi_chan *chan, struct dahdi_echocanparams *e struct dahdi_echocanparam *p, struct dahdi_echocan_state **ec) { struct t4 *wc = chan->pvt; - struct t4_span *tspan = chan->span->pvt; + struct t4_span *tspan = container_of(chan->span, struct t4_span, span); int channel; const struct dahdi_echocan_ops *ops; const struct dahdi_echocan_features *features; @@ -1434,7 +1434,7 @@ static void t4_hdlc_hard_xmit(struct dahdi_chan *chan) static int t4_maint(struct dahdi_span *span, int cmd) { - struct t4_span *ts = span->pvt; + struct t4_span *ts = container_of(span, struct t4_span, span); struct t4 *wc = ts->owner; unsigned int reg; @@ -1556,7 +1556,7 @@ static int t4_maint(struct dahdi_span *span, int cmd) static int t4_clear_maint(struct dahdi_span *span) { - struct t4_span *ts = span->pvt; + struct t4_span *ts = container_of(span, struct t4_span, span); struct t4 *wc = ts->owner; unsigned int reg; @@ -1583,7 +1583,7 @@ static int t4_clear_maint(struct dahdi_span *span) static int t4_reset_counters(struct dahdi_span *span) { - struct t4_span *ts = span->pvt; + struct t4_span *ts = container_of(span, struct t4_span, span); memset(&ts->span.count, 0, sizeof(ts->span.count)); return 0; } @@ -1647,7 +1647,7 @@ static int t4_shutdown(struct dahdi_span *span) int tspan; int wasrunning; unsigned long flags; - struct t4_span *ts = span->pvt; + struct t4_span *ts = container_of(span, struct t4_span, span); struct t4 *wc = ts->owner; tspan = span->offset + 1; @@ -1697,7 +1697,7 @@ static int t4_shutdown(struct dahdi_span *span) static int t4_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) { int i; - struct t4_span *ts = span->pvt; + struct t4_span *ts = container_of(span, struct t4_span, span); struct t4 *wc = ts->owner; printk(KERN_INFO "About to enter spanconfig!\n"); @@ -1913,7 +1913,6 @@ static void init_spans(struct t4 *wc) #endif ts->span.dacs = t4_dacs; } - ts->span.pvt = ts; ts->owner = wc; ts->span.offset = x; init_waitqueue_head(&ts->span.maintq); @@ -2374,7 +2373,7 @@ static int t4_startup(struct dahdi_span *span) int tspan; unsigned long flags; int alreadyrunning; - struct t4_span *ts = span->pvt; + struct t4_span *ts = container_of(span, struct t4_span, span); struct t4 *wc = ts->owner; set_bit(T4_IGNORE_LATENCY, &wc->checkflag); diff --git a/drivers/dahdi/wctdm.c b/drivers/dahdi/wctdm.c index 1160686..c9e4f51 100644 --- a/drivers/dahdi/wctdm.c +++ b/drivers/dahdi/wctdm.c @@ -2088,10 +2088,15 @@ static int wctdm_open(struct dahdi_chan *chan) return 0; } +static inline struct wctdm *wctdm_from_span(struct dahdi_span *span) +{ + return container_of(span, struct wctdm, span); +} + static int wctdm_watchdog(struct dahdi_span *span, int event) { printk(KERN_INFO "TDM: Restarting DMA\n"); - wctdm_restart_dma(span->pvt); + wctdm_restart_dma(wctdm_from_span(span)); return 0; } @@ -2365,7 +2370,6 @@ static int wctdm_initialize(struct wctdm *wc) wc->span.watchdog = wctdm_watchdog; init_waitqueue_head(&wc->span.maintq); - wc->span.pvt = wc; if (dahdi_register(&wc->span, 0)) { printk(KERN_NOTICE "Unable to register span with DAHDI\n"); return -1; diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index 92b5b50..99236fa 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -3312,9 +3312,15 @@ static int wctdm_open(struct dahdi_chan *chan) return 0; } +static inline struct wctdm *span_to_wctdm(struct dahdi_span *span) +{ + struct wctdm_span *s = container_of(span, struct wctdm_span, span); + return s->wc; +} + static int wctdm_watchdog(struct dahdi_span *span, int event) { - struct wctdm *wc = span->pvt; + struct wctdm *wc = span_to_wctdm(span); dev_info(&wc->vb.pdev->dev, "TDM: Called watchdog\n"); return 0; } @@ -3609,6 +3615,7 @@ static struct wctdm_span *wctdm_init_span(struct wctdm *wc, int spanno, int chan s->span.offset = spanno; s->spanno = spancount++; + s->wc = wc; /* Do not change the procfs representation for non-hx8 cards. */ if (digital_span) @@ -4787,7 +4794,6 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) return -EIO; } b4 = wc->mods[i].bri; - b400m_set_dahdi_span(b4, i & 0x03, &wc->spans[curspan]->span); ++curspan; curchan += 3; @@ -4822,7 +4828,6 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) wctdm_init_span(wc, curspan, curchan, wc->desc->ports, 0); wctdm_fixup_analog_span(wc, curspan); wc->aspan = wc->spans[curspan]; - wc->aspan->span.pvt = wc; curchan += wc->desc->ports; ++curspan; } diff --git a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h index 58b1907..beb929f 100644 --- a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h +++ b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h @@ -155,6 +155,7 @@ struct wctdm_span { struct dahdi_span span; int timing_priority; int spanno; + struct wctdm *wc; }; struct wctdm_chan { diff --git a/drivers/dahdi/wctdm24xxp/xhfc.c b/drivers/dahdi/wctdm24xxp/xhfc.c index 500cdf7..9380ed5 100644 --- a/drivers/dahdi/wctdm24xxp/xhfc.c +++ b/drivers/dahdi/wctdm24xxp/xhfc.c @@ -550,7 +550,7 @@ struct b400m_span { int fifos[B400M_CHANNELS_PER_SPAN]; /* B1, B2, D <--> host fifo numbers */ /* HDLC controller fields */ - struct dahdi_span *span; /* pointer to the actual dahdi_span */ + struct dahdi_span span; /* The actual dahdi_span */ struct dahdi_chan *sigchan; /* pointer to the signalling channel for this span */ int sigactive; /* nonzero means we're in the middle of sending an HDLC frame */ atomic_t hdlc_pending; /* hdlc_hard_xmit() increments, hdlc_tx_frame() decrements */ @@ -603,13 +603,6 @@ struct b400m { static void hfc_start_st(struct b400m_span *s); static void hfc_stop_st(struct b400m_span *s); -void b400m_set_dahdi_span(struct b400m *b4, int spanno, - struct dahdi_span *span) -{ - span->pvt = &b4->spans[spanno]; - b4->spans[spanno].span = span; -} - static inline void flush_hw(void) { } @@ -1446,11 +1439,11 @@ static void hfc_update_st_timers(struct b400m *b4) hfc_timer_expire(s, j); } - if (s->span && s->newalarm != s->span->alarms && + if (s->newalarm != s->span.alarms && time_after_eq(b4->ticks, s->alarmtimer)) { - s->span->alarms = s->newalarm; + s->span.alarms = s->newalarm; if ((!s->newalarm && bri_teignorered) || (!bri_teignorered)) - dahdi_alarm_notify(s->span); + dahdi_alarm_notify(&s->span); if (DBG_ALARM) { dev_info(&b4->wc->vb.pdev->dev, "span %d: alarm " \ @@ -1610,9 +1603,9 @@ static void hfc_reset_st(struct b400m_span *s) b400m_setreg_ra(b4, R_SU_SEL, s->port, A_SU_WR_STA, V_SU_LD_STA); flush_hw(); /* make sure write hit hardware */ - s->span->alarms = DAHDI_ALARM_RED; + s->span.alarms = DAHDI_ALARM_RED; s->newalarm = DAHDI_ALARM_RED; - dahdi_alarm_notify(s->span); + dahdi_alarm_notify(&s->span); /* set up the clock control register. Must be done before we activate * the interface. */ @@ -2060,7 +2053,7 @@ static void xhfc_init_stage2(struct b400m *b4) static int xhfc_startup(struct dahdi_span *span) { - struct b400m_span *bspan = span->pvt; + struct b400m_span *bspan = container_of(span, struct b400m_span, span); struct b400m *b4 = bspan->parent; if (!b4->running) hfc_enable_interrupts(bspan->parent); @@ -2177,7 +2170,7 @@ int b400m_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) int te_mode, term; int pos; - bspan = span->pvt; + bspan = container_of(span, struct b400m_span, span); b4 = bspan->parent; wc = b4->wc; @@ -2218,7 +2211,6 @@ int b400m_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) wc->spans[pos]->timing_priority = lc->sync; - bspan->span = span; xhfc_reset_span(bspan); /* call startup() manually here, because DAHDI won't call the startup @@ -2247,11 +2239,11 @@ int b400m_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) int b400m_chanconfig(struct dahdi_chan *chan, int sigtype) { int alreadyrunning; - struct b400m_span *bspan = chan->span->pvt; + struct b400m_span *bspan = container_of(chan->span, struct b400m_span, span); struct b400m *b4 = bspan->parent; int res; - alreadyrunning = bspan->span->flags & DAHDI_FLAG_RUNNING; + alreadyrunning = bspan->span.flags & DAHDI_FLAG_RUNNING; if (DBG_FOPS) { b4_info(b4, "%s channel %d (%s) sigtype %08x\n", @@ -2294,7 +2286,7 @@ int b400m_dchan(struct dahdi_span *span) int res; int i; - bspan = span->pvt; + bspan = container_of(span, struct b400m_span, span); b4 = bspan->parent; #ifdef HARDHDLC_RX return 0; @@ -2518,7 +2510,7 @@ void wctdm_hdlc_hard_xmit(struct dahdi_chan *chan) int span; dspan = chan->span; - bspan = dspan->pvt; + bspan = container_of(dspan, struct b400m_span, span); b4 = bspan->parent; wc = b4->wc; span = bspan->port; @@ -2719,7 +2711,7 @@ void wctdm_unload_b400m(struct wctdm *wc, int card) } for (i = 0; i < 4; i++) - b4->spans[i].span->flags &= ~DAHDI_FLAG_RUNNING; + b4->spans[i].span.flags &= ~DAHDI_FLAG_RUNNING; wctdm_change_card_sync_src(b4->wc, 0, 0); diff --git a/drivers/dahdi/wctdm24xxp/xhfc.h b/drivers/dahdi/wctdm24xxp/xhfc.h index 2699175..685809b 100644 --- a/drivers/dahdi/wctdm24xxp/xhfc.h +++ b/drivers/dahdi/wctdm24xxp/xhfc.h @@ -42,7 +42,6 @@ int b400m_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc); int b400m_dchan(struct dahdi_span *span); int b400m_chanconfig(struct dahdi_chan *chan, int sigtype); void b400m_post_init(struct b400m *b4); -void b400m_set_dahdi_span(struct b400m *b4, int spanno, struct dahdi_span *span); void b400m_module_init(void); void b400m_module_cleanup(void); diff --git a/drivers/dahdi/wcte11xp.c b/drivers/dahdi/wcte11xp.c index 16c216f..32d4f5b 100644 --- a/drivers/dahdi/wcte11xp.c +++ b/drivers/dahdi/wcte11xp.c @@ -442,9 +442,14 @@ static int t1xxp_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long return 0; } +static inline struct t1 *t1_from_span(struct dahdi_span *span) +{ + return container_of(span, struct t1, span); +} + static int t1xxp_maint(struct dahdi_span *span, int cmd) { - struct t1 *wc = span->pvt; + struct t1 *wc = t1_from_span(span); if (wc->spantype == TYPE_E1) { switch(cmd) { @@ -881,7 +886,7 @@ static void t1xxp_framer_start(struct t1 *wc, struct dahdi_span *span) static int t1xxp_startup(struct dahdi_span *span) { - struct t1 *wc = span->pvt; + struct t1 *wc = t1_from_span(span); int i,alreadyrunning = span->flags & DAHDI_FLAG_RUNNING; @@ -909,7 +914,7 @@ static int t1xxp_startup(struct dahdi_span *span) static int t1xxp_shutdown(struct dahdi_span *span) { - struct t1 *wc = span->pvt; + struct t1 *wc = t1_from_span(span); unsigned long flags; spin_lock_irqsave(&wc->lock, flags); @@ -939,7 +944,7 @@ static int t1xxp_chanconfig(struct dahdi_chan *chan, int sigtype) static int t1xxp_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) { - struct t1 *wc = span->pvt; + struct t1 *wc = t1_from_span(span); /* Do we want to SYNC on receive or not */ wc->sync = (lc->sync) ? 1 : 0; @@ -997,7 +1002,6 @@ static int t1xxp_software_init(struct t1 *wc) wc->span.chans = wc->chans; wc->span.flags = DAHDI_FLAG_RBS; wc->span.ioctl = t1xxp_ioctl; - wc->span.pvt = wc; init_waitqueue_head(&wc->span.maintq); for (x=0;xspan.channels;x++) { sprintf(wc->chans[x]->name, "WCT1/%d/%d", wc->num, x + 1); diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index 9f93954..cbb1b04 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -958,7 +958,7 @@ static void set_span_devicetype(struct t1 *wc) static int t1xxp_startup(struct dahdi_span *span) { - struct t1 *wc = span->pvt; + struct t1 *wc = container_of(span, struct t1, span); int i; check_and_load_vpm(wc); @@ -979,7 +979,7 @@ static int t1xxp_startup(struct dahdi_span *span) static int t1xxp_shutdown(struct dahdi_span *span) { - struct t1 *wc = span->pvt; + struct t1 *wc = container_of(span, struct t1, span); t1_setreg(wc, 0x46, 0x41); /* GCR: Interrupt on Activation/Deactivation of AIX, LOS */ clear_bit(DAHDI_FLAGBIT_RUNNING, &span->flags); return 0; @@ -1227,7 +1227,7 @@ cleanup: static int t1xxp_maint(struct dahdi_span *span, int cmd) { struct maint_work_struct *work; - struct t1 *wc = span->pvt; + struct t1 *wc = container_of(span, struct t1, span); if (wc->spantype == TYPE_E1) { switch (cmd) { @@ -1282,7 +1282,7 @@ static int t1xxp_maint(struct dahdi_span *span, int cmd) static int t1xxp_clear_maint(struct dahdi_span *span) { - struct t1 *wc = span->pvt; + struct t1 *wc = container_of(span, struct t1, span); int reg = 0; /* Turn off local loop */ @@ -1488,7 +1488,7 @@ static inline int check_and_load_vpm(const struct t1 *wc) static int t1xxp_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) { - struct t1 *wc = span->pvt; + struct t1 *wc = container_of(span, struct t1, span); /* Do we want to SYNC on receive or not */ if (lc->sync) { @@ -1568,7 +1568,6 @@ static int t1_software_init(struct t1 *wc) } wc->span.chans = wc->chans; set_bit(DAHDI_FLAGBIT_RBS, &wc->span.flags); - wc->span.pvt = wc; init_waitqueue_head(&wc->span.maintq); for (x = 0; x < wc->span.channels; x++) { sprintf(wc->chans[x]->name, "WCT1/%d/%d", num, x + 1); diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c index 7d3e652..b390bf7 100644 --- a/drivers/dahdi/xpp/card_bri.c +++ b/drivers/dahdi/xpp/card_bri.c @@ -1171,7 +1171,7 @@ static int BRI_card_close(xpd_t *xpd, lineno_t pos) */ static int bri_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) { - xpd_t *xpd = span->pvt; + xpd_t *xpd = container_of(span, struct xpd, span); const char *framingstr = ""; const char *codingstr = ""; const char *crcstr = ""; @@ -1227,7 +1227,7 @@ static int bri_chanconfig(struct dahdi_chan *chan, int sigtype) */ static int bri_startup(struct dahdi_span *span) { - xpd_t *xpd = span->pvt; + xpd_t *xpd = container_of(span, struct xpd, span); struct BRI_priv_data *priv; struct dahdi_chan *dchan; @@ -1263,7 +1263,7 @@ static int bri_startup(struct dahdi_span *span) */ static int bri_shutdown(struct dahdi_span *span) { - xpd_t *xpd = span->pvt; + xpd_t *xpd = container_of(span, struct xpd, span); struct BRI_priv_data *priv; BUG_ON(!xpd); diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c index c869fd8..53cd8d5 100644 --- a/drivers/dahdi/xpp/card_pri.c +++ b/drivers/dahdi/xpp/card_pri.c @@ -1093,7 +1093,7 @@ bad_lineconfig: static int pri_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) { - xpd_t *xpd = span->pvt; + xpd_t *xpd = container_of(span, struct xpd, span); struct PRI_priv_data *priv; int ret; @@ -1127,10 +1127,9 @@ static int pri_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) */ static int pri_chanconfig(struct dahdi_chan *chan, int sigtype) { - xpd_t *xpd; + xpd_t *xpd = container_of(chan->span, struct xpd, span); struct PRI_priv_data *priv; - xpd = chan->span->pvt; BUG_ON(!xpd); priv = xpd->priv; DBG(GENERAL, "channel %d (%s) -> %s\n", chan->channo, chan->name, sig2str(sigtype)); @@ -1510,7 +1509,7 @@ static int PRI_card_close(xpd_t *xpd, lineno_t pos) */ static int pri_startup(struct dahdi_span *span) { - xpd_t *xpd = span->pvt; + xpd_t *xpd = container_of(span, struct xpd, span); struct PRI_priv_data *priv; BUG_ON(!xpd); @@ -1533,7 +1532,7 @@ static int pri_startup(struct dahdi_span *span) */ static int pri_shutdown(struct dahdi_span *span) { - xpd_t *xpd = span->pvt; + xpd_t *xpd = container_of(span, struct xpd, span); struct PRI_priv_data *priv; BUG_ON(!xpd); diff --git a/drivers/dahdi/xpp/xbus-pcm.c b/drivers/dahdi/xpp/xbus-pcm.c index ce5c0fa..39b772b 100644 --- a/drivers/dahdi/xpp/xbus-pcm.c +++ b/drivers/dahdi/xpp/xbus-pcm.c @@ -496,7 +496,7 @@ static void global_tick(void) #ifdef DAHDI_SYNC_TICK int dahdi_sync_tick(struct dahdi_span *span, int is_master) { - xpd_t *xpd = span->pvt; + xpd_t *xpd = container_of(span, struct xpd, span); static int redundant_ticks; /* for extra spans */ struct timeval now; diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c index 72b514e..ebabdcc 100644 --- a/drivers/dahdi/xpp/xpp_dahdi.c +++ b/drivers/dahdi/xpp/xpp_dahdi.c @@ -974,7 +974,7 @@ int xpp_setchunksize(struct dahdi_span *span, int chunksize); /* Enable maintenance modes */ int xpp_maint(struct dahdi_span *span, int cmd) { - xpd_t *xpd = span->pvt; + xpd_t *xpd = container_of(span, struct xpd, span); int ret = 0; #if 0 char loopback_data[] = "THE-QUICK-BROWN-FOX-JUMPED-OVER-THE-LAZY-DOG"; @@ -1096,7 +1096,6 @@ int dahdi_register_xpd(xpd_t *xpd) snprintf(span->name, MAX_SPANNAME, "%s/%s", xbus->busname, xpd->xpdname); span->deflaw = DAHDI_LAW_MULAW; /* default, may be overriden by card_* drivers */ init_waitqueue_head(&span->maintq); - span->pvt = xpd; span->channels = cn; span->chans = xpd->chans; diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index 237e1db..ab2551b 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -753,7 +753,6 @@ struct dahdi_count { struct dahdi_span { spinlock_t lock; struct module *owner; /*!< Which module is exporting this span. */ - void *pvt; /*!< Private stuff */ char name[40]; /*!< Span name */ char desc[80]; /*!< Span description */ const char *spantype; /*!< span type in text form */ -- cgit v1.2.3