1 --- linux/drivers/usb/serial/pl2303.c.orig 2005-10-17 12:09:48.000000000 +0200
2 +++ linux/drivers/usb/serial/pl2303.c 2005-10-19 04:10:46.000000000 +0200
4 * See Documentation/usb/usb-serial.txt for more information on using this driver
8 + * added some missing ioctl commands
9 + * it seems that there's still an issue with the 2.6.8 version when
10 + * using the device with echo "whatever" >/dev/usb/tts/0 .
11 + * Apparently, a timeout is needed upon pl2303_close (implemented in
15 * ported 2.6.8 pl2303.c to 2.4.20 format
16 * (HX model works fine now, ID table should be brought up to date)
18 static int pl2303_write (struct usb_serial_port *port, int from_user,
19 const unsigned char *buf, int count);
20 static void pl2303_break_ctl(struct usb_serial_port *port,int break_state);
21 -static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file);
22 -static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
23 - unsigned int set, unsigned int clear);
24 +static int pl2303_tiocmget (struct usb_serial_port *port, unsigned int* value);
25 +static int pl2303_tiocmset (struct usb_serial_port *port, unsigned int cmd, unsigned int *value);
26 static int pl2303_startup (struct usb_serial *serial);
27 static void pl2303_shutdown (struct usb_serial *serial);
29 @@ -642,11 +648,108 @@
35 +static int pl2303_tiocmget (struct usb_serial_port *port, unsigned int *value)
37 + struct pl2303_private *priv = usb_get_serial_port_data(port);
38 + unsigned long flags;
40 + unsigned int status;
41 + unsigned int result;
43 + dbg("%s (%d)", __FUNCTION__, port->number);
45 + spin_lock_irqsave (&priv->lock, flags);
46 + mcr = priv->line_control;
47 + status = priv->line_status;
48 + spin_unlock_irqrestore (&priv->lock, flags);
50 + result = ((mcr & CONTROL_DTR) ? TIOCM_DTR : 0)
51 + | ((mcr & CONTROL_RTS) ? TIOCM_RTS : 0)
52 + | ((status & UART_CTS) ? TIOCM_CTS : 0)
53 + | ((status & UART_DSR) ? TIOCM_DSR : 0)
54 + | ((status & UART_RING) ? TIOCM_RI : 0)
55 + | ((status & UART_DCD) ? TIOCM_CD : 0);
57 + dbg("%s - result = %x", __FUNCTION__, result);
59 + if (copy_to_user(value, &result, sizeof(int)))
66 +static int pl2303_tiocmset (struct usb_serial_port *port, unsigned int cmd, unsigned int *value)
69 + struct pl2303_private *priv = usb_get_serial_port_data(port);
70 + unsigned long flags;
73 + spin_lock_irqsave (&priv->lock, flags);
74 + if (set & TIOCM_RTS)
75 + priv->line_control |= CONTROL_RTS;
76 + if (set & TIOCM_DTR)
77 + priv->line_control |= CONTROL_DTR;
78 + if (clear & TIOCM_RTS)
79 + priv->line_control &= ~CONTROL_RTS;
80 + if (clear & TIOCM_DTR)
81 + priv->line_control &= ~CONTROL_DTR;
82 + control = priv->line_control;
83 + spin_unlock_irqrestore (&priv->lock, flags);
85 + return set_control_lines (port->serial->dev, control);
87 + struct pl2303_private *priv = port->private;
90 + if (copy_from_user(&arg, value, sizeof(int)))
95 + if (arg & TIOCM_RTS)
96 + priv->line_control |= CONTROL_RTS;
97 + if (arg & TIOCM_DTR)
98 + priv->line_control |= CONTROL_DTR;
102 + if (arg & TIOCM_RTS)
103 + priv->line_control &= ~CONTROL_RTS;
104 + if (arg & TIOCM_DTR)
105 + priv->line_control &= ~CONTROL_DTR;
109 + /* turn off RTS and DTR and then only turn
110 + on what was asked to */
111 + priv->line_control &= ~(CONTROL_RTS | CONTROL_DTR);
112 + priv->line_control |= ((arg & TIOCM_RTS) ? CONTROL_RTS : 0);
113 + priv->line_control |= ((arg & TIOCM_DTR) ? CONTROL_DTR : 0);
117 + return set_control_lines (port->serial->dev, priv->line_control);
122 static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg)
124 dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd);
128 + dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
129 + return pl2303_tiocmget(port,(unsigned int *)arg);
133 + dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, port->number);
134 + return pl2303_tiocmset(port,cmd,(unsigned int*)arg);
136 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number);
137 return wait_modem_info(port, arg);
140 dbg("%s (%d)", __FUNCTION__, port->number);
142 + dbg("%s - urb status %d...", __FUNCTION__, urb->status);
144 switch (urb->status) {