From fdaba144813046745154ec3425705a80e2ca5eb6 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Tue, 14 Oct 2008 22:11:45 +0000 Subject: If the vpmad032 firmware needs to be reloaded, make sure we use the same slot in the ifaces array. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@5090 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/wcte12xp/base.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index 086c3f2..ee65acc 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -1582,11 +1582,16 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi unsigned int x; int res; int startinglatency; + unsigned int index = -1; - for (x = 0; x < sizeof(ifaces) / sizeof(ifaces[0]); x++) - if (!ifaces[x]) break; + for (x = 0; x < sizeof(ifaces) / sizeof(ifaces[0]); x++) { + if (!ifaces[x]) { + index = x; + break; + } + } - if (x >= sizeof(ifaces) / sizeof(ifaces[0])) { + if (-1 == index) { module_printk("Too many interfaces\n"); return -EIO; } @@ -1596,18 +1601,19 @@ retry: return -ENOMEM; } - ifaces[x] = wc; + ifaces[index] = wc; memset(wc, 0, sizeof(*wc)); spin_lock_init(&wc->reglock); wc->variety = d->name; wc->txident = 1; init_waitqueue_head(&wc->regq); - snprintf(wc->name, sizeof(wc->name)-1, "wcte12xp%d", x); + snprintf(wc->name, sizeof(wc->name)-1, "wcte12xp%d", index); if ((res = voicebus_init(pdev, SFRAME_SIZE, wc->name, t1_handle_receive, t1_handle_transmit, wc, &wc->vb))) { WARN_ON(1); kfree(wc); + ifaces[index] = NULL; return res; } @@ -1627,6 +1633,7 @@ retry: } kfree(wc); + ifaces[index] = NULL; return -ENOMEM; } memset(wc->chans[x], 0, sizeof(*wc->chans[x])); -- cgit v1.2.3