diff options
Diffstat (limited to 'drivers/usb/mon/mon_bin.c')
-rw-r--r-- | drivers/usb/mon/mon_bin.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index c436e1e2c3b6..a09dbd243eb3 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c | |||
@@ -436,6 +436,28 @@ static unsigned int mon_bin_get_data(const struct mon_reader_bin *rp, | |||
436 | return length; | 436 | return length; |
437 | } | 437 | } |
438 | 438 | ||
439 | /* | ||
440 | * This is the look-ahead pass in case of 'C Zi', when actual_length cannot | ||
441 | * be used to determine the length of the whole contiguous buffer. | ||
442 | */ | ||
443 | static unsigned int mon_bin_collate_isodesc(const struct mon_reader_bin *rp, | ||
444 | struct urb *urb, unsigned int ndesc) | ||
445 | { | ||
446 | struct usb_iso_packet_descriptor *fp; | ||
447 | unsigned int length; | ||
448 | |||
449 | length = 0; | ||
450 | fp = urb->iso_frame_desc; | ||
451 | while (ndesc-- != 0) { | ||
452 | if (fp->actual_length != 0) { | ||
453 | if (fp->offset + fp->actual_length > length) | ||
454 | length = fp->offset + fp->actual_length; | ||
455 | } | ||
456 | fp++; | ||
457 | } | ||
458 | return length; | ||
459 | } | ||
460 | |||
439 | static void mon_bin_get_isodesc(const struct mon_reader_bin *rp, | 461 | static void mon_bin_get_isodesc(const struct mon_reader_bin *rp, |
440 | unsigned int offset, struct urb *urb, char ev_type, unsigned int ndesc) | 462 | unsigned int offset, struct urb *urb, char ev_type, unsigned int ndesc) |
441 | { | 463 | { |
@@ -478,6 +500,10 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, | |||
478 | /* | 500 | /* |
479 | * Find the maximum allowable length, then allocate space. | 501 | * Find the maximum allowable length, then allocate space. |
480 | */ | 502 | */ |
503 | urb_length = (ev_type == 'S') ? | ||
504 | urb->transfer_buffer_length : urb->actual_length; | ||
505 | length = urb_length; | ||
506 | |||
481 | if (usb_endpoint_xfer_isoc(epd)) { | 507 | if (usb_endpoint_xfer_isoc(epd)) { |
482 | if (urb->number_of_packets < 0) { | 508 | if (urb->number_of_packets < 0) { |
483 | ndesc = 0; | 509 | ndesc = 0; |
@@ -486,14 +512,16 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, | |||
486 | } else { | 512 | } else { |
487 | ndesc = urb->number_of_packets; | 513 | ndesc = urb->number_of_packets; |
488 | } | 514 | } |
515 | if (ev_type == 'C' && usb_urb_dir_in(urb)) | ||
516 | length = mon_bin_collate_isodesc(rp, urb, ndesc); | ||
489 | } else { | 517 | } else { |
490 | ndesc = 0; | 518 | ndesc = 0; |
491 | } | 519 | } |
492 | lendesc = ndesc*sizeof(struct mon_bin_isodesc); | 520 | lendesc = ndesc*sizeof(struct mon_bin_isodesc); |
493 | 521 | ||
494 | urb_length = (ev_type == 'S') ? | 522 | /* not an issue unless there's a subtle bug in a HCD somewhere */ |
495 | urb->transfer_buffer_length : urb->actual_length; | 523 | if (length >= urb->transfer_buffer_length) |
496 | length = urb_length; | 524 | length = urb->transfer_buffer_length; |
497 | 525 | ||
498 | if (length >= rp->b_size/5) | 526 | if (length >= rp->b_size/5) |
499 | length = rp->b_size/5; | 527 | length = rp->b_size/5; |