diff options
Diffstat (limited to 'drivers/usb/serial/cp2101.c')
-rw-r--r-- | drivers/usb/serial/cp2101.c | 392 |
1 files changed, 196 insertions, 196 deletions
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index f5b57b196c5a..442cba69cce5 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
27 | #include <linux/usb.h> | 27 | #include <linux/usb.h> |
28 | #include <asm/uaccess.h> | 28 | #include <linux/uaccess.h> |
29 | #include <linux/usb/serial.h> | 29 | #include <linux/usb/serial.h> |
30 | 30 | ||
31 | /* | 31 | /* |
@@ -37,17 +37,20 @@ | |||
37 | /* | 37 | /* |
38 | * Function Prototypes | 38 | * Function Prototypes |
39 | */ | 39 | */ |
40 | static int cp2101_open(struct usb_serial_port*, struct file*); | 40 | static int cp2101_open(struct tty_struct *, struct usb_serial_port *, |
41 | static void cp2101_cleanup(struct usb_serial_port*); | 41 | struct file *); |
42 | static void cp2101_close(struct usb_serial_port*, struct file*); | 42 | static void cp2101_cleanup(struct usb_serial_port *); |
43 | static void cp2101_get_termios(struct usb_serial_port*); | 43 | static void cp2101_close(struct tty_struct *, struct usb_serial_port *, |
44 | static void cp2101_set_termios(struct usb_serial_port*, struct ktermios*); | 44 | struct file*); |
45 | static int cp2101_tiocmget (struct usb_serial_port *, struct file *); | 45 | static void cp2101_get_termios(struct tty_struct *); |
46 | static int cp2101_tiocmset (struct usb_serial_port *, struct file *, | 46 | static void cp2101_set_termios(struct tty_struct *, struct usb_serial_port *, |
47 | struct ktermios*); | ||
48 | static int cp2101_tiocmget(struct tty_struct *, struct file *); | ||
49 | static int cp2101_tiocmset(struct tty_struct *, struct file *, | ||
47 | unsigned int, unsigned int); | 50 | unsigned int, unsigned int); |
48 | static void cp2101_break_ctl(struct usb_serial_port*, int); | 51 | static void cp2101_break_ctl(struct tty_struct *, int); |
49 | static int cp2101_startup (struct usb_serial *); | 52 | static int cp2101_startup(struct usb_serial *); |
50 | static void cp2101_shutdown(struct usb_serial*); | 53 | static void cp2101_shutdown(struct usb_serial *); |
51 | 54 | ||
52 | 55 | ||
53 | static int debug; | 56 | static int debug; |
@@ -93,7 +96,7 @@ static struct usb_device_id id_table [] = { | |||
93 | { } /* Terminating Entry */ | 96 | { } /* Terminating Entry */ |
94 | }; | 97 | }; |
95 | 98 | ||
96 | MODULE_DEVICE_TABLE (usb, id_table); | 99 | MODULE_DEVICE_TABLE(usb, id_table); |
97 | 100 | ||
98 | static struct usb_driver cp2101_driver = { | 101 | static struct usb_driver cp2101_driver = { |
99 | .name = "cp2101", | 102 | .name = "cp2101", |
@@ -182,7 +185,7 @@ static struct usb_serial_driver cp2101_device = { | |||
182 | * 'data' is a pointer to a pre-allocated array of integers large | 185 | * 'data' is a pointer to a pre-allocated array of integers large |
183 | * enough to hold 'size' bytes (with 4 bytes to each integer) | 186 | * enough to hold 'size' bytes (with 4 bytes to each integer) |
184 | */ | 187 | */ |
185 | static int cp2101_get_config(struct usb_serial_port* port, u8 request, | 188 | static int cp2101_get_config(struct usb_serial_port *port, u8 request, |
186 | unsigned int *data, int size) | 189 | unsigned int *data, int size) |
187 | { | 190 | { |
188 | struct usb_serial *serial = port->serial; | 191 | struct usb_serial *serial = port->serial; |
@@ -202,12 +205,12 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request, | |||
202 | request++; | 205 | request++; |
203 | 206 | ||
204 | /* Issue the request, attempting to read 'size' bytes */ | 207 | /* Issue the request, attempting to read 'size' bytes */ |
205 | result = usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev, 0), | 208 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
206 | request, REQTYPE_DEVICE_TO_HOST, 0x0000, | 209 | request, REQTYPE_DEVICE_TO_HOST, 0x0000, |
207 | 0, buf, size, 300); | 210 | 0, buf, size, 300); |
208 | 211 | ||
209 | /* Convert data into an array of integers */ | 212 | /* Convert data into an array of integers */ |
210 | for (i=0; i<length; i++) | 213 | for (i = 0; i < length; i++) |
211 | data[i] = le32_to_cpu(buf[i]); | 214 | data[i] = le32_to_cpu(buf[i]); |
212 | 215 | ||
213 | kfree(buf); | 216 | kfree(buf); |
@@ -228,7 +231,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request, | |||
228 | * Values less than 16 bits wide are sent directly | 231 | * Values less than 16 bits wide are sent directly |
229 | * 'size' is specified in bytes. | 232 | * 'size' is specified in bytes. |
230 | */ | 233 | */ |
231 | static int cp2101_set_config(struct usb_serial_port* port, u8 request, | 234 | static int cp2101_set_config(struct usb_serial_port *port, u8 request, |
232 | unsigned int *data, int size) | 235 | unsigned int *data, int size) |
233 | { | 236 | { |
234 | struct usb_serial *serial = port->serial; | 237 | struct usb_serial *serial = port->serial; |
@@ -250,12 +253,12 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request, | |||
250 | buf[i] = cpu_to_le32(data[i]); | 253 | buf[i] = cpu_to_le32(data[i]); |
251 | 254 | ||
252 | if (size > 2) { | 255 | if (size > 2) { |
253 | result = usb_control_msg (serial->dev, | 256 | result = usb_control_msg(serial->dev, |
254 | usb_sndctrlpipe(serial->dev, 0), | 257 | usb_sndctrlpipe(serial->dev, 0), |
255 | request, REQTYPE_HOST_TO_DEVICE, 0x0000, | 258 | request, REQTYPE_HOST_TO_DEVICE, 0x0000, |
256 | 0, buf, size, 300); | 259 | 0, buf, size, 300); |
257 | } else { | 260 | } else { |
258 | result = usb_control_msg (serial->dev, | 261 | result = usb_control_msg(serial->dev, |
259 | usb_sndctrlpipe(serial->dev, 0), | 262 | usb_sndctrlpipe(serial->dev, 0), |
260 | request, REQTYPE_HOST_TO_DEVICE, data[0], | 263 | request, REQTYPE_HOST_TO_DEVICE, data[0], |
261 | 0, NULL, 0, 300); | 264 | 0, NULL, 0, 300); |
@@ -271,7 +274,7 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request, | |||
271 | } | 274 | } |
272 | 275 | ||
273 | /* Single data value */ | 276 | /* Single data value */ |
274 | result = usb_control_msg (serial->dev, | 277 | result = usb_control_msg(serial->dev, |
275 | usb_sndctrlpipe(serial->dev, 0), | 278 | usb_sndctrlpipe(serial->dev, 0), |
276 | request, REQTYPE_HOST_TO_DEVICE, data[0], | 279 | request, REQTYPE_HOST_TO_DEVICE, data[0], |
277 | 0, NULL, 0, 300); | 280 | 0, NULL, 0, 300); |
@@ -283,13 +286,14 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request, | |||
283 | * Convenience function for calling cp2101_set_config on single data values | 286 | * Convenience function for calling cp2101_set_config on single data values |
284 | * without requiring an integer pointer | 287 | * without requiring an integer pointer |
285 | */ | 288 | */ |
286 | static inline int cp2101_set_config_single(struct usb_serial_port* port, | 289 | static inline int cp2101_set_config_single(struct usb_serial_port *port, |
287 | u8 request, unsigned int data) | 290 | u8 request, unsigned int data) |
288 | { | 291 | { |
289 | return cp2101_set_config(port, request, &data, 2); | 292 | return cp2101_set_config(port, request, &data, 2); |
290 | } | 293 | } |
291 | 294 | ||
292 | static int cp2101_open (struct usb_serial_port *port, struct file *filp) | 295 | static int cp2101_open(struct tty_struct *tty, struct usb_serial_port *port, |
296 | struct file *filp) | ||
293 | { | 297 | { |
294 | struct usb_serial *serial = port->serial; | 298 | struct usb_serial *serial = port->serial; |
295 | int result; | 299 | int result; |
@@ -303,7 +307,7 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) | |||
303 | } | 307 | } |
304 | 308 | ||
305 | /* Start reading from the device */ | 309 | /* Start reading from the device */ |
306 | usb_fill_bulk_urb (port->read_urb, serial->dev, | 310 | usb_fill_bulk_urb(port->read_urb, serial->dev, |
307 | usb_rcvbulkpipe(serial->dev, | 311 | usb_rcvbulkpipe(serial->dev, |
308 | port->bulk_in_endpointAddress), | 312 | port->bulk_in_endpointAddress), |
309 | port->read_urb->transfer_buffer, | 313 | port->read_urb->transfer_buffer, |
@@ -318,15 +322,15 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) | |||
318 | } | 322 | } |
319 | 323 | ||
320 | /* Configure the termios structure */ | 324 | /* Configure the termios structure */ |
321 | cp2101_get_termios(port); | 325 | cp2101_get_termios(tty); |
322 | 326 | ||
323 | /* Set the DTR and RTS pins low */ | 327 | /* Set the DTR and RTS pins low */ |
324 | cp2101_tiocmset(port, NULL, TIOCM_DTR | TIOCM_RTS, 0); | 328 | cp2101_tiocmset(tty, NULL, TIOCM_DTR | TIOCM_RTS, 0); |
325 | 329 | ||
326 | return 0; | 330 | return 0; |
327 | } | 331 | } |
328 | 332 | ||
329 | static void cp2101_cleanup (struct usb_serial_port *port) | 333 | static void cp2101_cleanup(struct usb_serial_port *port) |
330 | { | 334 | { |
331 | struct usb_serial *serial = port->serial; | 335 | struct usb_serial *serial = port->serial; |
332 | 336 | ||
@@ -341,7 +345,8 @@ static void cp2101_cleanup (struct usb_serial_port *port) | |||
341 | } | 345 | } |
342 | } | 346 | } |
343 | 347 | ||
344 | static void cp2101_close (struct usb_serial_port *port, struct file * filp) | 348 | static void cp2101_close(struct tty_struct *tty, struct usb_serial_port *port, |
349 | struct file *filp) | ||
345 | { | 350 | { |
346 | dbg("%s - port %d", __func__, port->number); | 351 | dbg("%s - port %d", __func__, port->number); |
347 | 352 | ||
@@ -362,19 +367,15 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp) | |||
362 | * from the device, corrects any unsupported values, and configures the | 367 | * from the device, corrects any unsupported values, and configures the |
363 | * termios structure to reflect the state of the device | 368 | * termios structure to reflect the state of the device |
364 | */ | 369 | */ |
365 | static void cp2101_get_termios (struct usb_serial_port *port) | 370 | static void cp2101_get_termios (struct tty_struct *tty) |
366 | { | 371 | { |
372 | struct usb_serial_port *port = tty->driver_data; | ||
367 | unsigned int cflag, modem_ctl[4]; | 373 | unsigned int cflag, modem_ctl[4]; |
368 | int baud; | 374 | unsigned int baud; |
369 | int bits; | 375 | unsigned int bits; |
370 | 376 | ||
371 | dbg("%s - port %d", __func__, port->number); | 377 | dbg("%s - port %d", __func__, port->number); |
372 | 378 | ||
373 | if (!port->tty || !port->tty->termios) { | ||
374 | dbg("%s - no tty structures", __func__); | ||
375 | return; | ||
376 | } | ||
377 | |||
378 | cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); | 379 | cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); |
379 | /* Convert to baudrate */ | 380 | /* Convert to baudrate */ |
380 | if (baud) | 381 | if (baud) |
@@ -382,104 +383,102 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
382 | 383 | ||
383 | dbg("%s - baud rate = %d", __func__, baud); | 384 | dbg("%s - baud rate = %d", __func__, baud); |
384 | 385 | ||
385 | tty_encode_baud_rate(port->tty, baud, baud); | 386 | tty_encode_baud_rate(tty, baud, baud); |
386 | cflag = port->tty->termios->c_cflag; | 387 | cflag = tty->termios->c_cflag; |
387 | 388 | ||
388 | cp2101_get_config(port, CP2101_BITS, &bits, 2); | 389 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
389 | cflag &= ~CSIZE; | 390 | cflag &= ~CSIZE; |
390 | switch(bits & BITS_DATA_MASK) { | 391 | switch (bits & BITS_DATA_MASK) { |
391 | case BITS_DATA_5: | 392 | case BITS_DATA_5: |
392 | dbg("%s - data bits = 5", __func__); | 393 | dbg("%s - data bits = 5", __func__); |
393 | cflag |= CS5; | 394 | cflag |= CS5; |
394 | break; | 395 | break; |
395 | case BITS_DATA_6: | 396 | case BITS_DATA_6: |
396 | dbg("%s - data bits = 6", __func__); | 397 | dbg("%s - data bits = 6", __func__); |
397 | cflag |= CS6; | 398 | cflag |= CS6; |
398 | break; | 399 | break; |
399 | case BITS_DATA_7: | 400 | case BITS_DATA_7: |
400 | dbg("%s - data bits = 7", __func__); | 401 | dbg("%s - data bits = 7", __func__); |
401 | cflag |= CS7; | 402 | cflag |= CS7; |
402 | break; | 403 | break; |
403 | case BITS_DATA_8: | 404 | case BITS_DATA_8: |
404 | dbg("%s - data bits = 8", __func__); | 405 | dbg("%s - data bits = 8", __func__); |
405 | cflag |= CS8; | 406 | cflag |= CS8; |
406 | break; | 407 | break; |
407 | case BITS_DATA_9: | 408 | case BITS_DATA_9: |
408 | dbg("%s - data bits = 9 (not supported, " | 409 | dbg("%s - data bits = 9 (not supported, using 8 data bits)", |
409 | "using 8 data bits)", __func__); | 410 | __func__); |
410 | cflag |= CS8; | 411 | cflag |= CS8; |
411 | bits &= ~BITS_DATA_MASK; | 412 | bits &= ~BITS_DATA_MASK; |
412 | bits |= BITS_DATA_8; | 413 | bits |= BITS_DATA_8; |
413 | cp2101_set_config(port, CP2101_BITS, &bits, 2); | 414 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
414 | break; | 415 | break; |
415 | default: | 416 | default: |
416 | dbg("%s - Unknown number of data bits, " | 417 | dbg("%s - Unknown number of data bits, using 8", __func__); |
417 | "using 8", __func__); | 418 | cflag |= CS8; |
418 | cflag |= CS8; | 419 | bits &= ~BITS_DATA_MASK; |
419 | bits &= ~BITS_DATA_MASK; | 420 | bits |= BITS_DATA_8; |
420 | bits |= BITS_DATA_8; | 421 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
421 | cp2101_set_config(port, CP2101_BITS, &bits, 2); | 422 | break; |
422 | break; | ||
423 | } | 423 | } |
424 | 424 | ||
425 | switch(bits & BITS_PARITY_MASK) { | 425 | switch (bits & BITS_PARITY_MASK) { |
426 | case BITS_PARITY_NONE: | 426 | case BITS_PARITY_NONE: |
427 | dbg("%s - parity = NONE", __func__); | 427 | dbg("%s - parity = NONE", __func__); |
428 | cflag &= ~PARENB; | 428 | cflag &= ~PARENB; |
429 | break; | 429 | break; |
430 | case BITS_PARITY_ODD: | 430 | case BITS_PARITY_ODD: |
431 | dbg("%s - parity = ODD", __func__); | 431 | dbg("%s - parity = ODD", __func__); |
432 | cflag |= (PARENB|PARODD); | 432 | cflag |= (PARENB|PARODD); |
433 | break; | 433 | break; |
434 | case BITS_PARITY_EVEN: | 434 | case BITS_PARITY_EVEN: |
435 | dbg("%s - parity = EVEN", __func__); | 435 | dbg("%s - parity = EVEN", __func__); |
436 | cflag &= ~PARODD; | 436 | cflag &= ~PARODD; |
437 | cflag |= PARENB; | 437 | cflag |= PARENB; |
438 | break; | 438 | break; |
439 | case BITS_PARITY_MARK: | 439 | case BITS_PARITY_MARK: |
440 | dbg("%s - parity = MARK (not supported, " | 440 | dbg("%s - parity = MARK (not supported, disabling parity)", |
441 | "disabling parity)", __func__); | 441 | __func__); |
442 | cflag &= ~PARENB; | 442 | cflag &= ~PARENB; |
443 | bits &= ~BITS_PARITY_MASK; | 443 | bits &= ~BITS_PARITY_MASK; |
444 | cp2101_set_config(port, CP2101_BITS, &bits, 2); | 444 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
445 | break; | 445 | break; |
446 | case BITS_PARITY_SPACE: | 446 | case BITS_PARITY_SPACE: |
447 | dbg("%s - parity = SPACE (not supported, " | 447 | dbg("%s - parity = SPACE (not supported, disabling parity)", |
448 | "disabling parity)", __func__); | 448 | __func__); |
449 | cflag &= ~PARENB; | 449 | cflag &= ~PARENB; |
450 | bits &= ~BITS_PARITY_MASK; | 450 | bits &= ~BITS_PARITY_MASK; |
451 | cp2101_set_config(port, CP2101_BITS, &bits, 2); | 451 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
452 | break; | 452 | break; |
453 | default: | 453 | default: |
454 | dbg("%s - Unknown parity mode, " | 454 | dbg("%s - Unknown parity mode, disabling parity", __func__); |
455 | "disabling parity", __func__); | 455 | cflag &= ~PARENB; |
456 | cflag &= ~PARENB; | 456 | bits &= ~BITS_PARITY_MASK; |
457 | bits &= ~BITS_PARITY_MASK; | 457 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
458 | cp2101_set_config(port, CP2101_BITS, &bits, 2); | 458 | break; |
459 | break; | ||
460 | } | 459 | } |
461 | 460 | ||
462 | cflag &= ~CSTOPB; | 461 | cflag &= ~CSTOPB; |
463 | switch(bits & BITS_STOP_MASK) { | 462 | switch (bits & BITS_STOP_MASK) { |
464 | case BITS_STOP_1: | 463 | case BITS_STOP_1: |
465 | dbg("%s - stop bits = 1", __func__); | 464 | dbg("%s - stop bits = 1", __func__); |
466 | break; | 465 | break; |
467 | case BITS_STOP_1_5: | 466 | case BITS_STOP_1_5: |
468 | dbg("%s - stop bits = 1.5 (not supported, " | 467 | dbg("%s - stop bits = 1.5 (not supported, using 1 stop bit)", |
469 | "using 1 stop bit)", __func__); | 468 | __func__); |
470 | bits &= ~BITS_STOP_MASK; | 469 | bits &= ~BITS_STOP_MASK; |
471 | cp2101_set_config(port, CP2101_BITS, &bits, 2); | 470 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
472 | break; | 471 | break; |
473 | case BITS_STOP_2: | 472 | case BITS_STOP_2: |
474 | dbg("%s - stop bits = 2", __func__); | 473 | dbg("%s - stop bits = 2", __func__); |
475 | cflag |= CSTOPB; | 474 | cflag |= CSTOPB; |
476 | break; | 475 | break; |
477 | default: | 476 | default: |
478 | dbg("%s - Unknown number of stop bits, " | 477 | dbg("%s - Unknown number of stop bits, using 1 stop bit", |
479 | "using 1 stop bit", __func__); | 478 | __func__); |
480 | bits &= ~BITS_STOP_MASK; | 479 | bits &= ~BITS_STOP_MASK; |
481 | cp2101_set_config(port, CP2101_BITS, &bits, 2); | 480 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
482 | break; | 481 | break; |
483 | } | 482 | } |
484 | 483 | ||
485 | cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); | 484 | cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); |
@@ -491,55 +490,53 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
491 | cflag &= ~CRTSCTS; | 490 | cflag &= ~CRTSCTS; |
492 | } | 491 | } |
493 | 492 | ||
494 | port->tty->termios->c_cflag = cflag; | 493 | tty->termios->c_cflag = cflag; |
495 | } | 494 | } |
496 | 495 | ||
497 | static void cp2101_set_termios (struct usb_serial_port *port, | 496 | static void cp2101_set_termios(struct tty_struct *tty, |
498 | struct ktermios *old_termios) | 497 | struct usb_serial_port *port, struct ktermios *old_termios) |
499 | { | 498 | { |
500 | unsigned int cflag, old_cflag; | 499 | unsigned int cflag, old_cflag; |
501 | int baud=0, bits; | 500 | unsigned int baud = 0, bits; |
502 | unsigned int modem_ctl[4]; | 501 | unsigned int modem_ctl[4]; |
503 | 502 | ||
504 | dbg("%s - port %d", __func__, port->number); | 503 | dbg("%s - port %d", __func__, port->number); |
505 | 504 | ||
506 | if (!port->tty || !port->tty->termios) { | 505 | if (!tty) |
507 | dbg("%s - no tty structures", __func__); | ||
508 | return; | 506 | return; |
509 | } | ||
510 | port->tty->termios->c_cflag &= ~CMSPAR; | ||
511 | 507 | ||
512 | cflag = port->tty->termios->c_cflag; | 508 | tty->termios->c_cflag &= ~CMSPAR; |
509 | cflag = tty->termios->c_cflag; | ||
513 | old_cflag = old_termios->c_cflag; | 510 | old_cflag = old_termios->c_cflag; |
514 | baud = tty_get_baud_rate(port->tty); | 511 | baud = tty_get_baud_rate(tty); |
515 | 512 | ||
516 | /* If the baud rate is to be updated*/ | 513 | /* If the baud rate is to be updated*/ |
517 | if (baud != tty_termios_baud_rate(old_termios)) { | 514 | if (baud != tty_termios_baud_rate(old_termios)) { |
518 | switch (baud) { | 515 | switch (baud) { |
519 | case 0: | 516 | case 0: |
520 | case 600: | 517 | case 600: |
521 | case 1200: | 518 | case 1200: |
522 | case 1800: | 519 | case 1800: |
523 | case 2400: | 520 | case 2400: |
524 | case 4800: | 521 | case 4800: |
525 | case 7200: | 522 | case 7200: |
526 | case 9600: | 523 | case 9600: |
527 | case 14400: | 524 | case 14400: |
528 | case 19200: | 525 | case 19200: |
529 | case 28800: | 526 | case 28800: |
530 | case 38400: | 527 | case 38400: |
531 | case 55854: | 528 | case 55854: |
532 | case 57600: | 529 | case 57600: |
533 | case 115200: | 530 | case 115200: |
534 | case 127117: | 531 | case 127117: |
535 | case 230400: | 532 | case 230400: |
536 | case 460800: | 533 | case 460800: |
537 | case 921600: | 534 | case 921600: |
538 | case 3686400: | 535 | case 3686400: |
539 | break; | 536 | break; |
540 | default: | 537 | default: |
541 | baud = 9600; | 538 | baud = 9600; |
542 | break; | 539 | break; |
543 | } | 540 | } |
544 | 541 | ||
545 | if (baud) { | 542 | if (baud) { |
@@ -554,35 +551,35 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
554 | } | 551 | } |
555 | } | 552 | } |
556 | /* Report back the resulting baud rate */ | 553 | /* Report back the resulting baud rate */ |
557 | tty_encode_baud_rate(port->tty, baud, baud); | 554 | tty_encode_baud_rate(tty, baud, baud); |
558 | 555 | ||
559 | /* If the number of data bits is to be updated */ | 556 | /* If the number of data bits is to be updated */ |
560 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { | 557 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { |
561 | cp2101_get_config(port, CP2101_BITS, &bits, 2); | 558 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
562 | bits &= ~BITS_DATA_MASK; | 559 | bits &= ~BITS_DATA_MASK; |
563 | switch (cflag & CSIZE) { | 560 | switch (cflag & CSIZE) { |
564 | case CS5: | 561 | case CS5: |
565 | bits |= BITS_DATA_5; | 562 | bits |= BITS_DATA_5; |
566 | dbg("%s - data bits = 5", __func__); | 563 | dbg("%s - data bits = 5", __func__); |
567 | break; | 564 | break; |
568 | case CS6: | 565 | case CS6: |
569 | bits |= BITS_DATA_6; | 566 | bits |= BITS_DATA_6; |
570 | dbg("%s - data bits = 6", __func__); | 567 | dbg("%s - data bits = 6", __func__); |
571 | break; | 568 | break; |
572 | case CS7: | 569 | case CS7: |
573 | bits |= BITS_DATA_7; | 570 | bits |= BITS_DATA_7; |
574 | dbg("%s - data bits = 7", __func__); | 571 | dbg("%s - data bits = 7", __func__); |
575 | break; | 572 | break; |
576 | case CS8: | 573 | case CS8: |
577 | bits |= BITS_DATA_8; | 574 | bits |= BITS_DATA_8; |
578 | dbg("%s - data bits = 8", __func__); | 575 | dbg("%s - data bits = 8", __func__); |
579 | break; | 576 | break; |
580 | /*case CS9: | 577 | /*case CS9: |
581 | bits |= BITS_DATA_9; | 578 | bits |= BITS_DATA_9; |
582 | dbg("%s - data bits = 9", __func__); | 579 | dbg("%s - data bits = 9", __func__); |
583 | break;*/ | 580 | break;*/ |
584 | default: | 581 | default: |
585 | dev_err(&port->dev, "cp2101 driver does not " | 582 | dev_err(&port->dev, "cp2101 driver does not " |
586 | "support the number of bits requested," | 583 | "support the number of bits requested," |
587 | " using 8 bit mode\n"); | 584 | " using 8 bit mode\n"); |
588 | bits |= BITS_DATA_8; | 585 | bits |= BITS_DATA_8; |
@@ -651,10 +648,11 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
651 | 648 | ||
652 | } | 649 | } |
653 | 650 | ||
654 | static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, | 651 | static int cp2101_tiocmset (struct tty_struct *tty, struct file *file, |
655 | unsigned int set, unsigned int clear) | 652 | unsigned int set, unsigned int clear) |
656 | { | 653 | { |
657 | int control = 0; | 654 | struct usb_serial_port *port = tty->driver_data; |
655 | unsigned int control = 0; | ||
658 | 656 | ||
659 | dbg("%s - port %d", __func__, port->number); | 657 | dbg("%s - port %d", __func__, port->number); |
660 | 658 | ||
@@ -681,9 +679,11 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, | |||
681 | 679 | ||
682 | } | 680 | } |
683 | 681 | ||
684 | static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) | 682 | static int cp2101_tiocmget (struct tty_struct *tty, struct file *file) |
685 | { | 683 | { |
686 | int control, result; | 684 | struct usb_serial_port *port = tty->driver_data; |
685 | unsigned int control; | ||
686 | int result; | ||
687 | 687 | ||
688 | dbg("%s - port %d", __func__, port->number); | 688 | dbg("%s - port %d", __func__, port->number); |
689 | 689 | ||
@@ -701,9 +701,10 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) | |||
701 | return result; | 701 | return result; |
702 | } | 702 | } |
703 | 703 | ||
704 | static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) | 704 | static void cp2101_break_ctl (struct tty_struct *tty, int break_state) |
705 | { | 705 | { |
706 | int state; | 706 | struct usb_serial_port *port = tty->driver_data; |
707 | unsigned int state; | ||
707 | 708 | ||
708 | dbg("%s - port %d", __func__, port->number); | 709 | dbg("%s - port %d", __func__, port->number); |
709 | if (break_state == 0) | 710 | if (break_state == 0) |
@@ -711,30 +712,29 @@ static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) | |||
711 | else | 712 | else |
712 | state = BREAK_ON; | 713 | state = BREAK_ON; |
713 | dbg("%s - turning break %s", __func__, | 714 | dbg("%s - turning break %s", __func__, |
714 | state==BREAK_OFF ? "off" : "on"); | 715 | state == BREAK_OFF ? "off" : "on"); |
715 | cp2101_set_config(port, CP2101_BREAK, &state, 2); | 716 | cp2101_set_config(port, CP2101_BREAK, &state, 2); |
716 | } | 717 | } |
717 | 718 | ||
718 | static int cp2101_startup (struct usb_serial *serial) | 719 | static int cp2101_startup(struct usb_serial *serial) |
719 | { | 720 | { |
720 | /* CP2101 buffers behave strangely unless device is reset */ | 721 | /* CP2101 buffers behave strangely unless device is reset */ |
721 | usb_reset_device(serial->dev); | 722 | usb_reset_device(serial->dev); |
722 | return 0; | 723 | return 0; |
723 | } | 724 | } |
724 | 725 | ||
725 | static void cp2101_shutdown (struct usb_serial *serial) | 726 | static void cp2101_shutdown(struct usb_serial *serial) |
726 | { | 727 | { |
727 | int i; | 728 | int i; |
728 | 729 | ||
729 | dbg("%s", __func__); | 730 | dbg("%s", __func__); |
730 | 731 | ||
731 | /* Stop reads and writes on all ports */ | 732 | /* Stop reads and writes on all ports */ |
732 | for (i=0; i < serial->num_ports; ++i) { | 733 | for (i = 0; i < serial->num_ports; ++i) |
733 | cp2101_cleanup(serial->port[i]); | 734 | cp2101_cleanup(serial->port[i]); |
734 | } | ||
735 | } | 735 | } |
736 | 736 | ||
737 | static int __init cp2101_init (void) | 737 | static int __init cp2101_init(void) |
738 | { | 738 | { |
739 | int retval; | 739 | int retval; |
740 | 740 | ||
@@ -754,10 +754,10 @@ static int __init cp2101_init (void) | |||
754 | return 0; | 754 | return 0; |
755 | } | 755 | } |
756 | 756 | ||
757 | static void __exit cp2101_exit (void) | 757 | static void __exit cp2101_exit(void) |
758 | { | 758 | { |
759 | usb_deregister (&cp2101_driver); | 759 | usb_deregister(&cp2101_driver); |
760 | usb_serial_deregister (&cp2101_device); | 760 | usb_serial_deregister(&cp2101_device); |
761 | } | 761 | } |
762 | 762 | ||
763 | module_init(cp2101_init); | 763 | module_init(cp2101_init); |