[zaptel-commits] kpfleming: branch mogorman/zaptel-1.2-transcoder r2049 - in /team/mogorman/za...

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Wed Jan 31 09:17:10 MST 2007


Author: kpfleming
Date: Wed Jan 31 10:17:09 2007
New Revision: 2049

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2049
Log:
manage reference counts on transcoder modules when there are channels open in them

Modified:
    team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c
    team/mogorman/zaptel-1.2-transcoder/zaptel.h
    team/mogorman/zaptel-1.2-transcoder/zttranscode.c

Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c?view=diff&rev=2049&r1=2048&r2=2049
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c Wed Jan 31 10:17:09 2007
@@ -1489,8 +1489,8 @@
 		wc->udecode->channels[x].pvt = &decoders[x];
 	}
 	
-	zt_transcoder_register(wc->uencode);
-	zt_transcoder_register(wc->udecode);
+	zt_transcoder_register(wc->uencode, THIS_MODULE);
+	zt_transcoder_register(wc->udecode, THIS_MODULE);
 	
 	/* Enable bus mastering */
 	pci_set_master(pdev);

Modified: team/mogorman/zaptel-1.2-transcoder/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/zaptel.h?view=diff&rev=2049&r1=2048&r2=2049
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/zaptel.h (original)
+++ team/mogorman/zaptel-1.2-transcoder/zaptel.h Wed Jan 31 10:17:09 2007
@@ -1421,6 +1421,7 @@
 
 struct zt_transcoder {
 	struct list_head list;
+	struct module *owner;
 	char name[80];
 	int numchannels;
 	unsigned int srcfmts;
@@ -1484,7 +1485,7 @@
 void zt_transcoder_free(struct zt_transcoder *ztc);
 
 /* Register a transcoder */
-int zt_transcoder_register(struct zt_transcoder *tc);
+int zt_transcoder_register(struct zt_transcoder *tc, struct module *owner);
 
 /* Unregister a transcoder */
 int zt_transcoder_unregister(struct zt_transcoder *tc);

Modified: team/mogorman/zaptel-1.2-transcoder/zttranscode.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/zttranscode.c?view=diff&rev=2049&r1=2048&r2=2049
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/zttranscode.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/zttranscode.c Wed Jan 31 10:17:09 2007
@@ -105,8 +105,7 @@
 	kfree(ztc);
 }
 
-/* Register a transcoder */
-int zt_transcoder_register(struct zt_transcoder *tc)
+int zt_transcoder_register(struct zt_transcoder *tc, struct module *owner)
 {
 	struct zt_transcoder *cur;
 
@@ -118,6 +117,7 @@
 		}
 	}
 
+	tc->owner = owner;
 	list_add(&tc->list, &trans);
 	printk("Registered codec translator '%s' with %d transcoders (srcs=%08x, dsts=%08x)\n", 
 	       tc->name, tc->numchannels, tc->srcfmts, tc->dstfmts);
@@ -172,7 +172,7 @@
 	if (!(ztc = kmalloc(sizeof(*ztc), GFP_KERNEL)))
 		return -ENOMEM;
 
-	if (!(zth = kmalloc(sizeof(*zth), GFP_KERNEL | GFP_DMA))) {
+	if (!(zth = kmalloc(sizeof(*zth), GFP_KERNEL))) {
 		kfree(ztc);
 		return -ENOMEM;
 	}
@@ -203,7 +203,7 @@
 
 	ztc->flags &= ~(ZT_TC_FLAG_BUSY);
 
-	if(ztc->tch) {
+	if (ztc->tch) {
 		for (page = virt_to_page(zth);
 		     page < virt_to_page((unsigned long) zth + sizeof(*zth));
 		     page++)
@@ -226,7 +226,7 @@
 	return 0;
 }
 
-static int do_reset(struct zt_transcoder_channel **ztc)
+static int do_allocate(struct zt_transcoder_channel **ztc)
 {
 	struct zt_transcoder_channel *newztc = NULL, *origztc = NULL;
 	struct zt_transcode_header *zth = (*ztc)->tch;
@@ -252,6 +252,9 @@
 				if ((tc->channels[x].chan_built) && ((zth->srcfmt | zth->dstfmt) != tc->channels[x].built_fmts))
 					continue;
 
+				if (!try_module_get(tc->owner))
+					continue;
+
 				newztc = &tc->channels[x];
 				newztc->flags = ZT_TC_FLAG_BUSY;
 				break;
@@ -338,12 +341,12 @@
 		ret = zt_tc_getinfo(data);
 		break;
 	case ZT_TCOP_ALLOCATE:
-		/* Reset transcoder, possibly changing who we point to */
-		ret = do_reset(&ztc);
+		ret = do_allocate(&ztc);
 		file->private_data = ztc;
 		break;
 	case ZT_TCOP_RELEASE:
 		ret = ztc->parent->operation(ztc, ZT_TCOP_RELEASE);
+		module_put(ztc->parent->owner);
 		break;
 	case ZT_TCOP_TRANSCODE:
 		if (!ztc->parent->operation)
@@ -351,7 +354,7 @@
 
 		ztc->tch->status |= ZT_TC_FLAG_BUSY;
 		if (!(ret = ztc->parent->operation(ztc, ZT_TCOP_TRANSCODE))) {
-			/* Wait for busy to go away if we're not non-blocking */
+			/* Wait for busy to go away if we are in blocking mode */
 			if (!(file->f_flags & O_NONBLOCK)) {
 				if (!(ret = wait_busy(ztc)))
 					ret = ztc->errorstatus;
@@ -418,6 +421,7 @@
 		return -EINVAL;
 
 	poll_wait(file, &ztc->ready, wait_table);
+
 	return ztc->tch->status & ZT_TC_FLAG_BUSY ? 0 : POLLPRI;
 }
 
@@ -456,7 +460,7 @@
 }
 
 #ifdef LINUX26
-module_param(debug, int, 0600);
+module_param(debug, int, S_IRUGO | S_IWUSR);
 #else
 MODULE_PARM(debug, "i");
 #endif



More information about the zaptel-commits mailing list