[svn-commits] sruffell: linux/trunk r9955 - /linux/trunk/drivers/dahdi/wctdm24xxp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 2 15:02:50 CDT 2011


Author: sruffell
Date: Thu Jun  2 15:02:47 2011
New Revision: 9955

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9955
Log:
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 at digium.com>

Modified:
    linux/trunk/drivers/dahdi/wctdm24xxp/base.c
    linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h

Modified: linux/trunk/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=9955&r1=9954&r2=9955
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/base.c Thu Jun  2 15:02:47 2011
@@ -4047,6 +4047,7 @@
 		kfree(frame);
 	}
 
+	kfree(wc->board_name);
 	kfree(wc);
 }
 
@@ -4594,6 +4595,22 @@
 	}
 	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
@@ -4608,17 +4625,6 @@
 		}
 	}
 #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;
@@ -4636,7 +4642,7 @@
 	}
 
 	if (ret) {
-		kfree(wc);
+		wctdm_back_out_gracefully(wc);
 		return ret;
 	}
 
@@ -4644,9 +4650,6 @@
 
 	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;
@@ -4682,7 +4685,7 @@
 		ret = hx8_check_firmware(wc);
 		if (ret) {
 			voicebus_release(&wc->vb);
-			kfree(wc);
+			wctdm_back_out_gracefully(wc);
 			return -EIO;
 		}
 

Modified: linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h?view=diff&rev=9955&r1=9954&r2=9955
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h Thu Jun  2 15:02:47 2011
@@ -153,7 +153,7 @@
 
 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;




More information about the svn-commits mailing list