dahdi_dummy: Fix compilation since dahdi-linux 2.6.0.
Even though dahdi_dummy is no longer built by default, the adoption of dahdi_devices in 2.6 broke the ability to compile. This was not intended as there are some packagers who still patch the Kbuild file to enable dahdi_dummy. Internal-Issue-ID: DAHLIN-274 Signed-off-by: Shaun Ruffell <sruffell@digium.com> Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10486 git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10526 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
parent
6e1058eae0
commit
2b2054f28b
@ -75,6 +75,7 @@ static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct dahdi_dummy {
|
struct dahdi_dummy {
|
||||||
|
struct dahdi_device *ddev;
|
||||||
struct dahdi_span span;
|
struct dahdi_span span;
|
||||||
struct dahdi_chan _chan;
|
struct dahdi_chan _chan;
|
||||||
struct dahdi_chan *chan;
|
struct dahdi_chan *chan;
|
||||||
@ -205,37 +206,44 @@ static const struct dahdi_span_ops dummy_ops = {
|
|||||||
|
|
||||||
static int dahdi_dummy_initialize(struct dahdi_dummy *ztd)
|
static int dahdi_dummy_initialize(struct dahdi_dummy *ztd)
|
||||||
{
|
{
|
||||||
|
int res = 0;
|
||||||
/* DAHDI stuff */
|
/* DAHDI stuff */
|
||||||
|
ztd->ddev = dahdi_create_device();
|
||||||
|
if (!ztd->ddev)
|
||||||
|
return -ENOMEM;
|
||||||
|
dev_set_name(&ztd->ddev->dev, "dahdi_dummy");
|
||||||
ztd->chan = &ztd->_chan;
|
ztd->chan = &ztd->_chan;
|
||||||
sprintf(ztd->span.name, "DAHDI_DUMMY/1");
|
sprintf(ztd->span.name, "DAHDI_DUMMY/1");
|
||||||
snprintf(ztd->span.desc, sizeof(ztd->span.desc) - 1, "%s (source: " CLOCK_SRC ") %d", ztd->span.name, 1);
|
snprintf(ztd->span.desc, sizeof(ztd->span.desc) - 1, "%s (source: " CLOCK_SRC ") %d", ztd->span.name, 1);
|
||||||
sprintf(ztd->chan->name, "DAHDI_DUMMY/%d/%d", 1, 0);
|
sprintf(ztd->chan->name, "DAHDI_DUMMY/%d/%d", 1, 0);
|
||||||
strlcpy(ztd->span.devicetype, "DAHDI Dummy Timing",
|
ztd->ddev->devicetype = "DAHDI Dummy Timing";
|
||||||
sizeof(ztd->span.devicetype));
|
|
||||||
ztd->chan->chanpos = 1;
|
ztd->chan->chanpos = 1;
|
||||||
ztd->span.chans = &ztd->chan;
|
ztd->span.chans = &ztd->chan;
|
||||||
ztd->span.channels = 0; /* no channels on our span */
|
ztd->span.channels = 0; /* no channels on our span */
|
||||||
ztd->span.deflaw = DAHDI_LAW_MULAW;
|
ztd->span.deflaw = DAHDI_LAW_MULAW;
|
||||||
ztd->chan->pvt = ztd;
|
ztd->chan->pvt = ztd;
|
||||||
ztd->span.ops = &dummy_ops;
|
ztd->span.ops = &dummy_ops;
|
||||||
if (dahdi_register(&ztd->span, 0)) {
|
list_add_tail(&ztd->span.device_node, &ztd->ddev->spans);
|
||||||
return -1;
|
res = dahdi_register_device(ztd->ddev, NULL);
|
||||||
}
|
return res;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_module(void)
|
int init_module(void)
|
||||||
{
|
{
|
||||||
|
int res;
|
||||||
ztd = kzalloc(sizeof(*ztd), GFP_KERNEL);
|
ztd = kzalloc(sizeof(*ztd), GFP_KERNEL);
|
||||||
if (ztd == NULL) {
|
if (ztd == NULL) {
|
||||||
printk(KERN_ERR "dahdi_dummy: Unable to allocate memory\n");
|
printk(KERN_ERR "dahdi_dummy: Unable to allocate memory\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dahdi_dummy_initialize(ztd)) {
|
res = dahdi_dummy_initialize(ztd);
|
||||||
printk(KERN_ERR "dahdi_dummy: Unable to intialize DAHDI driver\n");
|
if (res) {
|
||||||
|
printk(KERN_ERR
|
||||||
|
"dahdi_dummy: Unable to intialize DAHDI driver (%d)\n",
|
||||||
|
res);
|
||||||
kfree(ztd);
|
kfree(ztd);
|
||||||
return -ENODEV;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_HIGHRESTIMER)
|
#if defined(USE_HIGHRESTIMER)
|
||||||
@ -273,7 +281,8 @@ void cleanup_module(void)
|
|||||||
atomic_set(&shutdown, 1);
|
atomic_set(&shutdown, 1);
|
||||||
del_timer_sync(&timer);
|
del_timer_sync(&timer);
|
||||||
#endif
|
#endif
|
||||||
dahdi_unregister(&ztd->span);
|
dahdi_unregister_device(ztd->ddev);
|
||||||
|
dahdi_free_device(ztd->ddev);
|
||||||
kfree(ztd);
|
kfree(ztd);
|
||||||
if (debug)
|
if (debug)
|
||||||
printk(KERN_DEBUG "dahdi_dummy: cleanup() finished\n");
|
printk(KERN_DEBUG "dahdi_dummy: cleanup() finished\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user