Commit 5fac329f authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] USB: pl2303: add support for new tty tiocmget and tiocmset functions.

parent 16d94a31
......@@ -124,6 +124,9 @@ static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
static int pl2303_write (struct usb_serial_port *port, int from_user,
const unsigned char *buf, int count);
static void pl2303_break_ctl(struct usb_serial_port *port,int break_state);
static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file);
static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
unsigned int set, unsigned int clear);
static int pl2303_startup (struct usb_serial *serial);
static void pl2303_shutdown (struct usb_serial *serial);
......@@ -143,6 +146,8 @@ static struct usb_serial_device_type pl2303_device = {
.ioctl = pl2303_ioctl,
.break_ctl = pl2303_break_ctl,
.set_termios = pl2303_set_termios,
.tiocmget = pl2303_tiocmget,
.tiocmset = pl2303_tiocmset,
.read_bulk_callback = pl2303_read_bulk_callback,
.read_int_callback = pl2303_read_int_callback,
.write_bulk_callback = pl2303_write_bulk_callback,
......@@ -490,51 +495,35 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
}
static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value)
static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
unsigned int set, unsigned int clear)
{
struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned int arg;
u8 control;
if (copy_from_user(&arg, value, sizeof(int)))
return -EFAULT;
spin_lock (&priv->lock);
switch (cmd) {
case TIOCMBIS:
if (arg & TIOCM_RTS)
if (set & TIOCM_RTS)
priv->line_control |= CONTROL_RTS;
if (arg & TIOCM_DTR)
if (set & TIOCM_DTR)
priv->line_control |= CONTROL_DTR;
break;
case TIOCMBIC:
if (arg & TIOCM_RTS)
if (clear & TIOCM_RTS)
priv->line_control &= ~CONTROL_RTS;
if (arg & TIOCM_DTR)
if (clear & TIOCM_DTR)
priv->line_control &= ~CONTROL_DTR;
break;
case TIOCMSET:
/* turn off RTS and DTR and then only turn
on what was asked to */
priv->line_control &= ~(CONTROL_RTS | CONTROL_DTR);
priv->line_control |= ((arg & TIOCM_RTS) ? CONTROL_RTS : 0);
priv->line_control |= ((arg & TIOCM_DTR) ? CONTROL_DTR : 0);
break;
}
control = priv->line_control;
spin_unlock (&priv->lock);
return set_control_lines (port->serial->dev, control);
}
static int get_modem_info (struct usb_serial_port *port, unsigned int *value)
static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file)
{
struct pl2303_private *priv = usb_get_serial_port_data(port);
unsigned int mcr;
unsigned int result;
dbg("%s (%d)", __FUNCTION__, port->number);
spin_lock (&priv->lock);
mcr = priv->line_control;
spin_unlock (&priv->lock);
......@@ -544,9 +533,7 @@ static int get_modem_info (struct usb_serial_port *port, unsigned int *value)
dbg("%s - result = %x", __FUNCTION__, result);
if (copy_to_user(value, &result, sizeof(int)))
return -EFAULT;
return 0;
return result;
}
static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg)
......@@ -554,17 +541,6 @@ static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsign
dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd);
switch (cmd) {
case TIOCMGET:
dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
return get_modem_info (port, (unsigned int *)arg);
case TIOCMBIS:
case TIOCMBIC:
case TIOCMSET:
dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, port->number);
return set_modem_info(port, cmd, (unsigned int *) arg);
default:
dbg("%s not supported = 0x%04x", __FUNCTION__, cmd);
break;
......@@ -573,7 +549,6 @@ static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsign
return -ENOIOCTLCMD;
}
static void pl2303_break_ctl (struct usb_serial_port *port, int break_state)
{
struct usb_serial *serial = port->serial;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment