diff options
-rwxr-xr-x | Makefile | 12 | ||||
-rwxr-xr-x | README.udev | 34 | ||||
-rwxr-xr-x | zaptel.c | 37 | ||||
-rwxr-xr-x | zconfig.h | 5 |
4 files changed, 85 insertions, 3 deletions
@@ -38,8 +38,13 @@ MODCONF=$(shell if [ -d $(INSTALL_PREFIX)/etc/modprobe.d ]; then echo "$(INSTALL ifeq (${BUILDVER},linux24) #We only support DEVFS in linux 2.4 kernels, since its considered obsolete post 2.4 -DEVFS=$(shell ps ax | grep -v grep | grep devfsd) +DYNFS=$(shell ps ax | grep -v grep | grep devfsd) endif +ifeq (${BUILDVER},linux26) +#Tests for newer linux-2.6 udev support +DYNFS=$(shell ps ax | grep -v grep | grep udevd) +endif + TZOBJS=zonedata.lo tonezone.lo LIBTONEZONE=libtonezone.so.1.0 @@ -213,7 +218,7 @@ fxsdump: fxsdump.o $(CC) -o fxsdump fxsdump.o -lm devices: -ifeq ($(DEVFS),) +ifeq ($(DYNFS),) mkdir -p $(INSTALL_PREFIX)/dev/zap rm -f $(INSTALL_PREFIX)/dev/zap/ctl rm -f $(INSTALL_PREFIX)/dev/zap/channel @@ -234,7 +239,8 @@ ifeq ($(DEVFS),) N=$$[$$N+1]; \ done else - @echo "**** devfs detected -- not making device nodes" + @echo "**** Dynamic filesystem detected -- not creating device nodes" + @echo "**** If you are running udev, read README.udev" endif install: all devices $(LIBTONEZONE) diff --git a/README.udev b/README.udev new file mode 100755 index 0000000..da3656a --- /dev/null +++ b/README.udev @@ -0,0 +1,34 @@ +UDEV -- What the heck is udev OR why did I get a message to read this? + +This is the new mechanism of doing a dyamic /dev. What does +that mean? Basically, before the days of linux-2.3/linux-2.4 your /dev +had to have ~18000 files in it for all the possible device that your +kernel could possibly have, most of which you will NEVER use. This, for +obvious reasons, is somewhat undesirable. So then came devfs. Devfs +solved a lot of these problems by dynamically populating /dev with only +the device nodes of the devices that existed on your system. Now, in +linux-2.6, udev+sysfs has become the mechanism of choice for populating +your dynamic /dev with device nodes. + +You got this message because you are probably running udev on your system. + +If your are not, or you feel that you have reached this message error you +can send me an email (look to bottom of file for address). + +If you're running udev on your system, you were probably directed +to read this file during compile. For udevd (the daemon responsible +for creation/deletion of device nodes), you will need to add the following +lines to your udev rules. + +# Section for zaptel device +KERNEL="zapctl", NAME="zap/ctl" +KERNEL="zaptimer", NAME="zap/timer" +KERNEL="zapchannel", NAME="zap/channel" +KERNEL="zappseudo", NAME="zap/pseudo" +KERNEL="zap[0-9]*", NAME="zap/%n" + +This will take care of making all the automagic occur that needs to be +done so that udevd will make the right files for zaptel. + +Matthew Fredrickson +creslin@NOSPAMdigium.com @@ -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 @@ -62,6 +62,11 @@ */ /* #define NO_ECHOCAN_DISABLE */ +/* udev support */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) +#define CONFIG_ZAP_UDEV +#endif + /* We now use the linux kernel config to detect which options to use */ /* You can still override them below */ #if defined(CONFIG_HDLC) || defined(CONFIG_HDLC_MODULE) |