summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-02-14 02:23:27 -0600
committerShaun Ruffell <sruffell@digium.com>2011-04-15 14:18:58 -0500
commit50d20c094820d93f616f5502b42cc80dde2130cd (patch)
tree20ada218d5606978b8099e90cd46e3d4babc3417
parent9fa825fda1d65670344223701175a9dcb8545bce (diff)
wctdm24xxp: Dynamically allocate the board_name.
Move the data backing the mostly unused string away from the active members of 'struct wctdm'. The location where some of the other members of 'struct wctdm' are initialized were moved so that wctdm_back_out_gracefully always has a fully formed structure to work on. Signed-off-by: Shaun Ruffell <sruffell@digium.com>
-rw-r--r--drivers/dahdi/wctdm24xxp/base.c35
-rw-r--r--drivers/dahdi/wctdm24xxp/wctdm24xxp.h2
2 files changed, 20 insertions, 17 deletions
diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c
index 7e1425a..27c2a2b 100644
--- a/drivers/dahdi/wctdm24xxp/base.c
+++ b/drivers/dahdi/wctdm24xxp/base.c
@@ -4003,6 +4003,7 @@ static void wctdm_back_out_gracefully(struct wctdm *wc)
kfree(frame);
}
+ kfree(wc->board_name);
kfree(wc);
}
@@ -4550,6 +4551,22 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
}
up(&ifacelock);
+ wc->desc = (struct wctdm_desc *)ent->driver_data;
+
+ /* This is to insure that the analog span is given lowest priority */
+ sema_init(&wc->syncsem, 1);
+ INIT_LIST_HEAD(&wc->frame_list);
+ spin_lock_init(&wc->frame_list_lock);
+ init_waitqueue_head(&wc->regq);
+ spin_lock_init(&wc->reglock);
+ wc->oldsync = -1;
+
+ wc->board_name = kasprintf(GFP_KERNEL, "%s%d", wctdm_driver.name, i);
+ if (!wc->board_name) {
+ wctdm_back_out_gracefully(wc);
+ return -ENOMEM;
+ }
+
#ifdef CONFIG_VOICEBUS_ECREFERENCE
for (i = 0; i < ARRAY_SIZE(wc->ec_reference); ++i) {
/* 256 is the smallest power of 2 that will contains the
@@ -4565,17 +4582,6 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
}
#endif
-
- wc->desc = (struct wctdm_desc *)ent->driver_data;
-
- /* This is to insure that the analog span is given lowest priority */
- wc->oldsync = -1;
- sema_init(&wc->syncsem, 1);
- INIT_LIST_HEAD(&wc->frame_list);
- spin_lock_init(&wc->frame_list_lock);
-
- snprintf(wc->board_name, sizeof(wc->board_name)-1, "%s%d", wctdm_driver.name, i);
-
pci_set_drvdata(pdev, wc);
wc->vb.ops = &voicebus_operations;
wc->vb.pdev = pdev;
@@ -4592,7 +4598,7 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
}
if (ret) {
- kfree(wc);
+ wctdm_back_out_gracefully(wc);
return ret;
}
@@ -4600,9 +4606,6 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
voicebus_lock_latency(&wc->vb);
- init_waitqueue_head(&wc->regq);
-
- spin_lock_init(&wc->reglock);
wc->mods_per_board = NUM_MODULES;
wc->pos = i;
wc->txident = 1;
@@ -4638,7 +4641,7 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
ret = hx8_check_firmware(wc);
if (ret) {
voicebus_release(&wc->vb);
- kfree(wc);
+ wctdm_back_out_gracefully(wc);
return -EIO;
}
diff --git a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
index 5366bb9..587cd9c 100644
--- a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
+++ b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
@@ -153,7 +153,7 @@ struct wctdm_chan {
struct wctdm {
const struct wctdm_desc *desc;
- char board_name[80];
+ const char *board_name;
int pos; /* card number in system */
spinlock_t frame_list_lock;