aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2009-04-07 11:48:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-07 11:44:05 -0400
commit0c212603981abb9bb8fe4ed1eec521dc18be02b9 (patch)
tree1230d3a89f8dc9a6a631c3aed2e7969648128223
parent6fd1af4cf98936f4034caf8f132c7826a6ffd0fa (diff)
serqt: initial clean up pass for tty side
Avoid using port->tty where possible (makes refcount fixing easier later). Remove unused code (the ioctl path is not used if the device has mget/mset functions) Remove various un-needed typecasts and long names so it could read it to do the changes. Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/staging/serqt_usb/serqt_usb.c449
1 files changed, 163 insertions, 286 deletions
diff --git a/drivers/staging/serqt_usb/serqt_usb.c b/drivers/staging/serqt_usb/serqt_usb.c
index 1781510c53fd..234f332fc82f 100644
--- a/drivers/staging/serqt_usb/serqt_usb.c
+++ b/drivers/staging/serqt_usb/serqt_usb.c
@@ -289,7 +289,8 @@ static void serial_unthrottle(struct tty_struct *tty);
289static int serial_break(struct tty_struct *tty, int break_state); 289static int serial_break(struct tty_struct *tty, int break_state);
290static int serial_chars_in_buffer(struct tty_struct *tty); 290static int serial_chars_in_buffer(struct tty_struct *tty);
291 291
292static int qt_open(struct usb_serial_port *port, struct file *filp); 292static int qt_open(struct tty_struct *tty, struct usb_serial_port *port,
293 struct file *filp);
293static int BoxSetPrebufferLevel(struct usb_serial *serial); 294static int BoxSetPrebufferLevel(struct usb_serial *serial);
294 295
295static int BoxSetATC(struct usb_serial *serial, __u16 n_Mode); 296static int BoxSetATC(struct usb_serial *serial, __u16 n_Mode);
@@ -300,24 +301,26 @@ static int BoxSetUart(struct usb_serial *serial, unsigned short Uart_Number,
300static int BoxOPenCloseChannel(struct usb_serial *serial, __u16 Uart_Number, 301static int BoxOPenCloseChannel(struct usb_serial *serial, __u16 Uart_Number,
301 __u16 OpenClose, 302 __u16 OpenClose,
302 struct qt_open_channel_data *pDeviceData); 303 struct qt_open_channel_data *pDeviceData);
303static void qt_close(struct usb_serial_port *port, struct file *filp); 304static void qt_close(struct tty_struct *tty, struct usb_serial_port *port,
305 struct file *filp);
304static int BoxGetRegister(struct usb_serial *serial, unsigned short Uart_Number, 306static int BoxGetRegister(struct usb_serial *serial, unsigned short Uart_Number,
305 unsigned short Register_Num, __u8 *pValue); 307 unsigned short Register_Num, __u8 *pValue);
306static int BoxSetRegister(struct usb_serial *serial, unsigned short Uart_Number, 308static int BoxSetRegister(struct usb_serial *serial, unsigned short Uart_Number,
307 unsigned short Register_Num, unsigned short Value); 309 unsigned short Register_Num, unsigned short Value);
308static void qt_write_bulk_callback(struct urb *urb); 310static void qt_write_bulk_callback(struct urb *urb);
309static int qt_write(struct usb_serial_port *port, int from_user, 311static int qt_write(struct tty_struct *tty, struct usb_serial_port *port,
310 const unsigned char *buf, int count); 312 const unsigned char *buf, int count);
311static void port_softint(struct work_struct *work); 313static void port_softint(struct work_struct *work);
312static int qt_write_room(struct usb_serial_port *port); 314static int qt_write_room(struct usb_serial_port *port);
313static int qt_chars_in_buffer(struct usb_serial_port *port); 315static int qt_chars_in_buffer(struct usb_serial_port *port);
314static int qt_ioctl(struct usb_serial_port *port, struct file *file, 316static int qt_ioctl(struct tty_struct *tty, struct usb_serial_port *port,
315 unsigned int cmd, unsigned long arg); 317 struct file *file, unsigned int cmd, unsigned long arg);
316static void qt_set_termios(struct usb_serial_port *port, 318static void qt_set_termios(struct tty_struct *tty,
319 struct usb_serial_port *port,
317 struct ktermios *old_termios); 320 struct ktermios *old_termios);
318static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int UartNumber, 321static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int index,
319 int bSet); 322 int bSet);
320static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber); 323static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 index);
321static int EmulateWriteQMCR_Reg(int index, unsigned uc_value); 324static int EmulateWriteQMCR_Reg(int index, unsigned uc_value);
322static int EmulateReadQMCR_Reg(int index, unsigned *uc_value); 325static int EmulateReadQMCR_Reg(int index, unsigned *uc_value);
323static struct usb_serial *find_the_box(unsigned int index); 326static struct usb_serial *find_the_box(unsigned int index);
@@ -336,10 +339,11 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file,
336 unsigned int set, unsigned int clear); 339 unsigned int set, unsigned int clear);
337static int serial_tiocmget(struct tty_struct *tty, struct file *file); 340static int serial_tiocmget(struct tty_struct *tty, struct file *file);
338 341
339static int qt_tiocmset(struct usb_serial_port *port, struct file *file, 342static int qt_tiocmset(struct tty_struct *tty, struct usb_serial_port *port,
340 unsigned int value); 343 struct file *file, unsigned int value);
341 344
342static int qt_tiocmget(struct usb_serial_port *port, struct file *file); 345static int qt_tiocmget(struct tty_struct *tty, struct usb_serial_port *port,
346 struct file *file);
343 347
344/* Version Information */ 348/* Version Information */
345#define DRIVER_VERSION "v2.14" 349#define DRIVER_VERSION "v2.14"
@@ -818,7 +822,7 @@ static struct usb_serial *get_free_serial(int num_ports, int *minor)
818 return NULL; 822 return NULL;
819} 823}
820 824
821static int flip_that(struct tty_struct *tty, __u16 UartNumber, 825static int flip_that(struct tty_struct *tty, __u16 index,
822 struct usb_serial *serial) 826 struct usb_serial *serial)
823{ 827{
824 tty_flip_buffer_push(tty); 828 tty_flip_buffer_push(tty);
@@ -829,18 +833,18 @@ static int flip_that(struct tty_struct *tty, __u16 UartNumber,
829/* Handles processing and moving data to the tty layer */ 833/* Handles processing and moving data to the tty layer */
830static void port_sofrint(void *private) 834static void port_sofrint(void *private)
831{ 835{
832 struct usb_serial_port *port = (struct usb_serial_port *)private; 836 struct usb_serial_port *port = private;
833 struct usb_serial *serial = get_usb_serial(port, __func__); 837 struct usb_serial *serial = get_usb_serial(port, __func__);
834 struct tty_struct *tty = port->tty; 838 struct tty_struct *tty = port->tty;
835 unsigned char *data = port->read_urb->transfer_buffer; 839 unsigned char *data = port->read_urb->transfer_buffer;
836 unsigned int UartNumber; 840 unsigned int index;
837 struct urb *urb = port->read_urb; 841 struct urb *urb = port->read_urb;
838 unsigned int RxCount = urb->actual_length; 842 unsigned int RxCount = urb->actual_length;
839 int i, result; 843 int i, result;
840 int flag, flag_data; 844 int flag, flag_data;
841 845
842 /* UartNumber = MINOR(port->tty->device) - serial->minor; */ 846 /* index = MINOR(port->tty->device) - serial->minor; */
843 UartNumber = tty->index - serial->minor; 847 index = tty->index - serial->minor;
844 848
845 mydbg("%s - port %d\n", __func__, port->number); 849 mydbg("%s - port %d\n", __func__, port->number);
846 mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding); 850 mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding);
@@ -948,7 +952,7 @@ static void port_sofrint(void *private)
948 __func__, result); 952 __func__, result);
949 else { 953 else {
950 if (tty && RxCount) 954 if (tty && RxCount)
951 flip_that(tty, UartNumber, serial); 955 flip_that(tty, index, serial);
952 } 956 }
953 957
954 return; 958 return;
@@ -1097,7 +1101,7 @@ static int serial_open(struct tty_struct *tty, struct file *filp)
1097 port->RxHolding = 0; 1101 port->RxHolding = 0;
1098 mydbg("%s port->RxHolding = 0\n", __func__); 1102 mydbg("%s port->RxHolding = 0\n", __func__);
1099 1103
1100 retval = qt_open(port, filp); 1104 retval = qt_open(tty, port, filp);
1101 } 1105 }
1102 1106
1103 if (retval) 1107 if (retval)
@@ -1112,11 +1116,12 @@ static int serial_open(struct tty_struct *tty, struct file *filp)
1112/***************************************************************************** 1116/*****************************************************************************
1113 *device's specific driver functions 1117 *device's specific driver functions
1114 *****************************************************************************/ 1118 *****************************************************************************/
1115static int qt_open(struct usb_serial_port *port, struct file *filp) 1119static int qt_open(struct tty_struct *tty, struct usb_serial_port *port,
1120 struct file *filp)
1116{ 1121{
1117 struct usb_serial *serial = port->serial; 1122 struct usb_serial *serial = port->serial;
1118 int result = 0; 1123 int result = 0;
1119 unsigned int UartNumber; 1124 unsigned int index;
1120 struct qt_get_device_data DeviceData; 1125 struct qt_get_device_data DeviceData;
1121 struct qt_open_channel_data ChannelData; 1126 struct qt_open_channel_data ChannelData;
1122 unsigned short default_divisor = 0x30; /* gives 9600 baud rate */ 1127 unsigned short default_divisor = 0x30; /* gives 9600 baud rate */
@@ -1128,13 +1133,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
1128 1133
1129 mydbg("%s - port %d\n", __func__, port->number); 1134 mydbg("%s - port %d\n", __func__, port->number);
1130 1135
1131 /* force low_latency on so that our tty_push actually forces the data through, 1136 index = tty->index - serial->minor;
1132 otherwise it is scheduled, and with high data rates (like with OHCI) data
1133 can get lost. */
1134 if (port->tty)
1135 port->tty->low_latency = 0;
1136
1137 UartNumber = port->tty->index - serial->minor;
1138 1137
1139 status = box_get_device(serial, &DeviceData); 1138 status = box_get_device(serial, &DeviceData);
1140 if (status < 0) { 1139 if (status < 0) {
@@ -1147,7 +1146,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
1147 /* Open uart channel */ 1146 /* Open uart channel */
1148 1147
1149 /* Port specific setups */ 1148 /* Port specific setups */
1150 status = BoxOPenCloseChannel(serial, UartNumber, 1, &ChannelData); 1149 status = BoxOPenCloseChannel(serial, index, 1, &ChannelData);
1151 if (status < 0) { 1150 if (status < 0) {
1152 mydbg(__FILE__ "BoxOPenCloseChannel failed\n"); 1151 mydbg(__FILE__ "BoxOPenCloseChannel failed\n");
1153 return status; 1152 return status;
@@ -1161,7 +1160,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
1161 (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_CD); 1160 (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_CD);
1162 1161
1163 /* Set Baud rate to default and turn off (default)flow control here */ 1162 /* Set Baud rate to default and turn off (default)flow control here */
1164 status = BoxSetUart(serial, UartNumber, default_divisor, default_LCR); 1163 status = BoxSetUart(serial, index, default_divisor, default_LCR);
1165 if (status < 0) { 1164 if (status < 0) {
1166 mydbg(__FILE__ "BoxSetUart failed\n"); 1165 mydbg(__FILE__ "BoxSetUart failed\n");
1167 return status; 1166 return status;
@@ -1169,7 +1168,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
1169 mydbg(__FILE__ "BoxSetUart completed.\n"); 1168 mydbg(__FILE__ "BoxSetUart completed.\n");
1170 1169
1171 /* Put this here to make it responsive to stty and defauls set by the tty layer */ 1170 /* Put this here to make it responsive to stty and defauls set by the tty layer */
1172 qt_set_termios(port, NULL); 1171 qt_set_termios(tty, port, NULL);
1173 1172
1174 /* Initialize the wait que head */ 1173 /* Initialize the wait que head */
1175 init_waitqueue_head(&(port->wait)); 1174 init_waitqueue_head(&(port->wait));
@@ -1203,7 +1202,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp)
1203static void serial_close(struct tty_struct *tty, struct file *filp) 1202static void serial_close(struct tty_struct *tty, struct file *filp)
1204{ 1203{
1205 struct usb_serial_port *port = 1204 struct usb_serial_port *port =
1206 (struct usb_serial_port *)tty->driver_data; 1205 tty->driver_data;
1207 struct usb_serial *serial = get_usb_serial(port, __func__); 1206 struct usb_serial *serial = get_usb_serial(port, __func__);
1208 1207
1209 if (!serial) 1208 if (!serial)
@@ -1226,7 +1225,7 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
1226 mydbg("%s - port->closePending = 1\n", __func__); 1225 mydbg("%s - port->closePending = 1\n", __func__);
1227 1226
1228 if (serial->dev) { 1227 if (serial->dev) {
1229 qt_close(port, filp); 1228 qt_close(tty, port, filp);
1230 port->open_count = 0; 1229 port->open_count = 0;
1231 } 1230 }
1232 } 1231 }
@@ -1240,20 +1239,21 @@ exit:
1240 1239
1241} 1240}
1242 1241
1243static void qt_close(struct usb_serial_port *port, struct file *filp) 1242static void qt_close(struct tty_struct *tty, struct usb_serial_port *port,
1243 struct file *filp)
1244{ 1244{
1245 unsigned long jift = jiffies + 10 * HZ; 1245 unsigned long jift = jiffies + 10 * HZ;
1246 __u8 LSR_Value, MCR_Value; 1246 u8 lsr, mcr;
1247 struct usb_serial *serial = port->serial; 1247 struct usb_serial *serial = port->serial;
1248 int status; 1248 int status;
1249 unsigned int UartNumber; 1249 unsigned int index;
1250 1250
1251 struct qt_open_channel_data ChannelData; 1251 struct qt_open_channel_data ChannelData;
1252 status = 0; 1252 status = 0;
1253 LSR_Value = 0; 1253 lsr = 0;
1254 1254
1255 mydbg("%s - port %d\n", __func__, port->number); 1255 mydbg("%s - port %d\n", __func__, port->number);
1256 UartNumber = port->tty->index - serial->minor; 1256 index = tty->index - serial->minor;
1257 1257
1258 /* shutdown any bulk reads that might be going on */ 1258 /* shutdown any bulk reads that might be going on */
1259 if (serial->num_bulk_out) 1259 if (serial->num_bulk_out)
@@ -1263,20 +1263,19 @@ static void qt_close(struct usb_serial_port *port, struct file *filp)
1263 1263
1264 /* wait up to 30 seconds for transmitter to empty */ 1264 /* wait up to 30 seconds for transmitter to empty */
1265 do { 1265 do {
1266 status = BoxGetRegister(serial, UartNumber, LINE_STATUS_REGISTER, &LSR_Value); 1266 status = BoxGetRegister(serial, index, LINE_STATUS_REGISTER, &lsr);
1267 if (status < 0) { 1267 if (status < 0) {
1268 mydbg(__FILE__ "box_get_device failed\n"); 1268 mydbg(__FILE__ "box_get_device failed\n");
1269 break; 1269 break;
1270 } 1270 }
1271 1271
1272 if ((LSR_Value & SERIAL_LSR_TEMT) 1272 if ((lsr & SERIAL_LSR_TEMT)
1273 && (port->ReadBulkStopped == 1)) 1273 && (port->ReadBulkStopped == 1))
1274 break; 1274 break;
1275 schedule(); 1275 schedule();
1276 1276
1277 } 1277 }
1278 while (jiffies <= jift) 1278 while (jiffies <= jift);
1279 ;
1280 1279
1281 if (jiffies > jift) 1280 if (jiffies > jift)
1282 mydbg("%s - port %d timout of checking transmitter empty\n", 1281 mydbg("%s - port %d timout of checking transmitter empty\n",
@@ -1286,17 +1285,17 @@ static void qt_close(struct usb_serial_port *port, struct file *filp)
1286 __func__, port->number); 1285 __func__, port->number);
1287 1286
1288 status = 1287 status =
1289 BoxGetRegister(serial, UartNumber, MODEM_CONTROL_REGISTER, 1288 BoxGetRegister(serial, index, MODEM_CONTROL_REGISTER,
1290 &MCR_Value); 1289 &mcr);
1291 mydbg(__FILE__ "BoxGetRegister MCR = 0x%x.\n", MCR_Value); 1290 mydbg(__FILE__ "BoxGetRegister MCR = 0x%x.\n", mcr);
1292 1291
1293 if (status >= 0) { 1292 if (status >= 0) {
1294 MCR_Value &= ~(SERIAL_MCR_DTR | SERIAL_MCR_RTS); 1293 mcr &= ~(SERIAL_MCR_DTR | SERIAL_MCR_RTS);
1295 /* status = BoxSetRegister(serial, UartNumber, MODEM_CONTROL_REGISTER, MCR_Value); */ 1294 /* status = BoxSetRegister(serial, index, MODEM_CONTROL_REGISTER, mcr); */
1296 } 1295 }
1297 1296
1298 /* Close uart channel */ 1297 /* Close uart channel */
1299 status = BoxOPenCloseChannel(serial, UartNumber, 0, &ChannelData); 1298 status = BoxOPenCloseChannel(serial, index, 0, &ChannelData);
1300 if (status < 0) 1299 if (status < 0)
1301 mydbg("%s - port %d BoxOPenCloseChannel failed.\n", 1300 mydbg("%s - port %d BoxOPenCloseChannel failed.\n",
1302 __func__, port->number); 1301 __func__, port->number);
@@ -1308,12 +1307,10 @@ static void qt_close(struct usb_serial_port *port, struct file *filp)
1308static int serial_write(struct tty_struct *tty, const unsigned char *buf, 1307static int serial_write(struct tty_struct *tty, const unsigned char *buf,
1309 int count) 1308 int count)
1310{ 1309{
1311 struct usb_serial_port *port = 1310 struct usb_serial_port *port = tty->driver_data;
1312 (struct usb_serial_port *)tty->driver_data;
1313 struct usb_serial *serial; 1311 struct usb_serial *serial;
1314 int retval = -EINVAL; 1312 int retval = -EINVAL;
1315 unsigned int UartNumber; 1313 unsigned int index;
1316 int from_user = 0;
1317 1314
1318 serial = get_usb_serial(port, __func__); 1315 serial = get_usb_serial(port, __func__);
1319 if (serial == NULL) 1316 if (serial == NULL)
@@ -1321,7 +1318,7 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf,
1321 /* This can happen if we get disconnected a */ 1318 /* This can happen if we get disconnected a */
1322 if (port->open_count == 0) 1319 if (port->open_count == 0)
1323 return -ENODEV; 1320 return -ENODEV;
1324 UartNumber = port->tty->index - serial->minor; 1321 index = tty->index - serial->minor;
1325 1322
1326 mydbg("%s - port %d, %d byte(s)\n", __func__, port->number, count); 1323 mydbg("%s - port %d, %d byte(s)\n", __func__, port->number, count);
1327 mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding); 1324 mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding);
@@ -1331,19 +1328,19 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf,
1331 goto exit; 1328 goto exit;
1332 } 1329 }
1333 1330
1334 retval = qt_write(port, from_user, buf, count); 1331 retval = qt_write(tty, port, buf, count);
1335 1332
1336exit: 1333exit:
1337 return retval; 1334 return retval;
1338} 1335}
1339 1336
1340static int qt_write(struct usb_serial_port *port, int from_user, 1337static int qt_write(struct tty_struct *tty, struct usb_serial_port *port,
1341 const unsigned char *buf, int count) 1338 const unsigned char *buf, int count)
1342{ 1339{
1343 int result; 1340 int result;
1344 unsigned int UartNumber; 1341 unsigned int index;
1345
1346 struct usb_serial *serial = get_usb_serial(port, __func__); 1342 struct usb_serial *serial = get_usb_serial(port, __func__);
1343
1347 if (serial == NULL) 1344 if (serial == NULL)
1348 return -ENODEV; 1345 return -ENODEV;
1349 1346
@@ -1354,7 +1351,7 @@ static int qt_write(struct usb_serial_port *port, int from_user,
1354 return 0; 1351 return 0;
1355 } 1352 }
1356 1353
1357 UartNumber = port->tty->index - serial->minor; 1354 index = tty->index - serial->minor;
1358 /* only do something if we have a bulk out endpoint */ 1355 /* only do something if we have a bulk out endpoint */
1359 if (serial->num_bulk_out) { 1356 if (serial->num_bulk_out) {
1360 if (port->write_urb->status == -EINPROGRESS) { 1357 if (port->write_urb->status == -EINPROGRESS) {
@@ -1364,14 +1361,7 @@ static int qt_write(struct usb_serial_port *port, int from_user,
1364 1361
1365 count = 1362 count =
1366 (count > port->bulk_out_size) ? port->bulk_out_size : count; 1363 (count > port->bulk_out_size) ? port->bulk_out_size : count;
1367 1364 memcpy(port->write_urb->transfer_buffer, buf, count);
1368 if (from_user) {
1369 if (copy_from_user
1370 (port->write_urb->transfer_buffer, buf, count))
1371 return -EFAULT;
1372 } else {
1373 memcpy(port->write_urb->transfer_buffer, buf, count);
1374 }
1375 1365
1376 /* usb_serial_debug_data(__FILE__, __func__, count, port->write_urb->transfer_buffer); */ 1366 /* usb_serial_debug_data(__FILE__, __func__, count, port->write_urb->transfer_buffer); */
1377 1367
@@ -1449,8 +1439,7 @@ static void port_softint(struct work_struct *work)
1449} 1439}
1450static int serial_write_room(struct tty_struct *tty) 1440static int serial_write_room(struct tty_struct *tty)
1451{ 1441{
1452 struct usb_serial_port *port = 1442 struct usb_serial_port *port = tty->driver_data;
1453 (struct usb_serial_port *)tty->driver_data;
1454 struct usb_serial *serial = get_usb_serial(port, __func__); 1443 struct usb_serial *serial = get_usb_serial(port, __func__);
1455 int retval = -EINVAL; 1444 int retval = -EINVAL;
1456 1445
@@ -1493,8 +1482,7 @@ static int qt_write_room(struct usb_serial_port *port)
1493} 1482}
1494static int serial_chars_in_buffer(struct tty_struct *tty) 1483static int serial_chars_in_buffer(struct tty_struct *tty)
1495{ 1484{
1496 struct usb_serial_port *port = 1485 struct usb_serial_port *port = tty->driver_data;
1497 (struct usb_serial_port *)tty->driver_data;
1498 struct usb_serial *serial = get_usb_serial(port, __func__); 1486 struct usb_serial *serial = get_usb_serial(port, __func__);
1499 int retval = -EINVAL; 1487 int retval = -EINVAL;
1500 1488
@@ -1537,17 +1525,16 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file,
1537 unsigned int set, unsigned int clear) 1525 unsigned int set, unsigned int clear)
1538{ 1526{
1539 1527
1540 struct usb_serial_port *port = 1528 struct usb_serial_port *port = tty->driver_data;
1541 (struct usb_serial_port *)tty->driver_data;
1542 struct usb_serial *serial = get_usb_serial(port, __func__); 1529 struct usb_serial *serial = get_usb_serial(port, __func__);
1543 int retval = -ENODEV; 1530 int retval = -ENODEV;
1544 unsigned int UartNumber; 1531 unsigned int index;
1545 mydbg("In %s \n", __func__); 1532 mydbg("In %s \n", __func__);
1546 1533
1547 if (!serial) 1534 if (!serial)
1548 return -ENODEV; 1535 return -ENODEV;
1549 1536
1550 UartNumber = port->tty->index - serial->minor; 1537 index = tty->index - serial->minor;
1551 1538
1552 down(&port->sem); 1539 down(&port->sem);
1553 1540
@@ -1559,22 +1546,22 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file,
1559 goto exit; 1546 goto exit;
1560 } 1547 }
1561 1548
1562 retval = qt_tiocmset(port, file, set); 1549 retval = qt_tiocmset(tty, port, file, set);
1563 1550
1564exit: 1551exit:
1565 up(&port->sem); 1552 up(&port->sem);
1566 return retval; 1553 return retval;
1567} 1554}
1568 1555
1569static int qt_tiocmset(struct usb_serial_port *port, struct file *file, 1556static int qt_tiocmset(struct tty_struct *tty, struct usb_serial_port *port,
1570 unsigned int value) 1557 struct file *file, unsigned int value)
1571{ 1558{
1572 1559
1573 __u8 MCR_Value; 1560 u8 mcr;
1574 int status; 1561 int status;
1575 unsigned int UartNumber; 1562 unsigned int index;
1576
1577 struct usb_serial *serial = get_usb_serial(port, __func__); 1563 struct usb_serial *serial = get_usb_serial(port, __func__);
1564
1578 if (serial == NULL) 1565 if (serial == NULL)
1579 return -ENODEV; 1566 return -ENODEV;
1580 1567
@@ -1583,10 +1570,10 @@ static int qt_tiocmset(struct usb_serial_port *port, struct file *file,
1583 /**************************************************************************************/ 1570 /**************************************************************************************/
1584 /** TIOCMGET 1571 /** TIOCMGET
1585 */ 1572 */
1586 UartNumber = port->tty->index - serial->minor; 1573 index = tty->index - serial->minor;
1587 status = 1574 status =
1588 BoxGetRegister(port->serial, UartNumber, MODEM_CONTROL_REGISTER, 1575 BoxGetRegister(port->serial, index, MODEM_CONTROL_REGISTER,
1589 &MCR_Value); 1576 &mcr);
1590 if (status < 0) 1577 if (status < 0)
1591 return -ESPIPE; 1578 return -ESPIPE;
1592 1579
@@ -1594,17 +1581,17 @@ static int qt_tiocmset(struct usb_serial_port *port, struct file *file,
1594 * Turn off the RTS and DTR and loopbcck and then only turn on what was 1581 * Turn off the RTS and DTR and loopbcck and then only turn on what was
1595 * asked for 1582 * asked for
1596 */ 1583 */
1597 MCR_Value &= ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | SERIAL_MCR_LOOP); 1584 mcr &= ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | SERIAL_MCR_LOOP);
1598 if (value & TIOCM_RTS) 1585 if (value & TIOCM_RTS)
1599 MCR_Value |= SERIAL_MCR_RTS; 1586 mcr |= SERIAL_MCR_RTS;
1600 if (value & TIOCM_DTR) 1587 if (value & TIOCM_DTR)
1601 MCR_Value |= SERIAL_MCR_DTR; 1588 mcr |= SERIAL_MCR_DTR;
1602 if (value & TIOCM_LOOP) 1589 if (value & TIOCM_LOOP)
1603 MCR_Value |= SERIAL_MCR_LOOP; 1590 mcr |= SERIAL_MCR_LOOP;
1604 1591
1605 status = 1592 status =
1606 BoxSetRegister(port->serial, UartNumber, MODEM_CONTROL_REGISTER, 1593 BoxSetRegister(port->serial, index, MODEM_CONTROL_REGISTER,
1607 MCR_Value); 1594 mcr);
1608 if (status < 0) 1595 if (status < 0)
1609 return -ESPIPE; 1596 return -ESPIPE;
1610 else 1597 else
@@ -1614,18 +1601,16 @@ static int qt_tiocmset(struct usb_serial_port *port, struct file *file,
1614static int serial_tiocmget(struct tty_struct *tty, struct file *file) 1601static int serial_tiocmget(struct tty_struct *tty, struct file *file)
1615{ 1602{
1616 1603
1617 struct usb_serial_port *port = 1604 struct usb_serial_port *port = tty->driver_data;
1618 (struct usb_serial_port *)tty->driver_data;
1619
1620 struct usb_serial *serial = get_usb_serial(port, __func__); 1605 struct usb_serial *serial = get_usb_serial(port, __func__);
1621 int retval = -ENODEV; 1606 int retval = -ENODEV;
1622 unsigned int UartNumber; 1607 unsigned int index;
1623 mydbg("In %s \n", __func__); 1608 mydbg("In %s \n", __func__);
1624 1609
1625 if (!serial) 1610 if (!serial)
1626 return -ENODEV; 1611 return -ENODEV;
1627 1612
1628 UartNumber = port->tty->index - serial->minor; 1613 index = tty->index - serial->minor;
1629 1614
1630 down(&port->sem); 1615 down(&port->sem);
1631 1616
@@ -1637,56 +1622,55 @@ static int serial_tiocmget(struct tty_struct *tty, struct file *file)
1637 goto exit; 1622 goto exit;
1638 } 1623 }
1639 1624
1640 retval = qt_tiocmget(port, file); 1625 retval = qt_tiocmget(tty, port, file);
1641 1626
1642exit: 1627exit:
1643 up(&port->sem); 1628 up(&port->sem);
1644 return retval; 1629 return retval;
1645} 1630}
1646 1631
1647static int qt_tiocmget(struct usb_serial_port *port, struct file *file) 1632static int qt_tiocmget(struct tty_struct *tty,
1633 struct usb_serial_port *port, struct file *file)
1648{ 1634{
1649 1635
1650 __u8 MCR_Value; 1636 u8 mcr;
1651 __u8 MSR_Value; 1637 u8 msr;
1652 unsigned int result = 0; 1638 unsigned int result = 0;
1653 int status; 1639 int status;
1654 unsigned int UartNumber; 1640 unsigned int index;
1655 struct tty_struct *tty;
1656 1641
1657 struct usb_serial *serial = get_usb_serial(port, __func__); 1642 struct usb_serial *serial = get_usb_serial(port, __func__);
1658 if (serial == NULL) 1643 if (serial == NULL)
1659 return -ENODEV; 1644 return -ENODEV;
1660 tty = port->tty;
1661 1645
1662 mydbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty); 1646 mydbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty);
1663 1647
1664 /**************************************************************************************/ 1648 /**************************************************************************************/
1665 /** TIOCMGET 1649 /** TIOCMGET
1666 */ 1650 */
1667 UartNumber = port->tty->index - serial->minor; 1651 index = tty->index - serial->minor;
1668 status = 1652 status =
1669 BoxGetRegister(port->serial, UartNumber, MODEM_CONTROL_REGISTER, 1653 BoxGetRegister(port->serial, index, MODEM_CONTROL_REGISTER,
1670 &MCR_Value); 1654 &mcr);
1671 if (status >= 0) { 1655 if (status >= 0) {
1672 status = 1656 status =
1673 BoxGetRegister(port->serial, UartNumber, 1657 BoxGetRegister(port->serial, index,
1674 MODEM_STATUS_REGISTER, &MSR_Value); 1658 MODEM_STATUS_REGISTER, &msr);
1675 1659
1676 } 1660 }
1677 1661
1678 if (status >= 0) { 1662 if (status >= 0) {
1679 result = ((MCR_Value & SERIAL_MCR_DTR) ? TIOCM_DTR : 0) 1663 result = ((mcr & SERIAL_MCR_DTR) ? TIOCM_DTR : 0)
1680 /* DTR IS SET */ 1664 /* DTR IS SET */
1681 | ((MCR_Value & SERIAL_MCR_RTS) ? TIOCM_RTS : 0) 1665 | ((mcr & SERIAL_MCR_RTS) ? TIOCM_RTS : 0)
1682 /* RTS IS SET */ 1666 /* RTS IS SET */
1683 | ((MSR_Value & SERIAL_MSR_CTS) ? TIOCM_CTS : 0) 1667 | ((msr & SERIAL_MSR_CTS) ? TIOCM_CTS : 0)
1684 /* CTS is set */ 1668 /* CTS is set */
1685 | ((MSR_Value & SERIAL_MSR_CD) ? TIOCM_CAR : 0) 1669 | ((msr & SERIAL_MSR_CD) ? TIOCM_CAR : 0)
1686 /* Carrier detect is set */ 1670 /* Carrier detect is set */
1687 | ((MSR_Value & SERIAL_MSR_RI) ? TIOCM_RI : 0) 1671 | ((msr & SERIAL_MSR_RI) ? TIOCM_RI : 0)
1688 /* Ring indicator set */ 1672 /* Ring indicator set */
1689 | ((MSR_Value & SERIAL_MSR_DSR) ? TIOCM_DSR : 0); 1673 | ((msr & SERIAL_MSR_DSR) ? TIOCM_DSR : 0);
1690 /* DSR is set */ 1674 /* DSR is set */
1691 return result; 1675 return result;
1692 1676
@@ -1698,17 +1682,16 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file,
1698 unsigned int cmd, unsigned long arg) 1682 unsigned int cmd, unsigned long arg)
1699{ 1683{
1700 1684
1701 struct usb_serial_port *port = 1685 struct usb_serial_port *port = tty->driver_data;
1702 (struct usb_serial_port *)tty->driver_data;
1703 struct usb_serial *serial = get_usb_serial(port, __func__); 1686 struct usb_serial *serial = get_usb_serial(port, __func__);
1704 int retval = -ENODEV; 1687 int retval = -ENODEV;
1705 unsigned int UartNumber; 1688 unsigned int index;
1706 mydbg("In %s \n", __func__); 1689 mydbg("In %s \n", __func__);
1707 1690
1708 if (!serial) 1691 if (!serial)
1709 return -ENODEV; 1692 return -ENODEV;
1710 1693
1711 UartNumber = port->tty->index - serial->minor; 1694 index = tty->index - serial->minor;
1712 1695
1713 down(&port->sem); 1696 down(&port->sem);
1714 1697
@@ -1720,125 +1703,34 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file,
1720 goto exit; 1703 goto exit;
1721 } 1704 }
1722 1705
1723 retval = qt_ioctl(port, file, cmd, arg); 1706 retval = qt_ioctl(tty, port, file, cmd, arg);
1724 1707
1725exit: 1708exit:
1726 up(&port->sem); 1709 up(&port->sem);
1727 return retval; 1710 return retval;
1728} 1711}
1729static int qt_ioctl(struct usb_serial_port *port, struct file *file, 1712static int qt_ioctl(struct tty_struct *tty, struct usb_serial_port *port,
1730 unsigned int cmd, unsigned long arg) 1713 struct file *file, unsigned int cmd, unsigned long arg)
1731{ 1714{
1732 __u8 MCR_Value; 1715 __u8 mcr;
1733 __u8 MSR_Value; 1716 __u8 msr;
1734 unsigned short Prev_MSR_Value; 1717 unsigned short prev_msr;
1735 unsigned int value, result = 0; 1718 unsigned int value, result = 0;
1736 int status; 1719 int status;
1737 unsigned int UartNumber; 1720 unsigned int index;
1738 struct tty_struct *tty;
1739 1721
1740 struct usb_serial *serial = get_usb_serial(port, __func__); 1722 struct usb_serial *serial = get_usb_serial(port, __func__);
1741 if (serial == NULL) 1723 if (serial == NULL)
1742 return -ENODEV; 1724 return -ENODEV;
1743 tty = port->tty;
1744 1725
1745 mydbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty); 1726 mydbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty);
1746 1727
1747 /* TIOCMGET */ 1728 /* TIOCMGET */
1748 UartNumber = port->tty->index - serial->minor; 1729 index = tty->index - serial->minor;
1749
1750 if (cmd == TIOCMGET) {
1751 MCR_Value = port->shadowMCR;
1752 MSR_Value = port->shadowMSR;
1753
1754 {
1755 result = ((MCR_Value & SERIAL_MCR_DTR) ? TIOCM_DTR : 0)
1756 /* DTR IS SET */
1757 | ((MCR_Value & SERIAL_MCR_RTS) ? TIOCM_RTS : 0)
1758 /* RTS IS SET */
1759 | ((MSR_Value & SERIAL_MSR_CTS) ? TIOCM_CTS : 0)
1760 /* CTS is set */
1761 | ((MSR_Value & SERIAL_MSR_CD) ? TIOCM_CAR : 0)
1762 /* Carrier detect is set */
1763 | ((MSR_Value & SERIAL_MSR_RI) ? TIOCM_RI : 0)
1764 /* Ring indicator set */
1765 | ((MSR_Value & SERIAL_MSR_DSR) ? TIOCM_DSR : 0);
1766 /* DSR is set */
1767 if (copy_to_user
1768 ((unsigned int *)arg, &result,
1769 sizeof(unsigned int)))
1770 return -EFAULT;
1771 return 0;
1772
1773 }
1774 }
1775
1776 /* TIOCMBIS, TIOCMBIC, AND TIOCMSET */
1777 if (cmd == TIOCMBIS || cmd == TIOCMBIC || cmd == TIOCMSET) {
1778 status =
1779 BoxGetRegister(port->serial, UartNumber,
1780 MODEM_CONTROL_REGISTER, &MCR_Value);
1781 if (status < 0)
1782 return -ESPIPE;
1783 if (copy_from_user
1784 (&value, (unsigned int *)arg, sizeof(unsigned int)))
1785 return -EFAULT;
1786
1787 switch (cmd) {
1788 case TIOCMBIS:
1789 if (value & TIOCM_RTS)
1790 MCR_Value |= SERIAL_MCR_RTS;
1791 if (value & TIOCM_DTR)
1792 MCR_Value |= SERIAL_MCR_DTR;
1793 if (value & TIOCM_LOOP)
1794 MCR_Value |= SERIAL_MCR_LOOP;
1795 break;
1796 case TIOCMBIC:
1797 if (value & TIOCM_RTS)
1798 MCR_Value &= ~SERIAL_MCR_RTS;
1799 if (value & TIOCM_DTR)
1800 MCR_Value &= ~SERIAL_MCR_DTR;
1801 if (value & TIOCM_LOOP)
1802 MCR_Value &= ~SERIAL_MCR_LOOP;
1803 break;
1804 case TIOCMSET:
1805 /*
1806 * Turn off the RTS and DTR and loopbcck and then only
1807 * turn on what was asked for
1808 */
1809 MCR_Value &=
1810 ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR |
1811 SERIAL_MCR_LOOP);
1812 if (value & TIOCM_RTS)
1813 MCR_Value |= SERIAL_MCR_RTS;
1814 if (value & TIOCM_DTR)
1815 MCR_Value |= SERIAL_MCR_DTR;
1816 if (value & TIOCM_LOOP)
1817 MCR_Value |= SERIAL_MCR_LOOP;
1818 break;
1819 default:
1820 break;
1821
1822 }
1823 status =
1824 BoxSetRegister(port->serial, UartNumber,
1825 MODEM_CONTROL_REGISTER, MCR_Value);
1826 if (status < 0)
1827 return -ESPIPE;
1828 else {
1829 port->shadowMCR = MCR_Value;
1830 return 0;
1831 }
1832
1833 }
1834 /**************************************************************************************/
1835 /** TIOCMBIS, TIOCMBIC, AND TIOCMSET end
1836 */
1837 /**************************************************************************************/
1838 1730
1839 if (cmd == TIOCMIWAIT) { 1731 if (cmd == TIOCMIWAIT) {
1840 DECLARE_WAITQUEUE(wait, current); 1732 DECLARE_WAITQUEUE(wait, current);
1841 Prev_MSR_Value = port->shadowMSR & SERIAL_MSR_MASK; 1733 prev_msr = port->shadowMSR & SERIAL_MSR_MASK;
1842 while (1) { 1734 while (1) {
1843 add_wait_queue(&port->wait, &wait); 1735 add_wait_queue(&port->wait, &wait);
1844 set_current_state(TASK_INTERRUPTIBLE); 1736 set_current_state(TASK_INTERRUPTIBLE);
@@ -1847,22 +1739,22 @@ static int qt_ioctl(struct usb_serial_port *port, struct file *file,
1847 /* see if a signal woke us up */ 1739 /* see if a signal woke us up */
1848 if (signal_pending(current)) 1740 if (signal_pending(current))
1849 return -ERESTARTSYS; 1741 return -ERESTARTSYS;
1850 MSR_Value = port->shadowMSR & SERIAL_MSR_MASK; 1742 msr = port->shadowMSR & SERIAL_MSR_MASK;
1851 if (MSR_Value == Prev_MSR_Value) 1743 if (msr == prev_msr)
1852 return -EIO; /* no change error */ 1744 return -EIO; /* no change error */
1853 1745
1854 if ((arg & TIOCM_RNG 1746 if ((arg & TIOCM_RNG
1855 && ((Prev_MSR_Value & SERIAL_MSR_RI) == 1747 && ((prev_msr & SERIAL_MSR_RI) ==
1856 (MSR_Value & SERIAL_MSR_RI))) 1748 (msr & SERIAL_MSR_RI)))
1857 || (arg & TIOCM_DSR 1749 || (arg & TIOCM_DSR
1858 && ((Prev_MSR_Value & SERIAL_MSR_DSR) == 1750 && ((prev_msr & SERIAL_MSR_DSR) ==
1859 (MSR_Value & SERIAL_MSR_DSR))) 1751 (msr & SERIAL_MSR_DSR)))
1860 || (arg & TIOCM_CD 1752 || (arg & TIOCM_CD
1861 && ((Prev_MSR_Value & SERIAL_MSR_CD) == 1753 && ((prev_msr & SERIAL_MSR_CD) ==
1862 (MSR_Value & SERIAL_MSR_CD))) 1754 (msr & SERIAL_MSR_CD)))
1863 || (arg & TIOCM_CTS 1755 || (arg & TIOCM_CTS
1864 && ((Prev_MSR_Value & SERIAL_MSR_CTS) == 1756 && ((prev_msr & SERIAL_MSR_CTS) ==
1865 (MSR_Value & SERIAL_MSR_CTS)))) { 1757 (msr & SERIAL_MSR_CTS)))) {
1866 return 0; 1758 return 0;
1867 } 1759 }
1868 1760
@@ -1878,7 +1770,7 @@ static int qt_ioctl(struct usb_serial_port *port, struct file *file,
1878static void serial_set_termios(struct tty_struct *tty, struct ktermios *old) 1770static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
1879{ 1771{
1880 struct usb_serial_port *port = 1772 struct usb_serial_port *port =
1881 (struct usb_serial_port *)tty->driver_data; 1773 tty->driver_data;
1882 struct usb_serial *serial = get_usb_serial(port, __func__); 1774 struct usb_serial *serial = get_usb_serial(port, __func__);
1883 1775
1884 if (!serial) 1776 if (!serial)
@@ -1894,22 +1786,22 @@ static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
1894 } 1786 }
1895 1787
1896 /* pass on to the driver specific version of this function if it is available */ 1788 /* pass on to the driver specific version of this function if it is available */
1897 qt_set_termios(port, old); 1789 qt_set_termios(tty, port, old);
1898 1790
1899exit: 1791exit:
1900 up(&port->sem); 1792 up(&port->sem);
1901} 1793}
1902 1794
1903static void qt_set_termios(struct usb_serial_port *port, 1795static void qt_set_termios(struct tty_struct *tty,
1796 struct usb_serial_port *port,
1904 struct ktermios *old_termios) 1797 struct ktermios *old_termios)
1905{ 1798{
1906 unsigned int cflag; 1799 unsigned int cflag;
1907 int baud, divisor, remainder; 1800 int baud, divisor, remainder;
1908 unsigned char LCR_change_to = 0; 1801 unsigned char new_LCR = 0;
1909 struct tty_struct *tty;
1910 int status; 1802 int status;
1911 struct usb_serial *serial; 1803 struct usb_serial *serial;
1912 __u16 UartNumber; 1804 __u16 index;
1913 __u16 tmp, tmp2; 1805 __u16 tmp, tmp2;
1914 1806
1915 mydbg("%s - port %d\n", __func__, port->number); 1807 mydbg("%s - port %d\n", __func__, port->number);
@@ -1921,59 +1813,46 @@ static void qt_set_termios(struct usb_serial_port *port,
1921 tmp2 = serial->minor; 1813 tmp2 = serial->minor;
1922 mydbg("%s - serial->minor = %d\n", __func__, tmp2); 1814 mydbg("%s - serial->minor = %d\n", __func__, tmp2);
1923 1815
1924 UartNumber = port->tty->index - serial->minor; 1816 index = port->tty->index - serial->minor;
1925
1926 tty = port->tty;
1927 1817
1928 cflag = tty->termios->c_cflag; 1818 cflag = tty->termios->c_cflag;
1929 1819
1930 if (old_termios) {
1931 if ((cflag == old_termios->c_cflag)
1932 && (RELEVANT_IFLAG(tty->termios->c_iflag) ==
1933 RELEVANT_IFLAG(old_termios->c_iflag))) {
1934 mydbg("%s - Nothing to change\n", __func__);
1935 return;
1936 }
1937
1938 }
1939
1940 mydbg("%s - 3\n", __func__); 1820 mydbg("%s - 3\n", __func__);
1941 1821
1942 switch (cflag) { 1822 switch (cflag) {
1943 case CS5: 1823 case CS5:
1944 LCR_change_to |= SERIAL_5_DATA; 1824 new_LCR |= SERIAL_5_DATA;
1945 break; 1825 break;
1946 case CS6: 1826 case CS6:
1947 LCR_change_to |= SERIAL_6_DATA; 1827 new_LCR |= SERIAL_6_DATA;
1948 break; 1828 break;
1949 case CS7: 1829 case CS7:
1950 LCR_change_to |= SERIAL_7_DATA; 1830 new_LCR |= SERIAL_7_DATA;
1951 break; 1831 break;
1952 default: 1832 default:
1953 case CS8: 1833 case CS8:
1954 LCR_change_to |= SERIAL_8_DATA; 1834 new_LCR |= SERIAL_8_DATA;
1955 break; 1835 break;
1956 } 1836 }
1957 1837
1958 /* Parity stuff */ 1838 /* Parity stuff */
1959 if (cflag & PARENB) { 1839 if (cflag & PARENB) {
1960 if (cflag & PARODD) 1840 if (cflag & PARODD)
1961 LCR_change_to |= SERIAL_ODD_PARITY; 1841 new_LCR |= SERIAL_ODD_PARITY;
1962 else 1842 else
1963 LCR_change_to |= SERIAL_EVEN_PARITY; 1843 new_LCR |= SERIAL_EVEN_PARITY;
1964 } 1844 }
1965 if (cflag & CSTOPB) 1845 if (cflag & CSTOPB)
1966 LCR_change_to |= SERIAL_TWO_STOPB; 1846 new_LCR |= SERIAL_TWO_STOPB;
1967 else 1847 else
1968 LCR_change_to |= SERIAL_TWO_STOPB; 1848 new_LCR |= SERIAL_TWO_STOPB;
1969 1849
1970 mydbg("%s - 4\n", __func__); 1850 mydbg("%s - 4\n", __func__);
1971 /* Thats the LCR stuff, go ahead and set it */ 1851 /* Thats the LCR stuff, go ahead and set it */
1972 baud = tty_get_baud_rate(tty); 1852 baud = tty_get_baud_rate(tty);
1973 if (!baud) { 1853 if (!baud)
1974 /* pick a default, any default... */ 1854 /* pick a default, any default... */
1975 baud = 9600; 1855 baud = 9600;
1976 }
1977 1856
1978 mydbg("%s - got baud = %d\n", __func__, baud); 1857 mydbg("%s - got baud = %d\n", __func__, baud);
1979 1858
@@ -1986,9 +1865,7 @@ static void qt_set_termios(struct usb_serial_port *port,
1986 /* 1865 /*
1987 * Set Baud rate to default and turn off (default)flow control here 1866 * Set Baud rate to default and turn off (default)flow control here
1988 */ 1867 */
1989 status = 1868 status = BoxSetUart(serial, index, (unsigned short)divisor, new_LCR);
1990 BoxSetUart(serial, UartNumber, (unsigned short)divisor,
1991 LCR_change_to);
1992 if (status < 0) { 1869 if (status < 0) {
1993 mydbg(__FILE__ "BoxSetUart failed\n"); 1870 mydbg(__FILE__ "BoxSetUart failed\n");
1994 return; 1871 return;
@@ -2000,7 +1877,7 @@ static void qt_set_termios(struct usb_serial_port *port,
2000 port->number); 1877 port->number);
2001 1878
2002 /* Enable RTS/CTS flow control */ 1879 /* Enable RTS/CTS flow control */
2003 status = BoxSetHW_FlowCtrl(serial, UartNumber, 1); 1880 status = BoxSetHW_FlowCtrl(serial, index, 1);
2004 1881
2005 if (status < 0) { 1882 if (status < 0) {
2006 mydbg(__FILE__ "BoxSetHW_FlowCtrl failed\n"); 1883 mydbg(__FILE__ "BoxSetHW_FlowCtrl failed\n");
@@ -2011,7 +1888,7 @@ static void qt_set_termios(struct usb_serial_port *port,
2011 mydbg("%s - disabling HW flow control port %d\n", __func__, 1888 mydbg("%s - disabling HW flow control port %d\n", __func__,
2012 port->number); 1889 port->number);
2013 1890
2014 status = BoxSetHW_FlowCtrl(serial, UartNumber, 0); 1891 status = BoxSetHW_FlowCtrl(serial, index, 0);
2015 if (status < 0) { 1892 if (status < 0) {
2016 mydbg(__FILE__ "BoxSetHW_FlowCtrl failed\n"); 1893 mydbg(__FILE__ "BoxSetHW_FlowCtrl failed\n");
2017 return; 1894 return;
@@ -2025,19 +1902,20 @@ static void qt_set_termios(struct usb_serial_port *port,
2025 unsigned char stop_char = STOP_CHAR(tty); 1902 unsigned char stop_char = STOP_CHAR(tty);
2026 unsigned char start_char = START_CHAR(tty); 1903 unsigned char start_char = START_CHAR(tty);
2027 status = 1904 status =
2028 BoxSetSW_FlowCtrl(serial, UartNumber, stop_char, 1905 BoxSetSW_FlowCtrl(serial, index, stop_char,
2029 start_char); 1906 start_char);
2030 if (status < 0) 1907 if (status < 0)
2031 mydbg(__FILE__ "BoxSetSW_FlowCtrl (enabled) failed\n"); 1908 mydbg(__FILE__ "BoxSetSW_FlowCtrl (enabled) failed\n");
2032 1909
2033 } else { 1910 } else {
2034 /* disable SW flow control */ 1911 /* disable SW flow control */
2035 status = BoxDisable_SW_FlowCtrl(serial, UartNumber); 1912 status = BoxDisable_SW_FlowCtrl(serial, index);
2036 if (status < 0) 1913 if (status < 0)
2037 mydbg(__FILE__ "BoxSetSW_FlowCtrl (diabling) failed\n"); 1914 mydbg(__FILE__ "BoxSetSW_FlowCtrl (diabling) failed\n");
2038 1915
2039 } 1916 }
2040 1917 tty->termios->c_cflag &= ~CMSPAR;
1918 /* FIXME: Error cases should be returning the actual bits changed only */
2041} 1919}
2042 1920
2043/**************************************************************************** 1921/****************************************************************************
@@ -2237,11 +2115,11 @@ static int BoxSetUart(struct usb_serial *serial, unsigned short Uart_Number,
2237 return result; 2115 return result;
2238} 2116}
2239 2117
2240static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int UartNumber, 2118static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int index,
2241 int bSet) 2119 int bSet)
2242{ 2120{
2243 __u8 MCR_Value = 0; 2121 __u8 mcr = 0;
2244 __u8 MSR_Value = 0, MOUT_Value = 0; 2122 __u8 msr = 0, MOUT_Value = 0;
2245 struct usb_serial_port *port; 2123 struct usb_serial_port *port;
2246 unsigned int status; 2124 unsigned int status;
2247 2125
@@ -2249,34 +2127,34 @@ static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int UartNumber,
2249 2127
2250 if (bSet == 1) { 2128 if (bSet == 1) {
2251 /* flow control, box will clear RTS line to prevent remote */ 2129 /* flow control, box will clear RTS line to prevent remote */
2252 MCR_Value = SERIAL_MCR_RTS; 2130 mcr = SERIAL_MCR_RTS;
2253 } /* device from xmitting more chars */ 2131 } /* device from xmitting more chars */
2254 else { 2132 else {
2255 /* no flow control to remote device */ 2133 /* no flow control to remote device */
2256 MCR_Value = 0; 2134 mcr = 0;
2257 2135
2258 } 2136 }
2259 MOUT_Value = MCR_Value << 8; 2137 MOUT_Value = mcr << 8;
2260 2138
2261 if (bSet == 1) { 2139 if (bSet == 1) {
2262 /* flow control, box will inhibit xmit data if CTS line is 2140 /* flow control, box will inhibit xmit data if CTS line is
2263 * asserted */ 2141 * asserted */
2264 MSR_Value = SERIAL_MSR_CTS; 2142 msr = SERIAL_MSR_CTS;
2265 } else { 2143 } else {
2266 /* Box will not inhimbe xmit data due to CTS line */ 2144 /* Box will not inhimbe xmit data due to CTS line */
2267 MSR_Value = 0; 2145 msr = 0;
2268 } 2146 }
2269 MOUT_Value |= MSR_Value; 2147 MOUT_Value |= msr;
2270 2148
2271 status = 2149 status =
2272 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2150 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2273 QT_HW_FLOW_CONTROL_MASK, 0x40, MOUT_Value, 2151 QT_HW_FLOW_CONTROL_MASK, 0x40, MOUT_Value,
2274 UartNumber, NULL, 0, 300); 2152 index, NULL, 0, 300);
2275 return status; 2153 return status;
2276 2154
2277} 2155}
2278 2156
2279static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber, 2157static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 index,
2280 unsigned char stop_char, unsigned char start_char) 2158 unsigned char stop_char, unsigned char start_char)
2281{ 2159{
2282 __u16 nSWflowout; 2160 __u16 nSWflowout;
@@ -2288,17 +2166,17 @@ static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber,
2288 result = 2166 result =
2289 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2167 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2290 QT_SW_FLOW_CONTROL_MASK, 0x40, nSWflowout, 2168 QT_SW_FLOW_CONTROL_MASK, 0x40, nSWflowout,
2291 UartNumber, NULL, 0, 300); 2169 index, NULL, 0, 300);
2292 return result; 2170 return result;
2293 2171
2294} 2172}
2295static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber) 2173static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 index)
2296{ 2174{
2297 int result; 2175 int result;
2298 2176
2299 result = 2177 result =
2300 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2178 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2301 QT_SW_FLOW_CONTROL_DISABLE, 0x40, 0, UartNumber, 2179 QT_SW_FLOW_CONTROL_DISABLE, 0x40, 0, index,
2302 NULL, 0, 300); 2180 NULL, 0, 300);
2303 return result; 2181 return result;
2304 2182
@@ -2307,7 +2185,7 @@ static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber)
2307static void serial_throttle(struct tty_struct *tty) 2185static void serial_throttle(struct tty_struct *tty)
2308{ 2186{
2309 struct usb_serial_port *port = 2187 struct usb_serial_port *port =
2310 (struct usb_serial_port *)tty->driver_data; 2188 tty->driver_data;
2311 struct usb_serial *serial = get_usb_serial(port, __func__); 2189 struct usb_serial *serial = get_usb_serial(port, __func__);
2312 mydbg("%s - port %d\n", __func__, port->number); 2190 mydbg("%s - port %d\n", __func__, port->number);
2313 2191
@@ -2334,7 +2212,7 @@ exit:
2334static void serial_unthrottle(struct tty_struct *tty) 2212static void serial_unthrottle(struct tty_struct *tty)
2335{ 2213{
2336 struct usb_serial_port *port = 2214 struct usb_serial_port *port =
2337 (struct usb_serial_port *)tty->driver_data; 2215 tty->driver_data;
2338 struct usb_serial *serial = get_usb_serial(port, __func__); 2216 struct usb_serial *serial = get_usb_serial(port, __func__);
2339 unsigned int result; 2217 unsigned int result;
2340 2218
@@ -2380,20 +2258,19 @@ exit:
2380 2258
2381static int serial_break(struct tty_struct *tty, int break_state) 2259static int serial_break(struct tty_struct *tty, int break_state)
2382{ 2260{
2383 struct usb_serial_port *port = 2261 struct usb_serial_port *port = tty->driver_data;
2384 (struct usb_serial_port *)tty->driver_data;
2385 struct usb_serial *serial = get_usb_serial(port, __func__); 2262 struct usb_serial *serial = get_usb_serial(port, __func__);
2386 __u16 UartNumber, Break_Value; 2263 u16 index, onoff;
2387 unsigned int result; 2264 unsigned int result;
2388 2265
2389 UartNumber = port->tty->index - serial->minor; 2266 index = tty->index - serial->minor;
2390 if (!serial) 2267 if (!serial)
2391 return -ENODEV; 2268 return -ENODEV;
2392 2269
2393 if (break_state == -1) 2270 if (break_state == -1)
2394 Break_Value = 1; 2271 onoff = 1;
2395 else 2272 else
2396 Break_Value = 0; 2273 onoff = 0;
2397 2274
2398 down(&port->sem); 2275 down(&port->sem);
2399 2276
@@ -2406,7 +2283,7 @@ static int serial_break(struct tty_struct *tty, int break_state)
2406 2283
2407 result = 2284 result =
2408 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2285 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2409 QT_BREAK_CONTROL, 0x40, Break_Value, UartNumber, 2286 QT_BREAK_CONTROL, 0x40, onoff, index,
2410 NULL, 0, 300); 2287 NULL, 0, 300);
2411 2288
2412exit: 2289exit: