From df441417d15b5a596f8a0f11a49c4a53da4d056e Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Fri, 16 Mar 2012 14:00:19 -0500 Subject: [PATCH 3/4] dahdi_dynamic: Since dynamic devices are 'parentless' we must name them. This in conjunction with r10449 "A parent-less device should not crash dahdi", this allows dahdi_dynamic spans to work post the dahdi_devices changes in 2.6.0. The full address of the device is not used since kernels prior to 2.6.31 limit the length of a devicename to 20 characters. This is a patch to just get things working again. dahdi_dynamic devices *may* still have issues if the auto_assign_spans module parameter is 0. Internal-Issue-ID: DAHLIN-280 Reported-by: Pavel Selivanov Signed-off-by: Shaun Ruffell --- drivers/dahdi/dahdi_dynamic.c | 10 +++++++--- include/dahdi/kernel.h | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c index d896580..7ca34e3 100644 --- a/drivers/dahdi/dahdi_dynamic.c +++ b/drivers/dahdi/dahdi_dynamic.c @@ -600,9 +600,10 @@ static int _create_dynamic(struct dahdi_dynamic_span *dds) strlcpy(d->dname, dds->driver, sizeof(d->dname)); strlcpy(d->addr, dds->addr, sizeof(d->addr)); d->timing = dds->timing; - sprintf(d->span.name, "DYN/%s/%s", dds->driver, dds->addr); - sprintf(d->span.desc, "Dynamic '%s' span at '%s'", - dds->driver, dds->addr); + snprintf(d->span.name, sizeof(d->span.name), "DYN/%s/%s", + dds->driver, dds->addr); + snprintf(d->span.desc, sizeof(d->span.desc), + "Dynamic '%s' span at '%s'", dds->driver, dds->addr); d->span.deflaw = DAHDI_LAW_MULAW; d->span.flags |= DAHDI_FLAG_RBS; d->span.chans = d->chans; @@ -653,6 +654,9 @@ static int _create_dynamic(struct dahdi_dynamic_span *dds) return res; } + d->ddev->devicetype = d->span.name; + d->ddev->hardware_id = d->span.name; + dev_set_name(&d->ddev->dev, "dynamic:%s:%d", dds->driver, dtd->count++); list_add_tail(&d->span.device_node, &d->ddev->spans); /* Whee! We're created. Now register the span */ if (dahdi_register_device(d->ddev, d->dev)) { diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index 6f397c1..805c62e 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -1096,6 +1096,9 @@ struct dahdi_dynamic_driver { struct list_head list; struct module *owner; + + /*! Count of devices created with this driver. */ + unsigned int count; }; /*! \brief Receive a dynamic span message */ -- 1.7.9.GIT