aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/iuu_phoenix.c
diff options
context:
space:
mode:
authorOlivier Bornet <Olivier.Bornet@puck.ch>2009-06-11 07:54:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-11 11:51:02 -0400
commit96dab77ebf3868cc8723ac95e048e8a9c1dccf22 (patch)
tree3094428021c695250c411ef2240cd030ad8f4e97 /drivers/usb/serial/iuu_phoenix.c
parentcc3447d179d8a5e16807e52b77d7f4c095ffedb7 (diff)
tty: iuu_phoenix: set termios.
set_termios can now be used for setting the parity and the stopbits. This is needed to use with cards which use a different parity then the parity used at start (even). If the iuu_uart_baud function return an error, we will return the old_termios instead of the new one. Signed-off-by: Olivier Bornet <Olivier.Bornet@puck.ch> This was then revamped to use the various helpers, not copy non-hardware bits any to add mark/space parity and csize reporting Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/iuu_phoenix.c')
-rw-r--r--drivers/usb/serial/iuu_phoenix.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index ef6d12fd579c..fa86f6e7415f 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -942,6 +942,55 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud,
942 return status; 942 return status;
943} 943}
944 944
945static void iuu_set_termios(struct tty_struct *tty,
946 struct usb_serial_port *port, struct ktermios *old_termios)
947{
948 const u32 supported_mask = CMSPAR|PARENB|PARODD;
949
950 unsigned int cflag = tty->termios->c_cflag;
951 int status;
952 u32 actual;
953 u32 parity;
954 int csize = CS7;
955 int baud = 9600; /* Fixed for the moment */
956 u32 newval = cflag & supported_mask;
957
958 /* compute the parity parameter */
959 parity = 0;
960 if (cflag & CMSPAR) { /* Using mark space */
961 if (cflag & PARODD)
962 parity |= IUU_PARITY_SPACE;
963 else
964 parity |= IUU_PARITY_MARK;
965 } else if (!(cflag & PARENB)) {
966 parity |= IUU_PARITY_NONE;
967 csize = CS8;
968 } else if (cflag & PARODD)
969 parity |= IUU_PARITY_ODD;
970 else
971 parity |= IUU_PARITY_EVEN;
972
973 parity |= (cflag & CSTOPB ? IUU_TWO_STOP_BITS : IUU_ONE_STOP_BIT);
974
975 /* set it */
976 status = iuu_uart_baud(port,
977 (clockmode == 2) ? 16457 : 9600 * boost / 100,
978 &actual, parity);
979
980 /* set the termios value to the real one, so the user now what has
981 * changed. We support few fields so its easies to copy the old hw
982 * settings back over and then adjust them
983 */
984 if (old_termios)
985 tty_termios_copy_hw(tty->termios, old_termios);
986 if (status != 0) /* Set failed - return old bits */
987 return;
988 /* Re-encode speed, parity and csize */
989 tty_encode_baud_rate(tty, baud, baud);
990 tty->termios->c_cflag &= ~(supported_mask|CSIZE);
991 tty->termios->c_cflag |= newval | csize;
992}
993
945static void iuu_close(struct usb_serial_port *port) 994static void iuu_close(struct usb_serial_port *port)
946{ 995{
947 /* iuu_led (port,255,0,0,0); */ 996 /* iuu_led (port,255,0,0,0); */
@@ -1151,6 +1200,7 @@ static struct usb_serial_driver iuu_device = {
1151 .read_bulk_callback = iuu_uart_read_callback, 1200 .read_bulk_callback = iuu_uart_read_callback,
1152 .tiocmget = iuu_tiocmget, 1201 .tiocmget = iuu_tiocmget,
1153 .tiocmset = iuu_tiocmset, 1202 .tiocmset = iuu_tiocmset,
1203 .set_termios = iuu_set_termios,
1154 .attach = iuu_startup, 1204 .attach = iuu_startup,
1155 .shutdown = iuu_shutdown, 1205 .shutdown = iuu_shutdown,
1156}; 1206};