aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mos7840.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/mos7840.c')
-rw-r--r--drivers/usb/serial/mos7840.c58
1 files changed, 22 insertions, 36 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 95bf57166c59..5b71962d0351 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -421,7 +421,7 @@ static int mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
421/************************************************************************/ 421/************************************************************************/
422/************************************************************************/ 422/************************************************************************/
423 423
424static void mos7840_control_callback(struct urb *urb, struct pt_regs *regs) 424static void mos7840_control_callback(struct urb *urb)
425{ 425{
426 unsigned char *data; 426 unsigned char *data;
427 struct moschip_port *mos7840_port; 427 struct moschip_port *mos7840_port;
@@ -497,7 +497,7 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
497 * interrupt endpoint. 497 * interrupt endpoint.
498 *****************************************************************************/ 498 *****************************************************************************/
499 499
500static void mos7840_interrupt_callback(struct urb *urb, struct pt_regs *regs) 500static void mos7840_interrupt_callback(struct urb *urb)
501{ 501{
502 int result; 502 int result;
503 int length; 503 int length;
@@ -647,7 +647,7 @@ static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port,
647 * bulk in endpoint. 647 * bulk in endpoint.
648 *****************************************************************************/ 648 *****************************************************************************/
649 649
650static void mos7840_bulk_in_callback(struct urb *urb, struct pt_regs *regs) 650static void mos7840_bulk_in_callback(struct urb *urb)
651{ 651{
652 int status; 652 int status;
653 unsigned char *data; 653 unsigned char *data;
@@ -726,8 +726,7 @@ static void mos7840_bulk_in_callback(struct urb *urb, struct pt_regs *regs)
726 * on the bulk out endpoint. 726 * on the bulk out endpoint.
727 *****************************************************************************/ 727 *****************************************************************************/
728 728
729static void mos7840_bulk_out_data_callback(struct urb *urb, 729static void mos7840_bulk_out_data_callback(struct urb *urb)
730 struct pt_regs *regs)
731{ 730{
732 struct moschip_port *mos7840_port; 731 struct moschip_port *mos7840_port;
733 struct tty_struct *tty; 732 struct tty_struct *tty;
@@ -1088,7 +1087,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
1088 mos7840_port->icount.tx = 0; 1087 mos7840_port->icount.tx = 0;
1089 mos7840_port->icount.rx = 0; 1088 mos7840_port->icount.rx = 0;
1090 1089
1091 dbg("\n\nusb_serial serial:%x mos7840_port:%x\n usb_serial_port port:%x\n\n", (unsigned int)serial, (unsigned int)mos7840_port, (unsigned int)port); 1090 dbg("\n\nusb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p\n\n", serial, mos7840_port, port);
1092 1091
1093 return 0; 1092 return 0;
1094 1093
@@ -1421,7 +1420,6 @@ static int mos7840_write(struct usb_serial_port *port,
1421 int i; 1420 int i;
1422 int bytes_sent = 0; 1421 int bytes_sent = 0;
1423 int transfer_size; 1422 int transfer_size;
1424 int from_user = 0;
1425 1423
1426 struct moschip_port *mos7840_port; 1424 struct moschip_port *mos7840_port;
1427 struct usb_serial *serial; 1425 struct usb_serial *serial;
@@ -1512,15 +1510,7 @@ static int mos7840_write(struct usb_serial_port *port,
1512 } 1510 }
1513 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); 1511 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
1514 1512
1515 if (from_user) { 1513 memcpy(urb->transfer_buffer, current_position, transfer_size);
1516 if (copy_from_user
1517 (urb->transfer_buffer, current_position, transfer_size)) {
1518 bytes_sent = -EFAULT;
1519 goto exit;
1520 }
1521 } else {
1522 memcpy(urb->transfer_buffer, current_position, transfer_size);
1523 }
1524 1514
1525 /* fill urb with data and submit */ 1515 /* fill urb with data and submit */
1526 usb_fill_bulk_urb(urb, 1516 usb_fill_bulk_urb(urb,
@@ -2226,7 +2216,7 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2226 *****************************************************************************/ 2216 *****************************************************************************/
2227 2217
2228static int mos7840_get_lsr_info(struct moschip_port *mos7840_port, 2218static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2229 unsigned int *value) 2219 unsigned int __user *value)
2230{ 2220{
2231 int count; 2221 int count;
2232 unsigned int result = 0; 2222 unsigned int result = 0;
@@ -2249,7 +2239,7 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2249 *****************************************************************************/ 2239 *****************************************************************************/
2250 2240
2251static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port, 2241static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port,
2252 unsigned int *value) 2242 unsigned int __user *value)
2253{ 2243{
2254 unsigned int result = 0; 2244 unsigned int result = 0;
2255 struct tty_struct *tty = mos7840_port->port->tty; 2245 struct tty_struct *tty = mos7840_port->port->tty;
@@ -2272,7 +2262,7 @@ static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port,
2272 *****************************************************************************/ 2262 *****************************************************************************/
2273 2263
2274static int mos7840_set_modem_info(struct moschip_port *mos7840_port, 2264static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2275 unsigned int cmd, unsigned int *value) 2265 unsigned int cmd, unsigned int __user *value)
2276{ 2266{
2277 unsigned int mcr; 2267 unsigned int mcr;
2278 unsigned int arg; 2268 unsigned int arg;
@@ -2342,7 +2332,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2342 *****************************************************************************/ 2332 *****************************************************************************/
2343 2333
2344static int mos7840_get_modem_info(struct moschip_port *mos7840_port, 2334static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2345 unsigned int *value) 2335 unsigned int __user *value)
2346{ 2336{
2347 unsigned int result = 0; 2337 unsigned int result = 0;
2348 __u16 msr; 2338 __u16 msr;
@@ -2371,7 +2361,7 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2371 *****************************************************************************/ 2361 *****************************************************************************/
2372 2362
2373static int mos7840_get_serial_info(struct moschip_port *mos7840_port, 2363static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
2374 struct serial_struct *retinfo) 2364 struct serial_struct __user *retinfo)
2375{ 2365{
2376 struct serial_struct tmp; 2366 struct serial_struct tmp;
2377 2367
@@ -2406,6 +2396,7 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
2406static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, 2396static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2407 unsigned int cmd, unsigned long arg) 2397 unsigned int cmd, unsigned long arg)
2408{ 2398{
2399 void __user *argp = (void __user *)arg;
2409 struct moschip_port *mos7840_port; 2400 struct moschip_port *mos7840_port;
2410 struct tty_struct *tty; 2401 struct tty_struct *tty;
2411 2402
@@ -2422,11 +2413,12 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2422 } 2413 }
2423 2414
2424 mos7840_port = mos7840_get_port_private(port); 2415 mos7840_port = mos7840_get_port_private(port);
2425 tty = mos7840_port->port->tty;
2426 2416
2427 if (mos7840_port == NULL) 2417 if (mos7840_port == NULL)
2428 return -1; 2418 return -1;
2429 2419
2420 tty = mos7840_port->port->tty;
2421
2430 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); 2422 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd);
2431 2423
2432 switch (cmd) { 2424 switch (cmd) {
@@ -2434,16 +2426,13 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2434 2426
2435 case TIOCINQ: 2427 case TIOCINQ:
2436 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number); 2428 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number);
2437 return mos7840_get_bytes_avail(mos7840_port, 2429 return mos7840_get_bytes_avail(mos7840_port, argp);
2438 (unsigned int *)arg);
2439 break;
2440 2430
2441 case TIOCOUTQ: 2431 case TIOCOUTQ:
2442 dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number); 2432 dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number);
2443 return put_user(tty->driver->chars_in_buffer ? 2433 return put_user(tty->driver->chars_in_buffer ?
2444 tty->driver->chars_in_buffer(tty) : 0, 2434 tty->driver->chars_in_buffer(tty) : 0,
2445 (int __user *)arg); 2435 (int __user *)arg);
2446 break;
2447 2436
2448 case TCFLSH: 2437 case TCFLSH:
2449 retval = tty_check_change(tty); 2438 retval = tty_check_change(tty);
@@ -2473,13 +2462,13 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2473 2462
2474 case TCGETS: 2463 case TCGETS:
2475 if (kernel_termios_to_user_termios 2464 if (kernel_termios_to_user_termios
2476 ((struct termios __user *)arg, tty->termios)) 2465 ((struct termios __user *)argp, tty->termios))
2477 return -EFAULT; 2466 return -EFAULT;
2478 return 0; 2467 return 0;
2479 2468
2480 case TIOCSERGETLSR: 2469 case TIOCSERGETLSR:
2481 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); 2470 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
2482 return mos7840_get_lsr_info(mos7840_port, (unsigned int *)arg); 2471 return mos7840_get_lsr_info(mos7840_port, argp);
2483 return 0; 2472 return 0;
2484 2473
2485 case TIOCMBIS: 2474 case TIOCMBIS:
@@ -2488,19 +2477,16 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2488 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, 2477 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,
2489 port->number); 2478 port->number);
2490 mosret = 2479 mosret =
2491 mos7840_set_modem_info(mos7840_port, cmd, 2480 mos7840_set_modem_info(mos7840_port, cmd, argp);
2492 (unsigned int *)arg);
2493 return mosret; 2481 return mosret;
2494 2482
2495 case TIOCMGET: 2483 case TIOCMGET:
2496 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number); 2484 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
2497 return mos7840_get_modem_info(mos7840_port, 2485 return mos7840_get_modem_info(mos7840_port, argp);
2498 (unsigned int *)arg);
2499 2486
2500 case TIOCGSERIAL: 2487 case TIOCGSERIAL:
2501 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number); 2488 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number);
2502 return mos7840_get_serial_info(mos7840_port, 2489 return mos7840_get_serial_info(mos7840_port, argp);
2503 (struct serial_struct *)arg);
2504 2490
2505 case TIOCSSERIAL: 2491 case TIOCSSERIAL:
2506 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number); 2492 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number);
@@ -2550,7 +2536,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2550 2536
2551 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, 2537 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__,
2552 port->number, icount.rx, icount.tx); 2538 port->number, icount.rx, icount.tx);
2553 if (copy_to_user((void *)arg, &icount, sizeof(icount))) 2539 if (copy_to_user(argp, &icount, sizeof(icount)))
2554 return -EFAULT; 2540 return -EFAULT;
2555 return 0; 2541 return 0;
2556 2542
@@ -2818,7 +2804,7 @@ static int mos7840_startup(struct usb_serial *serial)
2818 2804
2819 /* setting configuration feature to one */ 2805 /* setting configuration feature to one */
2820 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2806 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2821 (__u8) 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 5 * HZ); 2807 (__u8) 0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5 * HZ);
2822 return 0; 2808 return 0;
2823} 2809}
2824 2810