diff options
Diffstat (limited to 'zaptel.c')
-rwxr-xr-x | zaptel.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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 |