From c48dea5195a3bc374c6357df7ec1ffc3106d22b4 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 2 Jul 2015 01:17:49 +1000 Subject: [PATCH] Allow the vizzini module to be installed side-by-side with cdc-acm. * Use a dynamically allocated major device number. * Use the tty name of /dev/ttyVIZx so it doesn't conflict with other devices. * Create a udev rule which makes sure the device is bound to the vizzini module. This is needed if the vizzini module is loaded *after* the cdc-acm module as drivers are checked in the order they have been loaded and the cdc-acm registers for the device class exported by the device. * Adding slightly better debug messages. --- 99-vizzini.rules | 1 + Makefile | 5 +++++ debian/changelog | 6 ++++++ debian/rules | 3 +++ vizzini.c | 11 +++++++---- vizzini.h | 1 - 6 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 99-vizzini.rules diff --git a/99-vizzini.rules b/99-vizzini.rules new file mode 100644 index 0000000..61ebe5c --- /dev/null +++ b/99-vizzini.rules @@ -0,0 +1 @@ +SUBSYSTEM=="usb", ATTR{idVendor}=="04e2", RUN+="/bin/sh -c 'echo -n %k:1.0 >/sys/bus/usb/drivers/cdc_acm/unbind; echo -n %k:1.0 >/sys/bus/usb/drivers/vizzini/bind'" diff --git a/Makefile b/Makefile index 750a450..898f64d 100644 --- a/Makefile +++ b/Makefile @@ -13,3 +13,8 @@ modules_install: clean: rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions vtty + +install-rules: 99-vizzini.rules + cp $< "/etc/udev/rules.d/99-vizzini.rules" + udevadm control --reload-rules + udevadm trigger --attr-match=idVendor=04e2 --verbose diff --git a/debian/changelog b/debian/changelog index fdc80e0..9b9bc66 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +vizzini (1.0.0-3) unstable; urgency=low + + * Now can be loaded side-by-side with the cdc-acm module. + + -- Tim 'mithro' Ansell Thu, 02 Jul 2015 01:34:00 +1030 + vizzini (1.0.0-2) unstable; urgency=low * Now based on https://github.com/shenki/exar-uart-driver instead of https://github.com/ardje/vizzini diff --git a/debian/rules b/debian/rules index 42506bb..1faffd7 100755 --- a/debian/rules +++ b/debian/rules @@ -27,6 +27,8 @@ binary-modules: dh_installdocs dh_installchangelogs dh_installmodules + cp debian/vizzini.udev debian/$(PKGNAME).udev + dh_installudev --priority=99 dh_compress dh_fixperms dh_installdeb @@ -50,6 +52,7 @@ install: build dh_installdirs -p$(psource) usr/src/modules/$(sname)/debian cp Makefile README* vizzini.c vizzini.h vzioctl.h $(DESTDIR) cp debian/*modules.in* debian/control debian/rules debian/changelog debian/copyright debian/compat $(DESTDIR)/debian + cp 99-vizzini.rules $(DESTDIR)/debian/vizzini.udev cd debian/$(psource)/usr/src && tar c modules | bzip2 -9 > $(sname).tar.bz2 && rm -rf modules dh_install diff --git a/vizzini.c b/vizzini.c index 9e085c0..85e5d76 100644 --- a/vizzini.c +++ b/vizzini.c @@ -1853,11 +1853,13 @@ static int __init xr21v141x_init(void) { int retval; xr21v141x_tty_driver = alloc_tty_driver(XR21V141X_TTY_MINORS); - if (!xr21v141x_tty_driver) + if (!xr21v141x_tty_driver) { + printk(KERN_INFO KBUILD_MODNAME ": alloc_tty_driver(%d) failed\n", XR21V141X_TTY_MINORS); return -ENOMEM; + } xr21v141x_tty_driver->driver_name = "vizzini", - xr21v141x_tty_driver->name = "ttyUSB", - xr21v141x_tty_driver->major = XR21V141X_TTY_MAJOR, + xr21v141x_tty_driver->name = "ttyVIZ", + xr21v141x_tty_driver->major = 0, // Dynamically allocate the major number xr21v141x_tty_driver->minor_start = 0, xr21v141x_tty_driver->type = TTY_DRIVER_TYPE_SERIAL, xr21v141x_tty_driver->subtype = SERIAL_TYPE_NORMAL, @@ -1869,12 +1871,14 @@ static int __init xr21v141x_init(void) retval = tty_register_driver(xr21v141x_tty_driver); if (retval) { + printk(KERN_INFO KBUILD_MODNAME ": tty_register_driver failed\n"); put_tty_driver(xr21v141x_tty_driver); return retval; } retval = usb_register(&xr21v141x_driver); if (retval) { + printk(KERN_INFO KBUILD_MODNAME ": usb_register failed\n"); tty_unregister_driver(xr21v141x_tty_driver); put_tty_driver(xr21v141x_tty_driver); return retval; @@ -1898,4 +1902,3 @@ module_exit(xr21v141x_exit); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); -MODULE_ALIAS_CHARDEV_MAJOR(ACM_TTY_MAJOR); diff --git a/vizzini.h b/vizzini.h index 1fa31e6..9fe8638 100644 --- a/vizzini.h +++ b/vizzini.h @@ -195,7 +195,6 @@ * Major and minor numbers. */ -#define XR21V141X_TTY_MAJOR 166 #define XR21V141X_TTY_MINORS 32 #define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE) -- 2.39.5