diff options
author | Shaun Ruffell <sruffell@digium.com> | 2010-07-26 00:30:43 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2010-07-26 00:30:43 +0000 |
commit | b764ebded8f543d62e1a19463db7c2926b9b22e0 (patch) | |
tree | 60e0b36a1f89a6339bd3a357420c1f1152224a2a | |
parent | 113b9311ebca9311befbd017eb27f6a25949e6a6 (diff) |
dahdi: Move the 'owner' field from dahdi_span to dahdi_span_ops.
One more thing that can be moved out of the per-span structure.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8986 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r-- | drivers/dahdi/dahdi-base.c | 11 | ||||
-rw-r--r-- | drivers/dahdi/dahdi_dummy.c | 6 | ||||
-rw-r--r-- | drivers/dahdi/dahdi_dynamic.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/pciradio.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/tor2.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/wcb4xxp/base.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/wcfxo.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/wct1xxp.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/wct4xxp/base.c | 3 | ||||
-rw-r--r-- | drivers/dahdi/wctdm.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/wctdm24xxp/base.c | 3 | ||||
-rw-r--r-- | drivers/dahdi/wcte11xp.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/wcte12xp/base.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/xpp/card_bri.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/xpp/card_fxo.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/xpp/card_fxs.c | 1 | ||||
-rw-r--r-- | drivers/dahdi/xpp/card_pri.c | 2 | ||||
-rw-r--r-- | drivers/dahdi/xpp/xpp_dahdi.c | 6 | ||||
-rw-r--r-- | include/dahdi/kernel.h | 3 |
19 files changed, 32 insertions, 25 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 32f60ce..f3a677c 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -2734,7 +2734,7 @@ static int dahdi_specchan_open(struct file *file, int unit) if (chan->flags & DAHDI_FLAG_PSEUDO) chan->flags |= DAHDI_FLAG_AUDIO; if (chan->span) { - if (!try_module_get(chan->span->owner)) + if (!try_module_get(chan->span->ops->owner)) res = -ENXIO; else if (chan->span->ops->open) res = chan->span->ops->open(chan); @@ -2771,7 +2771,7 @@ static int dahdi_specchan_release(struct file *file, int unit) if (chan->span) { if (chan->span->ops->close) res = chan->span->ops->close(chan); - module_put(chan->span->owner); + module_put(chan->span->ops->owner); } /* The channel might be destroyed by low-level driver span->close() */ if (chans[unit]) @@ -5877,7 +5877,12 @@ int dahdi_register(struct dahdi_span *span, int prefmaster) if (!span) return -EINVAL; - WARN_ON(!span->owner); + if (!span->ops) + return -EINVAL; + + if (!span->ops->owner) + return -EINVAL; + if (test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags)) { module_printk(KERN_ERR, "Span %s already appears to be registered\n", span->name); diff --git a/drivers/dahdi/dahdi_dummy.c b/drivers/dahdi/dahdi_dummy.c index f50996a..e7055db 100644 --- a/drivers/dahdi/dahdi_dummy.c +++ b/drivers/dahdi/dahdi_dummy.c @@ -199,6 +199,10 @@ static void dahdi_dummy_timer(unsigned long param) } #endif +static const struct dahdi_span_ops dummy_ops = { + .owner = THIS_MODULE, +}; + static int dahdi_dummy_initialize(struct dahdi_dummy *ztd) { /* DAHDI stuff */ @@ -208,12 +212,12 @@ static int dahdi_dummy_initialize(struct dahdi_dummy *ztd) sprintf(ztd->chan->name, "DAHDI_DUMMY/%d/%d", 1, 0); dahdi_copy_string(ztd->span.devicetype, "DAHDI Dummy Timing", sizeof(ztd->span.devicetype)); ztd->chan->chanpos = 1; - ztd->span.owner = THIS_MODULE; ztd->span.chans = &ztd->chan; ztd->span.channels = 0; /* no channels on our span */ ztd->span.deflaw = DAHDI_LAW_MULAW; init_waitqueue_head(&ztd->span.maintq); ztd->chan->pvt = ztd; + ztd->span.ops = &dummy_ops; if (dahdi_register(&ztd->span, 0)) { return -1; } diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c index 6a5bab5..31a6c30 100644 --- a/drivers/dahdi/dahdi_dynamic.c +++ b/drivers/dahdi/dahdi_dynamic.c @@ -528,6 +528,7 @@ static int ztd_close(struct dahdi_chan *chan) } static const struct dahdi_span_ops dynamic_ops = { + .owner = THIS_MODULE, .rbsbits = ztd_rbsbits, .open = ztd_open, .close = ztd_close, @@ -592,7 +593,6 @@ static int create_dynamic(struct dahdi_dynamic_span *zds) z->timing = zds->timing; sprintf(z->span.name, "DYN/%s/%s", zds->driver, zds->addr); 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.deflaw = DAHDI_LAW_MULAW; z->span.flags |= DAHDI_FLAG_RBS; diff --git a/drivers/dahdi/pciradio.c b/drivers/dahdi/pciradio.c index b6e885f..3d69e5a 100644 --- a/drivers/dahdi/pciradio.c +++ b/drivers/dahdi/pciradio.c @@ -1459,6 +1459,7 @@ static int pciradio_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig) } static const struct dahdi_span_ops pciradio_span_ops = { + .owner = THIS_MODULE, .hooksig = pciradio_hooksig, .open = pciradio_open, .close = pciradio_close, @@ -1471,7 +1472,6 @@ static int pciradio_initialize(struct pciradio *rad) int x; /* DAHDI stuff */ - rad->span.owner = THIS_MODULE; sprintf(rad->span.name, "PCIRADIO/%d", rad->pos); sprintf(rad->span.desc, "Board %d", rad->pos + 1); rad->span.deflaw = DAHDI_LAW_MULAW; diff --git a/drivers/dahdi/tor2.c b/drivers/dahdi/tor2.c index 633369c..b859708 100644 --- a/drivers/dahdi/tor2.c +++ b/drivers/dahdi/tor2.c @@ -260,6 +260,7 @@ static int tor2_close(struct dahdi_chan *chan) } static const struct dahdi_span_ops tor2_span_ops = { + .owner = THIS_MODULE, .spanconfig = tor2_spanconfig, .chanconfig = tor2_chanconfig, .startup = tor2_startup, @@ -285,7 +286,6 @@ static void init_spans(struct tor2 *tor) 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); - s->owner = THIS_MODULE; if (tor->cardtype == TYPE_T1) { s->channels = 24; s->deflaw = DAHDI_LAW_MULAW; diff --git a/drivers/dahdi/wcb4xxp/base.c b/drivers/dahdi/wcb4xxp/base.c index fd916dc..25a8a15 100644 --- a/drivers/dahdi/wcb4xxp/base.c +++ b/drivers/dahdi/wcb4xxp/base.c @@ -2313,6 +2313,7 @@ static void b4xxp_hdlc_hard_xmit(struct dahdi_chan *chan) /* internal functions, not specific to the hardware or DAHDI */ static const struct dahdi_span_ops b4xxp_span_ops = { + .owner = THIS_MODULE, .spanconfig = b4xxp_spanconfig, .chanconfig = b4xxp_chanconfig, .startup = b4xxp_startup, @@ -2360,7 +2361,6 @@ static void init_spans(struct b4xxp *b4) sprintf(bspan->span.location, "PCI Bus %02d Slot %02d", b4->pdev->bus->number, PCI_SLOT(b4->pdev->devfn) + 1); - bspan->span.owner = THIS_MODULE; bspan->span.ops = &b4xxp_span_ops; /* HDLC stuff */ bspan->sigchan = NULL; diff --git a/drivers/dahdi/wcfxo.c b/drivers/dahdi/wcfxo.c index bf495d7..7893c87 100644 --- a/drivers/dahdi/wcfxo.c +++ b/drivers/dahdi/wcfxo.c @@ -639,6 +639,7 @@ static int wcfxo_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig) } static const struct dahdi_span_ops wcfxo_span_ops = { + .owner = THIS_MODULE, .hooksig = wcfxo_hooksig, .open = wcfxo_open, .close = wcfxo_close, @@ -648,7 +649,6 @@ static const struct dahdi_span_ops wcfxo_span_ops = { static int wcfxo_initialize(struct wcfxo *wc) { /* DAHDI stuff */ - wc->span.owner = THIS_MODULE; sprintf(wc->span.name, "WCFXO/%d", wc->pos); snprintf(wc->span.desc, sizeof(wc->span.desc) - 1, "%s Board %d", wc->variety, wc->pos + 1); sprintf(wc->chan->name, "WCFXO/%d/%d", wc->pos, 0); diff --git a/drivers/dahdi/wct1xxp.c b/drivers/dahdi/wct1xxp.c index 80392c8..76b038f 100644 --- a/drivers/dahdi/wct1xxp.c +++ b/drivers/dahdi/wct1xxp.c @@ -747,6 +747,7 @@ static int t1xxp_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc } static const struct dahdi_span_ops t1xxp_span_ops = { + .owner = THIS_MODULE, .spanconfig = t1xxp_spanconfig, .chanconfig = t1xxp_chanconfig, .startup = t1xxp_startup, @@ -777,7 +778,6 @@ static int t1xxp_software_init(struct t1xxp *wc) dahdi_copy_string(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype)); snprintf(wc->span.location, sizeof(wc->span.location) - 1, "PCI Bus %02d Slot %02d", wc->dev->bus->number, PCI_SLOT(wc->dev->devfn) + 1); - wc->span.owner = THIS_MODULE; wc->span.irq = wc->dev->irq; wc->span.chans = wc->chans; wc->span.flags = DAHDI_FLAG_RBS; diff --git a/drivers/dahdi/wct4xxp/base.c b/drivers/dahdi/wct4xxp/base.c index a0564a9..77ef562 100644 --- a/drivers/dahdi/wct4xxp/base.c +++ b/drivers/dahdi/wct4xxp/base.c @@ -1847,6 +1847,7 @@ void setup_chunks(struct t4 *wc, int which) } static const struct dahdi_span_ops t4_gen1_span_ops = { + .owner = THIS_MODULE, .spanconfig = t4_spanconfig, .chanconfig = t4_chanconfig, .startup = t4_startup, @@ -1860,6 +1861,7 @@ static const struct dahdi_span_ops t4_gen1_span_ops = { }; static const struct dahdi_span_ops t4_gen2_span_ops = { + .owner = THIS_MODULE, .spanconfig = t4_spanconfig, .chanconfig = t4_chanconfig, .startup = t4_startup, @@ -1907,7 +1909,6 @@ static void init_spans(struct t4 *wc) ts->span.spantype = "J1"; break; } - ts->span.owner = THIS_MODULE; ts->span.irq = wc->dev->irq; /* HDLC Specific init */ diff --git a/drivers/dahdi/wctdm.c b/drivers/dahdi/wctdm.c index f533726..9f4d1ea 100644 --- a/drivers/dahdi/wctdm.c +++ b/drivers/dahdi/wctdm.c @@ -2335,6 +2335,7 @@ static int wctdm_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig) } static const struct dahdi_span_ops wctdm_span_ops = { + .owner = THIS_MODULE, .hooksig = wctdm_hooksig, .open = wctdm_open, .close = wctdm_close, @@ -2366,7 +2367,6 @@ static int wctdm_initialize(struct wctdm *wc) wc->chans[x]->chanpos = x+1; wc->chans[x]->pvt = wc; } - wc->span.owner = THIS_MODULE; wc->span.chans = wc->chans; wc->span.channels = NUM_CARDS; wc->span.irq = wc->dev->irq; diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index 1390176..eea2121 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -3559,6 +3559,7 @@ static int wctdm_dacs(struct dahdi_chan *dst, struct dahdi_chan *src) } static const struct dahdi_span_ops wctdm24xxp_analog_span_ops = { + .owner = THIS_MODULE, .hooksig = wctdm_hooksig, .open = wctdm_open, .close = wctdm_close, @@ -3571,6 +3572,7 @@ static const struct dahdi_span_ops wctdm24xxp_analog_span_ops = { }; static const struct dahdi_span_ops wctdm24xxp_digital_span_ops = { + .owner = THIS_MODULE, .open = wctdm_open, .close = wctdm_close, .ioctl = wctdm_ioctl, @@ -3641,7 +3643,6 @@ static struct wctdm_span *wctdm_init_span(struct wctdm *wc, int spanno, int chan return NULL; /* DAHDI stuff */ - s->span.owner = THIS_MODULE; s->span.offset = spanno; s->spanno = spancount++; diff --git a/drivers/dahdi/wcte11xp.c b/drivers/dahdi/wcte11xp.c index ec73cbf..10d2a9a 100644 --- a/drivers/dahdi/wcte11xp.c +++ b/drivers/dahdi/wcte11xp.c @@ -956,6 +956,7 @@ static int t1xxp_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc } static const struct dahdi_span_ops t1xxp_span_ops = { + .owner = THIS_MODULE, .startup = t1xxp_startup, .shutdown = t1xxp_shutdown, .rbsbits = t1xxp_rbsbits, @@ -981,7 +982,6 @@ static int t1xxp_software_init(struct t1 *wc) return -1; t4_serial_setup(wc); wc->num = x; - wc->span.owner = THIS_MODULE; sprintf(wc->span.name, "WCT1/%d", wc->num); snprintf(wc->span.desc, sizeof(wc->span.desc) - 1, "%s Card %d", wc->variety, wc->num); wc->span.manufacturer = "Digium"; diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index 3c58b64..2dd882d 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -1507,6 +1507,7 @@ t1xxp_spanconfig(struct dahdi_span *span, struct dahdi_lineconfig *lc) } static const struct dahdi_span_ops t1_span_ops = { + .owner = THIS_MODULE, .spanconfig = t1xxp_spanconfig, .chanconfig = t1xxp_chanconfig, .startup = t1xxp_startup, @@ -1550,7 +1551,6 @@ static int t1_software_init(struct t1 *wc) "PCI Bus %02d Slot %02d", pdev->bus->number, PCI_SLOT(pdev->devfn) + 1); - wc->span.owner = THIS_MODULE; wc->span.irq = pdev->irq; if (wc->spantype == TYPE_E1) { diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c index e15f064..39fe907 100644 --- a/drivers/dahdi/xpp/card_bri.c +++ b/drivers/dahdi/xpp/card_bri.c @@ -862,6 +862,7 @@ static int BRI_card_remove(xbus_t *xbus, xpd_t *xpd) } static const struct dahdi_span_ops BRI_span_ops = { + .owner = THIS_MODULE, .spanconfig = bri_spanconfig, .chanconfig = bri_chanconfig, .startup = bri_startup, @@ -897,7 +898,6 @@ static int BRI_card_dahdi_preregistration(xpd_t *xpd, bool on) /* Nothing to do yet */ return 0; } - xpd->span.owner = THIS_MODULE; xpd->span.spantype = "BRI"; xpd->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_CCS; xpd->span.deflaw = DAHDI_LAW_ALAW; diff --git a/drivers/dahdi/xpp/card_fxo.c b/drivers/dahdi/xpp/card_fxo.c index 474e217..596cbc0 100644 --- a/drivers/dahdi/xpp/card_fxo.c +++ b/drivers/dahdi/xpp/card_fxo.c @@ -511,8 +511,6 @@ static int FXO_card_dahdi_preregistration(xpd_t *xpd, bool on) BUG_ON(!priv); timer_count = xpd->timer_count; XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF"); - xpd->span.owner = THIS_MODULE; - xpd->span.spantype = "FXO"; for_each_line(xpd, i) { struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i); diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c index cbafab0..050833e 100644 --- a/drivers/dahdi/xpp/card_fxs.c +++ b/drivers/dahdi/xpp/card_fxs.c @@ -496,7 +496,6 @@ static int FXS_card_dahdi_preregistration(xpd_t *xpd, bool on) priv = xpd->priv; BUG_ON(!priv); XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off"); - xpd->span.owner = THIS_MODULE; xpd->span.spantype = "FXS"; for_each_line(xpd, i) { struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i); diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c index 1003188..b84ddf7 100644 --- a/drivers/dahdi/xpp/card_pri.c +++ b/drivers/dahdi/xpp/card_pri.c @@ -1274,6 +1274,7 @@ static int pri_audio_notify(struct dahdi_chan *chan, int on) #endif static const struct dahdi_span_ops PRI_span_ops = { + .owner = THIS_MODULE, .spanconfig = pri_spanconfig, .chanconfig = pri_chanconfig, .startup = pri_startup, @@ -1315,7 +1316,6 @@ static int PRI_card_dahdi_preregistration(xpd_t *xpd, bool on) /* Nothing to do yet */ return 0; } - xpd->span.owner = THIS_MODULE; xpd->span.spantype = pri_protocol_name(priv->pri_protocol); xpd->span.linecompat = pri_linecompat(priv->pri_protocol); xpd->span.deflaw = priv->deflaw; diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c index 82157f6..6bc0663 100644 --- a/drivers/dahdi/xpp/xpp_dahdi.c +++ b/drivers/dahdi/xpp/xpp_dahdi.c @@ -1070,6 +1070,7 @@ int dahdi_unregister_xpd(xpd_t *xpd) } static const struct dahdi_span_ops xpp_span_ops = { + .owner = THIS_MODULE, .open = xpp_open, .close = xpp_close, .ioctl = xpp_ioctl, @@ -1077,6 +1078,7 @@ static const struct dahdi_span_ops xpp_span_ops = { }; static const struct dahdi_span_ops xpp_rbs_span_ops = { + .owner = THIS_MODULE, .hooksig = xpp_hooksig, .open = xpp_open, .close = xpp_close, @@ -1158,10 +1160,6 @@ int dahdi_register_xpd(xpd_t *xpd) xbus->num, xpd->addr.unit, xpd->addr.subunit, xpd->type_name); XPD_DBG(GENERAL, xpd, "Registering span '%s'\n", xpd->span.desc); xpd->xops->card_dahdi_preregistration(xpd, 1); - if(!xpd->span.owner) { - XPD_ERR(xpd, "NO span.owner field -- bug in low-level driver\n"); - WARN_ON(!xpd->span.owner); - } if(dahdi_register(&xpd->span, prefmaster)) { XPD_ERR(xpd, "Failed to dahdi_register span\n"); return -ENODEV; diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index 4c17bfa..a33ca18 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -751,6 +751,8 @@ struct dahdi_count { #define DAHDI_FLAG_HDLC56 DAHDI_FLAG(HDLC56) struct dahdi_span_ops { + struct module *owner; /*!< Which module is exporting this span. */ + /* ==== Span Callback Operations ==== */ /*! Req: Set the requested chunk size. This is the unit in which you must report results for conferencing, etc */ @@ -829,7 +831,6 @@ struct dahdi_span_ops { struct dahdi_span { spinlock_t lock; - struct module *owner; /*!< Which module is exporting this span. */ char name[40]; /*!< Span name */ char desc[80]; /*!< Span description */ const char *spantype; /*!< span type in text form */ |