diff options
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 742a5bc44be8..2a70563bbee1 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/tty_flip.h> | 26 | #include <linux/tty_flip.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/moduleparam.h> | 28 | #include <linux/moduleparam.h> |
29 | #include <linux/seq_file.h> | ||
29 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
30 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
31 | #include <linux/list.h> | 32 | #include <linux/list.h> |
@@ -421,57 +422,52 @@ static int serial_break(struct tty_struct *tty, int break_state) | |||
421 | return 0; | 422 | return 0; |
422 | } | 423 | } |
423 | 424 | ||
424 | static int serial_read_proc(char *page, char **start, off_t off, int count, | 425 | static int serial_proc_show(struct seq_file *m, void *v) |
425 | int *eof, void *data) | ||
426 | { | 426 | { |
427 | struct usb_serial *serial; | 427 | struct usb_serial *serial; |
428 | int length = 0; | ||
429 | int i; | 428 | int i; |
430 | off_t begin = 0; | ||
431 | char tmp[40]; | 429 | char tmp[40]; |
432 | 430 | ||
433 | dbg("%s", __func__); | 431 | dbg("%s", __func__); |
434 | length += sprintf(page, "usbserinfo:1.0 driver:2.0\n"); | 432 | seq_puts(m, "usbserinfo:1.0 driver:2.0\n"); |
435 | for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { | 433 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { |
436 | serial = usb_serial_get_by_index(i); | 434 | serial = usb_serial_get_by_index(i); |
437 | if (serial == NULL) | 435 | if (serial == NULL) |
438 | continue; | 436 | continue; |
439 | 437 | ||
440 | length += sprintf(page+length, "%d:", i); | 438 | seq_printf(m, "%d:", i); |
441 | if (serial->type->driver.owner) | 439 | if (serial->type->driver.owner) |
442 | length += sprintf(page+length, " module:%s", | 440 | seq_printf(m, " module:%s", |
443 | module_name(serial->type->driver.owner)); | 441 | module_name(serial->type->driver.owner)); |
444 | length += sprintf(page+length, " name:\"%s\"", | 442 | seq_printf(m, " name:\"%s\"", |
445 | serial->type->description); | 443 | serial->type->description); |
446 | length += sprintf(page+length, " vendor:%04x product:%04x", | 444 | seq_printf(m, " vendor:%04x product:%04x", |
447 | le16_to_cpu(serial->dev->descriptor.idVendor), | 445 | le16_to_cpu(serial->dev->descriptor.idVendor), |
448 | le16_to_cpu(serial->dev->descriptor.idProduct)); | 446 | le16_to_cpu(serial->dev->descriptor.idProduct)); |
449 | length += sprintf(page+length, " num_ports:%d", | 447 | seq_printf(m, " num_ports:%d", serial->num_ports); |
450 | serial->num_ports); | 448 | seq_printf(m, " port:%d", i - serial->minor + 1); |
451 | length += sprintf(page+length, " port:%d", | ||
452 | i - serial->minor + 1); | ||
453 | usb_make_path(serial->dev, tmp, sizeof(tmp)); | 449 | usb_make_path(serial->dev, tmp, sizeof(tmp)); |
454 | length += sprintf(page+length, " path:%s", tmp); | 450 | seq_printf(m, " path:%s", tmp); |
455 | 451 | ||
456 | length += sprintf(page+length, "\n"); | 452 | seq_putc(m, '\n'); |
457 | if ((length + begin) > (off + count)) { | ||
458 | usb_serial_put(serial); | ||
459 | goto done; | ||
460 | } | ||
461 | if ((length + begin) < off) { | ||
462 | begin += length; | ||
463 | length = 0; | ||
464 | } | ||
465 | usb_serial_put(serial); | 453 | usb_serial_put(serial); |
466 | } | 454 | } |
467 | *eof = 1; | 455 | return 0; |
468 | done: | ||
469 | if (off >= (length + begin)) | ||
470 | return 0; | ||
471 | *start = page + (off-begin); | ||
472 | return (count < begin+length-off) ? count : begin+length-off; | ||
473 | } | 456 | } |
474 | 457 | ||
458 | static int serial_proc_open(struct inode *inode, struct file *file) | ||
459 | { | ||
460 | return single_open(file, serial_proc_show, NULL); | ||
461 | } | ||
462 | |||
463 | static const struct file_operations serial_proc_fops = { | ||
464 | .owner = THIS_MODULE, | ||
465 | .open = serial_proc_open, | ||
466 | .read = seq_read, | ||
467 | .llseek = seq_lseek, | ||
468 | .release = single_release, | ||
469 | }; | ||
470 | |||
475 | static int serial_tiocmget(struct tty_struct *tty, struct file *file) | 471 | static int serial_tiocmget(struct tty_struct *tty, struct file *file) |
476 | { | 472 | { |
477 | struct usb_serial_port *port = tty->driver_data; | 473 | struct usb_serial_port *port = tty->driver_data; |
@@ -1113,9 +1109,9 @@ static const struct tty_operations serial_ops = { | |||
1113 | .unthrottle = serial_unthrottle, | 1109 | .unthrottle = serial_unthrottle, |
1114 | .break_ctl = serial_break, | 1110 | .break_ctl = serial_break, |
1115 | .chars_in_buffer = serial_chars_in_buffer, | 1111 | .chars_in_buffer = serial_chars_in_buffer, |
1116 | .read_proc = serial_read_proc, | ||
1117 | .tiocmget = serial_tiocmget, | 1112 | .tiocmget = serial_tiocmget, |
1118 | .tiocmset = serial_tiocmset, | 1113 | .tiocmset = serial_tiocmset, |
1114 | .proc_fops = &serial_proc_fops, | ||
1119 | }; | 1115 | }; |
1120 | 1116 | ||
1121 | struct tty_driver *usb_serial_tty_driver; | 1117 | struct tty_driver *usb_serial_tty_driver; |