summaryrefslogtreecommitdiff
path: root/zaptel.c
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-07-16 22:09:07 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-07-16 22:09:07 +0000
commit1818360e59b558561a6b0b530d2c9ef7f2407da5 (patch)
tree0dfea157fa66dc329a1107e891a8af37aa0facba /zaptel.c
parentb6f5d94bb37d52f93b2b869c1105ded1fe520fe8 (diff)
Add udev support (courtesy matt / creslin)
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@433 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'zaptel.c')
-rwxr-xr-xzaptel.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/zaptel.c b/zaptel.c
index 5e26181..d897a2c 100755
--- a/zaptel.c
+++ b/zaptel.c
@@ -143,6 +143,12 @@ static devfs_handle_t pseudo;
static devfs_handle_t ctl;
static devfs_handle_t timer;
#endif
+
+/* udev necessary data structures. Yeah! */
+#ifdef CONFIG_ZAP_UDEV
+static struct class_simple *zap_class = NULL;
+#endif
+
/* There is a table like this in the PPP driver, too */
static int deftaps = 64;
@@ -4165,6 +4171,14 @@ int zt_register(struct zt_span *span, int prefmaster)
}
#endif /* CONFIG_DEVFS_FS */
+#ifdef CONFIG_ZAP_UDEV
+ for (x = 0; x < span->channels; x++) {
+ char chan_name[50];
+ sprintf(chan_name, "zap%d", span->chans[x].channo);
+ class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, span->chans[x].channo), NULL, chan_name);
+ }
+#endif /* CONFIG_ZAP_UDEV */
+
if (debug)
printk("Registered Span %d ('%s') with %d channels\n", span->spanno, span->name, span->channels);
if (!master || prefmaster) {
@@ -4208,6 +4222,13 @@ int zt_unregister(struct zt_span *span)
}
devfs_unregister(span->dhandle);
#endif /* CONFIG_DEVFS_FS */
+
+#ifdef CONFIG_ZAP_UDEV
+ for (x = 0; x < span->channels; x++) {
+ class_simple_device_remove(MKDEV(ZT_MAJOR, span->chans[x].channo));
+ }
+#endif /* CONFIG_ZAP_UDEV */
+
spans[span->spanno] = NULL;
span->spanno = 0;
span->flags &= ~ZT_FLAG_REGISTERED;
@@ -6078,6 +6099,15 @@ static int __init zt_init(void) {
#ifdef CONFIG_PROC_FS
proc_entries[0] = proc_mkdir("zaptel", NULL);
#endif
+
+#ifdef CONFIG_ZAP_UDEV /* udev support functions */
+ zap_class = class_simple_create(THIS_MODULE, "zaptel");
+ class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, 253), NULL, "zaptimer");
+ class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, 254), NULL, "zapchannel");
+ class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, 255), NULL, "zappseudo");
+ class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, 0), NULL, "zapctl");
+#endif /* CONFIG_ZAP_UDEV */
+
#ifdef CONFIG_DEVFS_FS
{
umode_t mode = S_IFCHR|S_IRUGO|S_IWUGO;
@@ -6127,6 +6157,13 @@ static void __exit zt_cleanup(void) {
devfs_unregister(zaptel_devfs_dir);
devfs_unregister_chrdev(ZT_MAJOR, "zaptel");
#else
+#ifdef CONFIG_ZAP_UDEV
+ class_simple_device_remove(MKDEV(ZT_MAJOR, 253)); /* timer */
+ class_simple_device_remove(MKDEV(ZT_MAJOR, 254)); /* channel */
+ class_simple_device_remove(MKDEV(ZT_MAJOR, 255)); /* pseudo */
+ class_simple_device_remove(MKDEV(ZT_MAJOR, 0)); /* ctl */
+ class_simple_destroy(zap_class);
+#endif /* CONFIG_ZAP_UDEV */
unregister_chrdev(ZT_MAJOR, "zaptel");
#endif
#ifdef CONFIG_ZAPTEL_WATCHDOG