Commit 16d94a31 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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

parent 7e40f256
...@@ -125,7 +125,11 @@ static int mct_u232_ioctl (struct usb_serial_port *port, ...@@ -125,7 +125,11 @@ static int mct_u232_ioctl (struct usb_serial_port *port,
unsigned long arg); unsigned long arg);
static void mct_u232_break_ctl (struct usb_serial_port *port, static void mct_u232_break_ctl (struct usb_serial_port *port,
int break_state ); int break_state );
static int mct_u232_tiocmget (struct usb_serial_port *port,
struct file *file);
static int mct_u232_tiocmset (struct usb_serial_port *port,
struct file *file, unsigned int set,
unsigned int clear);
/* /*
* All of the device info needed for the MCT USB-RS232 converter. * All of the device info needed for the MCT USB-RS232 converter.
*/ */
...@@ -165,6 +169,8 @@ static struct usb_serial_device_type mct_u232_device = { ...@@ -165,6 +169,8 @@ static struct usb_serial_device_type mct_u232_device = {
.ioctl = mct_u232_ioctl, .ioctl = mct_u232_ioctl,
.set_termios = mct_u232_set_termios, .set_termios = mct_u232_set_termios,
.break_ctl = mct_u232_break_ctl, .break_ctl = mct_u232_break_ctl,
.tiocmget = mct_u232_tiocmget,
.tiocmset = mct_u232_tiocmset,
.attach = mct_u232_startup, .attach = mct_u232_startup,
.shutdown = mct_u232_shutdown, .shutdown = mct_u232_shutdown,
}; };
...@@ -773,57 +779,55 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) ...@@ -773,57 +779,55 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
} /* mct_u232_break_ctl */ } /* mct_u232_break_ctl */
static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file, static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file)
unsigned int cmd, unsigned long arg)
{ {
struct usb_serial *serial = port->serial;
struct mct_u232_private *priv = usb_get_serial_port_data(port); struct mct_u232_private *priv = usb_get_serial_port_data(port);
int mask;
unsigned long control_state; unsigned long control_state;
unsigned long flags; unsigned long flags;
dbg("%scmd=0x%x", __FUNCTION__, cmd); dbg("%s", __FUNCTION__);
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
control_state = priv->control_state; control_state = priv->control_state;
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
/* Based on code from acm.c and others */ return control_state;
switch (cmd) { }
case TIOCMGET:
return put_user(control_state, (unsigned long *) arg);
break;
case TIOCMSET: /* Turns on and off the lines as specified by the mask */ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file,
case TIOCMBIS: /* turns on (Sets) the lines as specified by the mask */ unsigned int set, unsigned int clear)
case TIOCMBIC: /* turns off (Clears) the lines as specified by the mask */ {
if (get_user(mask, (unsigned long *) arg)) struct usb_serial *serial = port->serial;
return -EFAULT; struct mct_u232_private *priv = usb_get_serial_port_data(port);
unsigned long control_state;
unsigned long flags;
if ((cmd == TIOCMSET) || (mask & TIOCM_RTS)) { dbg("%s", __FUNCTION__);
/* RTS needs set */
if( ((cmd == TIOCMSET) && (mask & TIOCM_RTS)) ||
(cmd == TIOCMBIS) )
control_state |= TIOCM_RTS;
else
control_state &= ~TIOCM_RTS;
}
if ((cmd == TIOCMSET) || (mask & TIOCM_DTR)) { spin_lock_irqsave(&priv->lock, flags);
/* DTR needs set */ control_state = priv->control_state;
if( ((cmd == TIOCMSET) && (mask & TIOCM_DTR)) ||
(cmd == TIOCMBIS) ) if (set & TIOCM_RTS)
control_state |= TIOCM_RTS;
if (set & TIOCM_DTR)
control_state |= TIOCM_DTR; control_state |= TIOCM_DTR;
else if (clear & TIOCM_RTS)
control_state &= ~TIOCM_RTS;
if (clear & TIOCM_DTR)
control_state &= ~TIOCM_DTR; control_state &= ~TIOCM_DTR;
}
mct_u232_set_modem_ctrl(serial, control_state);
spin_lock_irqsave(&priv->lock, flags);
priv->control_state = control_state; priv->control_state = control_state;
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
break; return mct_u232_set_modem_ctrl(serial, control_state);
}
static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file,
unsigned int cmd, unsigned long arg)
{
dbg("%scmd=0x%x", __FUNCTION__, cmd);
/* Based on code from acm.c and others */
switch (cmd) {
case TIOCMIWAIT: case TIOCMIWAIT:
/* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/ /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
/* TODO */ /* TODO */
......
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