aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2006-10-09 15:29:03 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-09 17:19:08 -0400
commit97c4965d970587a1cc4264c1cffbf0ea9c1e35e8 (patch)
treef366774b6f960281ba953b5f82544c1d012c68b6
parent5a42b81f03b756116f982e72838bc358bc4e460f (diff)
[PATCH] mos7840 annotations
__user annotations, NULL noise removal, %p use for pointers Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/usb/serial/mos7840.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 2306d493e55b..021be39fe16e 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1087,7 +1087,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
1087 mos7840_port->icount.tx = 0; 1087 mos7840_port->icount.tx = 0;
1088 mos7840_port->icount.rx = 0; 1088 mos7840_port->icount.rx = 0;
1089 1089
1090 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);
1091 1091
1092 return 0; 1092 return 0;
1093 1093
@@ -1420,7 +1420,6 @@ static int mos7840_write(struct usb_serial_port *port,
1420 int i; 1420 int i;
1421 int bytes_sent = 0; 1421 int bytes_sent = 0;
1422 int transfer_size; 1422 int transfer_size;
1423 int from_user = 0;
1424 1423
1425 struct moschip_port *mos7840_port; 1424 struct moschip_port *mos7840_port;
1426 struct usb_serial *serial; 1425 struct usb_serial *serial;
@@ -1511,15 +1510,7 @@ static int mos7840_write(struct usb_serial_port *port,
1511 } 1510 }
1512 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); 1511 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
1513 1512
1514 if (from_user) { 1513 memcpy(urb->transfer_buffer, current_position, transfer_size);
1515 if (copy_from_user
1516 (urb->transfer_buffer, current_position, transfer_size)) {
1517 bytes_sent = -EFAULT;
1518 goto exit;
1519 }
1520 } else {
1521 memcpy(urb->transfer_buffer, current_position, transfer_size);
1522 }
1523 1514
1524 /* fill urb with data and submit */ 1515 /* fill urb with data and submit */
1525 usb_fill_bulk_urb(urb, 1516 usb_fill_bulk_urb(urb,
@@ -2225,7 +2216,7 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2225 *****************************************************************************/ 2216 *****************************************************************************/
2226 2217
2227static int mos7840_get_lsr_info(struct moschip_port *mos7840_port, 2218static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2228 unsigned int *value) 2219 unsigned int __user *value)
2229{ 2220{
2230 int count; 2221 int count;
2231 unsigned int result = 0; 2222 unsigned int result = 0;
@@ -2248,7 +2239,7 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2248 *****************************************************************************/ 2239 *****************************************************************************/
2249 2240
2250static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port, 2241static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port,
2251 unsigned int *value) 2242 unsigned int __user *value)
2252{ 2243{
2253 unsigned int result = 0; 2244 unsigned int result = 0;
2254 struct tty_struct *tty = mos7840_port->port->tty; 2245 struct tty_struct *tty = mos7840_port->port->tty;
@@ -2271,7 +2262,7 @@ static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port,
2271 *****************************************************************************/ 2262 *****************************************************************************/
2272 2263
2273static int mos7840_set_modem_info(struct moschip_port *mos7840_port, 2264static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2274 unsigned int cmd, unsigned int *value) 2265 unsigned int cmd, unsigned int __user *value)
2275{ 2266{
2276 unsigned int mcr; 2267 unsigned int mcr;
2277 unsigned int arg; 2268 unsigned int arg;
@@ -2341,7 +2332,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2341 *****************************************************************************/ 2332 *****************************************************************************/
2342 2333
2343static int mos7840_get_modem_info(struct moschip_port *mos7840_port, 2334static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2344 unsigned int *value) 2335 unsigned int __user *value)
2345{ 2336{
2346 unsigned int result = 0; 2337 unsigned int result = 0;
2347 __u16 msr; 2338 __u16 msr;
@@ -2370,7 +2361,7 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2370 *****************************************************************************/ 2361 *****************************************************************************/
2371 2362
2372static int mos7840_get_serial_info(struct moschip_port *mos7840_port, 2363static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
2373 struct serial_struct *retinfo) 2364 struct serial_struct __user *retinfo)
2374{ 2365{
2375 struct serial_struct tmp; 2366 struct serial_struct tmp;
2376 2367
@@ -2405,6 +2396,7 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
2405static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, 2396static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2406 unsigned int cmd, unsigned long arg) 2397 unsigned int cmd, unsigned long arg)
2407{ 2398{
2399 void __user *argp = (void __user *)arg;
2408 struct moschip_port *mos7840_port; 2400 struct moschip_port *mos7840_port;
2409 struct tty_struct *tty; 2401 struct tty_struct *tty;
2410 2402
@@ -2433,16 +2425,13 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2433 2425
2434 case TIOCINQ: 2426 case TIOCINQ:
2435 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number); 2427 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number);
2436 return mos7840_get_bytes_avail(mos7840_port, 2428 return mos7840_get_bytes_avail(mos7840_port, argp);
2437 (unsigned int *)arg);
2438 break;
2439 2429
2440 case TIOCOUTQ: 2430 case TIOCOUTQ:
2441 dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number); 2431 dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number);
2442 return put_user(tty->driver->chars_in_buffer ? 2432 return put_user(tty->driver->chars_in_buffer ?
2443 tty->driver->chars_in_buffer(tty) : 0, 2433 tty->driver->chars_in_buffer(tty) : 0,
2444 (int __user *)arg); 2434 (int __user *)arg);
2445 break;
2446 2435
2447 case TCFLSH: 2436 case TCFLSH:
2448 retval = tty_check_change(tty); 2437 retval = tty_check_change(tty);
@@ -2472,13 +2461,13 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2472 2461
2473 case TCGETS: 2462 case TCGETS:
2474 if (kernel_termios_to_user_termios 2463 if (kernel_termios_to_user_termios
2475 ((struct termios __user *)arg, tty->termios)) 2464 ((struct termios __user *)argp, tty->termios))
2476 return -EFAULT; 2465 return -EFAULT;
2477 return 0; 2466 return 0;
2478 2467
2479 case TIOCSERGETLSR: 2468 case TIOCSERGETLSR:
2480 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); 2469 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
2481 return mos7840_get_lsr_info(mos7840_port, (unsigned int *)arg); 2470 return mos7840_get_lsr_info(mos7840_port, argp);
2482 return 0; 2471 return 0;
2483 2472
2484 case TIOCMBIS: 2473 case TIOCMBIS:
@@ -2487,19 +2476,16 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2487 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, 2476 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,
2488 port->number); 2477 port->number);
2489 mosret = 2478 mosret =
2490 mos7840_set_modem_info(mos7840_port, cmd, 2479 mos7840_set_modem_info(mos7840_port, cmd, argp);
2491 (unsigned int *)arg);
2492 return mosret; 2480 return mosret;
2493 2481
2494 case TIOCMGET: 2482 case TIOCMGET:
2495 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number); 2483 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
2496 return mos7840_get_modem_info(mos7840_port, 2484 return mos7840_get_modem_info(mos7840_port, argp);
2497 (unsigned int *)arg);
2498 2485
2499 case TIOCGSERIAL: 2486 case TIOCGSERIAL:
2500 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number); 2487 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number);
2501 return mos7840_get_serial_info(mos7840_port, 2488 return mos7840_get_serial_info(mos7840_port, argp);
2502 (struct serial_struct *)arg);
2503 2489
2504 case TIOCSSERIAL: 2490 case TIOCSSERIAL:
2505 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number); 2491 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number);
@@ -2549,7 +2535,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2549 2535
2550 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__, 2536 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__,
2551 port->number, icount.rx, icount.tx); 2537 port->number, icount.rx, icount.tx);
2552 if (copy_to_user((void *)arg, &icount, sizeof(icount))) 2538 if (copy_to_user(argp, &icount, sizeof(icount)))
2553 return -EFAULT; 2539 return -EFAULT;
2554 return 0; 2540 return 0;
2555 2541
@@ -2817,7 +2803,7 @@ static int mos7840_startup(struct usb_serial *serial)
2817 2803
2818 /* setting configuration feature to one */ 2804 /* setting configuration feature to one */
2819 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2805 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2820 (__u8) 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 5 * HZ); 2806 (__u8) 0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5 * HZ);
2821 return 0; 2807 return 0;
2822} 2808}
2823 2809