[svn-commits] sruffell: branch linux/sruffell/wctdm24xxp-cmdlist r9850 - /linux/team/sruffe...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 16 16:39:58 CDT 2011


Author: sruffell
Date: Wed Mar 16 16:39:55 2011
New Revision: 9850

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9850
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/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c
    linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h

Modified: linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=9850&r1=9849&r2=9850
==============================================================================
--- linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c Wed Mar 16 16:39:55 2011
@@ -4003,6 +4003,7 @@
 		kfree(frame);
 	}
 
+	kfree(wc->board_name);
 	kfree(wc);
 }
 
@@ -4550,6 +4551,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
@@ -4564,17 +4581,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;
@@ -4592,7 +4598,7 @@
 	}
 
 	if (ret) {
-		kfree(wc);
+		wctdm_back_out_gracefully(wc);
 		return ret;
 	}
 
@@ -4600,9 +4606,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;
@@ -4638,7 +4641,7 @@
 		ret = hx8_check_firmware(wc);
 		if (ret) {
 			voicebus_release(&wc->vb);
-			kfree(wc);
+			wctdm_back_out_gracefully(wc);
 			return -EIO;
 		}
 

Modified: linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h?view=diff&rev=9850&r1=9849&r2=9850
==============================================================================
--- linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h (original)
+++ linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h Wed Mar 16 16:39:55 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