[zaptel-commits] kpfleming: branch kpfleming/transcode r3634 - /team/kpfleming/transcode/

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Wed Jan 9 11:08:21 CST 2008


Author: kpfleming
Date: Wed Jan  9 11:08:21 2008
New Revision: 3634

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3634
Log:
create a branch for some changes that need to be tested

Added:
    team/kpfleming/transcode/
      - copied from r3633, branches/1.4/
Modified:
    team/kpfleming/transcode/zaptel-base.c
    team/kpfleming/transcode/zaptel.h
    team/kpfleming/transcode/zttranscode.c

Modified: team/kpfleming/transcode/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/team/kpfleming/transcode/zaptel-base.c?view=diff&rev=3634&r1=3633&r2=3634
==============================================================================
--- team/kpfleming/transcode/zaptel-base.c (original)
+++ team/kpfleming/transcode/zaptel-base.c Wed Jan  9 11:08:21 2008
@@ -143,6 +143,8 @@
 EXPORT_SYMBOL(zt_hdlc_getbuf);
 EXPORT_SYMBOL(zt_hdlc_putbuf);
 EXPORT_SYMBOL(zt_alarm_channel);
+EXPORT_SYMBOL(zt_register_chardev);
+EXPORT_SYMBOL(zt_unregister_chardev);
 
 #ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *proc_entries[ZT_MAX_SPANS]; 
@@ -155,7 +157,6 @@
 static devfs_handle_t pseudo;
 static devfs_handle_t ctl;
 static devfs_handle_t timer;
-static devfs_handle_t transcode;
 #endif
 
 /* udev necessary data structures.  Yeah! */
@@ -7284,6 +7285,36 @@
 
 #endif
 
+int zt_register_chardev(struct zt_chardev *dev)
+{
+#ifdef CONFIG_ZAP_UDEV
+	char udevname[strlen(dev->name) + 3];
+
+	strcpy(udevname, "zap");
+	strcat(udevname, dev->name);
+	CLASS_DEV_CREATE(zap_class, MKDEV(ZT_MAJOR, dev->minor), NULL, udevname);
+#endif /* CONFIG_ZAP_UDEV */
+	
+#ifdef CONFIG_DEVFS_FS
+	dev->devfs_handle = devfs_register(zaptel_devfs_dir, dev->name, DEVFS_FL_DEFAULT, ZT_MAJOR, dev->minor, mode, &zt_fops, NULL);
+#endif /* CONFIG_DEVFS_FS */
+
+	return 0;
+}
+
+int zt_unregister_chardev(struct zt_chardev *dev)
+{
+#ifdef CONFIG_ZAP_UDEV
+	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, dev->minor));
+#endif /* CONFIG_ZAP_UDEV */
+
+#ifdef CONFIG_DEVFS_FS
+	devfs_unregister(dev->devfs_handle);
+#endif /* CONFIG_DEVFS_FS */
+
+	return 0;
+}
+
 static int __init zt_init(void) {
 	int res = 0;
 
@@ -7293,7 +7324,6 @@
 
 #ifdef CONFIG_ZAP_UDEV /* udev support functions */
 	zap_class = class_create(THIS_MODULE, "zaptel");
-	CLASS_DEV_CREATE(zap_class, MKDEV(ZT_MAJOR, 250), NULL, "zaptranscode");
 	CLASS_DEV_CREATE(zap_class, MKDEV(ZT_MAJOR, 253), NULL, "zaptimer");
 	CLASS_DEV_CREATE(zap_class, MKDEV(ZT_MAJOR, 254), NULL, "zapchannel");
 	CLASS_DEV_CREATE(zap_class, MKDEV(ZT_MAJOR, 255), NULL, "zappseudo");
@@ -7302,19 +7332,19 @@
 
 #ifdef CONFIG_DEVFS_FS
 	{
-	umode_t mode = S_IFCHR|S_IRUGO|S_IWUGO;
-	devfs_register_chrdev(ZT_MAJOR, "zaptel", &zt_fops);
-	zaptel_devfs_dir = devfs_mk_dir(NULL, "zap", NULL);
-	if (!zaptel_devfs_dir) return -EBUSY; /* This would be bad */
-	timer = devfs_register(zaptel_devfs_dir, "timer", DEVFS_FL_DEFAULT, ZT_MAJOR, 253, mode, &zt_fops, NULL);
-	channel = devfs_register(zaptel_devfs_dir, "channel", DEVFS_FL_DEFAULT, ZT_MAJOR, 254, mode, &zt_fops, NULL);
-	pseudo = devfs_register(zaptel_devfs_dir, "pseudo", DEVFS_FL_DEFAULT, ZT_MAJOR, 255, mode, &zt_fops, NULL);
-	transcode = devfs_register(zaptel_devfs_dir, "transcode", DEVFS_FL_DEFAULT, ZT_MAJOR, 250, mode, &zt_fops, NULL);
-	ctl = devfs_register(zaptel_devfs_dir, "ctl", DEVFS_FL_DEFAULT, ZT_MAJOR, 0, mode, &zt_fops, NULL);
+		umode_t mode = S_IFCHR|S_IRUGO|S_IWUGO;
+
+		devfs_register_chrdev(ZT_MAJOR, "zaptel", &zt_fops);
+		if (!(zaptel_devfs_dir = devfs_mk_dir(NULL, "zap", NULL)))
+			return -EBUSY; /* This would be bad */
+		timer = devfs_register(zaptel_devfs_dir, "timer", DEVFS_FL_DEFAULT, ZT_MAJOR, 253, mode, &zt_fops, NULL);
+		channel = devfs_register(zaptel_devfs_dir, "channel", DEVFS_FL_DEFAULT, ZT_MAJOR, 254, mode, &zt_fops, NULL);
+		pseudo = devfs_register(zaptel_devfs_dir, "pseudo", DEVFS_FL_DEFAULT, ZT_MAJOR, 255, mode, &zt_fops, NULL);
+		ctl = devfs_register(zaptel_devfs_dir, "ctl", DEVFS_FL_DEFAULT, ZT_MAJOR, 0, mode, &zt_fops, NULL);
 	}
 #else
 	if ((res = register_chrdev(ZT_MAJOR, "zaptel", &zt_fops))) {
-		printk(KERN_ERR "Unable to register tor device on %d\n", ZT_MAJOR);
+		printk(KERN_ERR "Unable to register Zaptel character device handler on %d\n", ZT_MAJOR);
 		return res;
 	}
 #endif /* CONFIG_DEVFS_FS */
@@ -7347,7 +7377,6 @@
 
 #ifdef CONFIG_DEVFS_FS
 	devfs_unregister(timer);
-	devfs_unregister(transcode);
 	devfs_unregister(channel);
 	devfs_unregister(pseudo);
 	devfs_unregister(ctl);
@@ -7355,7 +7384,6 @@
 	devfs_unregister_chrdev(ZT_MAJOR, "zaptel");
 #else
 #ifdef CONFIG_ZAP_UDEV
-	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, 250)); /* transcode */
 	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, 253)); /* timer */
 	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, 254)); /* channel */
 	class_device_destroy(zap_class, MKDEV(ZT_MAJOR, 255)); /* pseudo */

Modified: team/kpfleming/transcode/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/kpfleming/transcode/zaptel.h?view=diff&rev=3634&r1=3633&r2=3634
==============================================================================
--- team/kpfleming/transcode/zaptel.h (original)
+++ team/kpfleming/transcode/zaptel.h Wed Jan  9 11:08:21 2008
@@ -1198,6 +1198,17 @@
 	int modulate;
 };
 
+struct zt_chardev {
+	const char *name;
+	__u8 minor;
+#ifdef CONFIG_DEVFS_FS
+	static devfs_handle_t devfs_handle;
+#endif
+};
+
+int zt_register_chardev(struct zt_chardev *dev);
+int zt_unregister_chardev(struct zt_chardev *dev);
+
 #ifdef CONFIG_ZAPATA_NET
 struct zt_hdlc {
 #ifdef LINUX26	

Modified: team/kpfleming/transcode/zttranscode.c
URL: http://svn.digium.com/view/zaptel/team/kpfleming/transcode/zttranscode.c?view=diff&rev=3634&r1=3633&r2=3634
==============================================================================
--- team/kpfleming/transcode/zttranscode.c (original)
+++ team/kpfleming/transcode/zttranscode.c Wed Jan  9 11:08:21 2008
@@ -428,7 +428,7 @@
 	return ztc->tch->status & ZT_TC_FLAG_BUSY ? 0 : POLLPRI;
 }
 
-struct file_operations __zt_transcode_fops = {
+static struct file_operations __zt_transcode_fops = {
 	owner: THIS_MODULE,
 	llseek: NULL,
 	open: zt_tc_open,
@@ -443,14 +443,25 @@
 	fasync: NULL,
 };
 
+static struct zt_chardev transcode_chardev = {
+	.name = "transcode",
+	.minor = 250,
+};
+
 int zttranscode_init(void)
 {
+	int res;
+
 	if (zt_transcode_fops) {
 		printk("Whoa, zt_transcode_fops already set?!\n");
 		return -EBUSY;
 	}
 
 	zt_transcode_fops = &__zt_transcode_fops;
+
+	if ((res = zt_register_chardev(&transcode_chardev)))
+		return res;
+
 	printk("Zaptel Transcoder support loaded\n");
 
 	return 0;
@@ -458,7 +469,10 @@
 
 void zttranscode_cleanup(void)
 {
+	zt_unregister_chardev(&transcode_chardev);
+
 	zt_transcode_fops = NULL;
+
 	printk("Zaptel Transcoder support unloaded\n");
 }
 




More information about the zaptel-commits mailing list