I've cleaned up my usb-serial patch a little so I'll submit it again.
This patch adds proper devfs support to the usb-serial driver. It creates
it's devices as </dev>/usb/serial/#. Also, new in the version: It tries to
create a /dev/pilot symlink if it detects a Visor is connected.
A couple of known issues: When syncing usb/serial/# devices might not get
cleaned up properly. I think this is because the Visor is disconnecting
before pilot-xfer closes the device. And, while it won't change an existing
pilot symlink, it will remove it.
Enjoy.
- Nick Lopez
[EMAIL PROTECTED]
--- linux-2.3.99-pre3/drivers/usb/serial/usb-serial.c.stock Wed Mar 29 15:46:47
2000
+++ linux-2.3.99-pre3/drivers/usb/serial/usb-serial.c Wed Mar 29 15:38:56 2000
@@ -190,6 +190,14 @@
#include <linux/module.h>
#include <linux/spinlock.h>
+#ifdef CONFIG_DEVFS_FS
+#include <linux/devfs_fs_kernel.h>
+extern void tty_register_devfs (struct tty_driver *driver, unsigned int flags,
+ unsigned int minor);
+extern void tty_unregister_devfs (struct tty_driver *driver, unsigned minor);
+#endif /* CONFIG_DEVFS_FS */
+
+
#ifdef CONFIG_USB_SERIAL_DEBUG
#define DEBUG
#else
@@ -241,6 +249,44 @@
static struct termios * serial_termios_locked[SERIAL_TTY_MINORS];
static struct usb_serial *serial_table[SERIAL_TTY_MINORS] = {NULL, };
+static struct tty_driver serial_tty_driver = {
+ magic: TTY_DRIVER_MAGIC,
+ driver_name: "usb-serial",
+ name: "usb/serial/%d",
+ major: SERIAL_TTY_MAJOR,
+ minor_start: 0,
+ num: SERIAL_TTY_MINORS,
+ type: TTY_DRIVER_TYPE_SERIAL,
+ subtype: SERIAL_TYPE_NORMAL,
+ flags: TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS,
+ refcount: &serial_refcount,
+ table: serial_tty,
+ proc_entry: NULL,
+ other: NULL,
+ termios: serial_termios,
+ termios_locked: serial_termios_locked,
+
+ open: serial_open,
+ close: serial_close,
+ write: serial_write,
+ put_char: NULL,
+ flush_chars: NULL,
+ write_room: serial_write_room,
+ ioctl: serial_ioctl,
+ set_termios: serial_set_termios,
+ set_ldisc: NULL,
+ throttle: serial_throttle,
+ unthrottle: serial_unthrottle,
+ stop: NULL,
+ start: NULL,
+ hangup: NULL,
+ break_ctl: NULL,
+ wait_until_sent: NULL,
+ send_xchar: NULL,
+ read_proc: NULL,
+ chars_in_buffer: serial_chars_in_buffer,
+ flush_buffer: NULL
+};
static inline int serial_paranoia_check (struct usb_serial *serial, const char
*function)
{
@@ -2407,7 +2453,21 @@
#endif
for (i = 0; i < serial->num_ports; ++i) {
+ char link[20];
info("%s converter now attached to ttyUSB%d",
type->name, serial->minor + i);
+ #ifdef CONFIG_DEVFS_FS
+ tty_register_devfs (&serial_tty_driver,
+ 0, serial->port[i].minor);
+ if (type == &handspring_device &&
+ i == 1) {
+ sprintf(link,
+ "usb/serial/%d",
+ serial->port[i].minor);
+ devfs_mk_symlink(NULL,
+ "pilot",5,
+ 0,link,0,NULL,NULL);
+ }
+ #endif /* CONFIG_DEVFS_FS */
}
MOD_INC_USE_COUNT;
@@ -2501,6 +2561,11 @@
/* return the minor range that this device had */
return_serial (serial);
+ #ifdef CONFIG_DEVFS_FS
+ tty_unregister_devfs(&serial_tty_driver, serial->minor);
+ /* devfs_unregister has NULL sanitycheck */
+ devfs_unregister(devfs_find_handle( NULL, "pilot", 5, 0, 0, 0, 0 ));
+ #endif /* CONFIG_DEVFS_FS */
/* free up any memory that we allocated */
kfree (serial);
@@ -2510,46 +2575,6 @@
MOD_DEC_USE_COUNT;
}
-
-
-static struct tty_driver serial_tty_driver = {
- magic: TTY_DRIVER_MAGIC,
- driver_name: "usb",
- name: "ttyUSB%d",
- major: SERIAL_TTY_MAJOR,
- minor_start: 0,
- num: SERIAL_TTY_MINORS,
- type: TTY_DRIVER_TYPE_SERIAL,
- subtype: SERIAL_TYPE_NORMAL,
- flags: TTY_DRIVER_REAL_RAW,
- refcount: &serial_refcount,
- table: serial_tty,
- proc_entry: NULL,
- other: NULL,
- termios: serial_termios,
- termios_locked: serial_termios_locked,
-
- open: serial_open,
- close: serial_close,
- write: serial_write,
- put_char: NULL,
- flush_chars: NULL,
- write_room: serial_write_room,
- ioctl: serial_ioctl,
- set_termios: serial_set_termios,
- set_ldisc: NULL,
- throttle: serial_throttle,
- unthrottle: serial_unthrottle,
- stop: NULL,
- start: NULL,
- hangup: NULL,
- break_ctl: serial_break,
- wait_until_sent: NULL,
- send_xchar: NULL,
- read_proc: NULL,
- chars_in_buffer: serial_chars_in_buffer,
- flush_buffer: NULL
-};
int usb_serial_init(void)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]