summaryrefslogtreecommitdiff
path: root/drivers/dahdi/dahdi_dynamic.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2008-08-20 22:20:46 +0000
committerKevin P. Fleming <kpfleming@digium.com>2008-08-20 22:20:46 +0000
commitd2dc50fa62b6cb6c806abb9dc43662901034c4a7 (patch)
treec92f35daa7ca842499892a3811baeeba31087809 /drivers/dahdi/dahdi_dynamic.c
parentfae982562ae1490e085e40573a2b4b1b5f219dad (diff)
use the new separate allocation method for channel structures here too
replace "ZTD" references in channel/span names with "DYN" (closes issue #13302) Reported by: KNK git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@4805 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/dahdi_dynamic.c')
-rw-r--r--drivers/dahdi/dahdi_dynamic.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c
index f8d85d6..c1f09eb 100644
--- a/drivers/dahdi/dahdi_dynamic.c
+++ b/drivers/dahdi/dahdi_dynamic.c
@@ -102,7 +102,7 @@ static struct dahdi_dynamic {
unsigned short txcnt;
unsigned short rxcnt;
struct dahdi_span span;
- struct dahdi_chan **chans;
+ struct dahdi_chan *chans[DAHDI_DYNAMIC_MAX_CHANS];
struct dahdi_dynamic *next;
struct dahdi_dynamic_driver *driver;
void *pvt;
@@ -411,6 +411,8 @@ void dahdi_dynamic_receive(struct dahdi_span *span, unsigned char *msg, int msgl
static void dynamic_destroy(struct dahdi_dynamic *z)
{
+ unsigned int x;
+
/* Unregister span if appropriate */
if (z->span.flags & DAHDI_FLAG_REGISTERED)
dahdi_unregister(&z->span);
@@ -424,8 +426,10 @@ static void dynamic_destroy(struct dahdi_dynamic *z)
kfree(z->msgbuf);
/* Free channels */
- if (z->chans)
- vfree(z->chans);
+ for (x = 0; x < z->span.channels; x++) {
+ kfree(z->chans[x]);
+ }
+
/* Free z */
kfree(z);
@@ -563,22 +567,21 @@ static int create_dynamic(struct dahdi_dynamic_span *zds)
/* Allocate memory */
- z = (struct dahdi_dynamic *)kmalloc(sizeof(struct dahdi_dynamic), GFP_KERNEL);
- if (!z)
+ if (!(z = kmalloc(sizeof(*z), GFP_KERNEL))) {
return -ENOMEM;
+ }
/* Zero it out */
- memset(z, 0, sizeof(struct dahdi_dynamic));
+ memset(z, 0, sizeof(*z));
- /* Allocate other memories */
- z->chans = vmalloc(sizeof(struct dahdi_chan) * zds->numchans);
- if (!z->chans) {
- dynamic_destroy(z);
- return -ENOMEM;
- }
+ for (x = 0; x < zds->numchans; x++) {
+ if (!(z->chans[x] = kmalloc(sizeof(*z->chans[x]), GFP_KERNEL))) {
+ dynamic_destroy(z);
+ return -ENOMEM;
+ }
- /* Zero out channel stuff */
- memset(z->chans, 0, sizeof(struct dahdi_chan) * zds->numchans);
+ memset(z->chans[x], 0, sizeof(*z->chans[x]));
+ }
/* Allocate message buffer with sample space and header space */
bufsize = zds->numchans * DAHDI_CHUNKSIZE + zds->numchans / 4 + 48;
@@ -597,7 +600,7 @@ static int create_dynamic(struct dahdi_dynamic_span *zds)
dahdi_copy_string(z->dname, zds->driver, sizeof(z->dname));
dahdi_copy_string(z->addr, zds->addr, sizeof(z->addr));
z->timing = zds->timing;
- sprintf(z->span.name, "ZTD/%s/%s", zds->driver, zds->addr);
+ 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.channels = zds->numchans;
z->span.pvt = z;
@@ -608,8 +611,8 @@ static int create_dynamic(struct dahdi_dynamic_span *zds)
z->span.open = ztd_open;
z->span.close = ztd_close;
z->span.chanconfig = ztd_chanconfig;
- for (x=0;x<zds->numchans;x++) {
- sprintf(z->chans[x]->name, "ZTD/%s/%s/%d", zds->driver, zds->addr, x+1);
+ for (x=0; x < z->span.channels; x++) {
+ sprintf(z->chans[x]->name, "DYN/%s/%s/%d", zds->driver, zds->addr, x+1);
z->chans[x]->sigcap = DAHDI_SIG_EM | DAHDI_SIG_CLEAR | DAHDI_SIG_FXSLS |
DAHDI_SIG_FXSKS | DAHDI_SIG_FXSGS | DAHDI_SIG_FXOLS |
DAHDI_SIG_FXOKS | DAHDI_SIG_FXOGS | DAHDI_SIG_SF |