104
106
static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file);
105
107
static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file,
106
108
unsigned int set, unsigned int clear);
109
static int mct_u232_ioctl(struct tty_struct *tty, struct file *file,
110
unsigned int cmd, unsigned long arg);
111
static int mct_u232_get_icount(struct tty_struct *tty,
112
struct serial_icounter_struct *icount);
107
113
static void mct_u232_throttle(struct tty_struct *tty);
108
114
static void mct_u232_unthrottle(struct tty_struct *tty);
150
156
.tiocmset = mct_u232_tiocmset,
151
157
.attach = mct_u232_startup,
152
158
.release = mct_u232_release,
159
.ioctl = mct_u232_ioctl,
160
.get_icount = mct_u232_get_icount,
156
163
struct mct_u232_private {
158
165
unsigned int control_state; /* Modem Line Setting (TIOCM) */
387
397
} /* mct_u232_get_modem_stat */
399
static void mct_u232_msr_to_icount(struct async_icount *icount,
402
/* Translate Control Line states */
403
if (msr & MCT_U232_MSR_DDSR)
405
if (msr & MCT_U232_MSR_DCTS)
407
if (msr & MCT_U232_MSR_DRI)
409
if (msr & MCT_U232_MSR_DCD)
411
} /* mct_u232_msr_to_icount */
389
413
static void mct_u232_msr_to_state(unsigned int *control_state,
390
414
unsigned char msr)
877
static int mct_u232_ioctl(struct tty_struct *tty, struct file *file,
878
unsigned int cmd, unsigned long arg)
881
struct usb_serial_port *port = tty->driver_data;
882
struct mct_u232_private *mct_u232_port = usb_get_serial_port_data(port);
883
struct async_icount cnow, cprev;
886
dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
892
dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
894
spin_lock_irqsave(&mct_u232_port->lock, flags);
895
cprev = mct_u232_port->icount;
896
spin_unlock_irqrestore(&mct_u232_port->lock, flags);
898
prepare_to_wait(&mct_u232_port->msr_wait,
899
&wait, TASK_INTERRUPTIBLE);
901
finish_wait(&mct_u232_port->msr_wait, &wait);
902
/* see if a signal did it */
903
if (signal_pending(current))
905
spin_lock_irqsave(&mct_u232_port->lock, flags);
906
cnow = mct_u232_port->icount;
907
spin_unlock_irqrestore(&mct_u232_port->lock, flags);
908
if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
909
cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
910
return -EIO; /* no change => error */
911
if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
912
((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
913
((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
914
((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
924
static int mct_u232_get_icount(struct tty_struct *tty,
925
struct serial_icounter_struct *icount)
927
struct usb_serial_port *port = tty->driver_data;
928
struct mct_u232_private *mct_u232_port = usb_get_serial_port_data(port);
929
struct async_icount *ic = &mct_u232_port->icount;
932
spin_lock_irqsave(&mct_u232_port->lock, flags);
934
icount->cts = ic->cts;
935
icount->dsr = ic->dsr;
936
icount->rng = ic->rng;
937
icount->dcd = ic->dcd;
940
icount->frame = ic->frame;
941
icount->overrun = ic->overrun;
942
icount->parity = ic->parity;
943
icount->brk = ic->brk;
944
icount->buf_overrun = ic->buf_overrun;
946
spin_unlock_irqrestore(&mct_u232_port->lock, flags);
948
dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d",
949
__func__, port->number, icount->rx, icount->tx);
850
953
static int __init mct_u232_init(void)