[svn-commits] kpfleming: branch 1.4 r3635 - /branches/1.4/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Jan 9 11:17:08 CST 2008
Author: kpfleming
Date: Wed Jan 9 11:17:07 2008
New Revision: 3635
URL: http://svn.digium.com/view/zaptel?view=rev&rev=3635
Log:
For systems using a dynamic device filesystem (pretty much everything
now), don't register the character device for transcoder support
unless the 'zttranscode'module is loaded. This will result in
zttranscode no longer being automatically loaded when there are no
transcoders present but Asterisk's codec_zap is loaded to look for
them. The zttranscode module will get loaded if any transcoder driver
modules are loaded, so users with transcoders will not see any change
in behavior.
Modified:
branches/1.4/zaptel-base.c
branches/1.4/zaptel.h
branches/1.4/zttranscode.c
Modified: branches/1.4/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/zaptel-base.c?view=diff&rev=3635&r1=3634&r2=3635
==============================================================================
--- branches/1.4/zaptel-base.c (original)
+++ branches/1.4/zaptel-base.c Wed Jan 9 11:17:07 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: branches/1.4/zaptel.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/zaptel.h?view=diff&rev=3635&r1=3634&r2=3635
==============================================================================
--- branches/1.4/zaptel.h (original)
+++ branches/1.4/zaptel.h Wed Jan 9 11:17:07 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: branches/1.4/zttranscode.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/zttranscode.c?view=diff&rev=3635&r1=3634&r2=3635
==============================================================================
--- branches/1.4/zttranscode.c (original)
+++ branches/1.4/zttranscode.c Wed Jan 9 11:17:07 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 svn-commits
mailing list