]> git.decadent.org.uk Git - exar-uart-driver.git/commitdiff
Allow the vizzini module to be installed side-by-side with cdc-acm.
authorTim 'mithro' Ansell <mithro@mithis.com>
Wed, 1 Jul 2015 15:17:49 +0000 (01:17 +1000)
committerTim 'mithro' Ansell <mithro@mithis.com>
Thu, 2 Jul 2015 04:24:14 +0000 (14:24 +1000)
 * 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 [new file with mode: 0644]
Makefile
debian/changelog
debian/rules
vizzini.c
vizzini.h

diff --git a/99-vizzini.rules b/99-vizzini.rules
new file mode 100644 (file)
index 0000000..61ebe5c
--- /dev/null
@@ -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'"
index 750a45070482c06341aac25e488662cc6329fe33..898f64d516b2629a51a79af9a296865c856248ab 100644 (file)
--- 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
index fdc80e0ae00e4efeff7cbb93e9b8fa94a892bfdd..9b9bc660c59b4fe2af593b085c1e5c9169983310 100644 (file)
@@ -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 <mithro@mithis.com>  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
index 42506bb9683ce66a88f5313910d33d9370c32abd..1faffd73e639267dc2a0528f46dd02bc46650be8 100755 (executable)
@@ -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
 
index 9e085c003b0c426fda9154dbdeb6a9ba0c0c7dee..85e5d76eae2ef432540f1bbe19330d483eff7db7 100644 (file)
--- 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);
index 1fa31e60ba8ec12f50de368c2fd3bf8f8aacabb9..9fe863805187b698cd451f82e2b3c88a053a3271 100644 (file)
--- a/vizzini.h
+++ b/vizzini.h
  * Major and minor numbers.
  */
 
-#define XR21V141X_TTY_MAJOR            166
 #define XR21V141X_TTY_MINORS           32
 
 #define USB_RT_ACM             (USB_TYPE_CLASS | USB_RECIP_INTERFACE)