aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/mon/mon_bin.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/mon/mon_bin.c')
-rw-r--r--drivers/usb/mon/mon_bin.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 0b0d77c669da..5185e93dedef 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -172,6 +172,10 @@ static inline struct mon_bin_hdr *MON_OFF2HDR(const struct mon_reader_bin *rp,
172 172
173#define MON_RING_EMPTY(rp) ((rp)->b_cnt == 0) 173#define MON_RING_EMPTY(rp) ((rp)->b_cnt == 0)
174 174
175static unsigned char xfer_to_pipe[4] = {
176 PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT
177};
178
175static struct class *mon_bin_class; 179static struct class *mon_bin_class;
176static dev_t mon_bin_dev0; 180static dev_t mon_bin_dev0;
177static struct cdev mon_bin_cdev; 181static struct cdev mon_bin_cdev;
@@ -388,11 +392,13 @@ static char mon_bin_get_data(const struct mon_reader_bin *rp,
388static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, 392static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
389 char ev_type) 393 char ev_type)
390{ 394{
395 const struct usb_endpoint_descriptor *epd = &urb->ep->desc;
391 unsigned long flags; 396 unsigned long flags;
392 struct timeval ts; 397 struct timeval ts;
393 unsigned int urb_length; 398 unsigned int urb_length;
394 unsigned int offset; 399 unsigned int offset;
395 unsigned int length; 400 unsigned int length;
401 unsigned char dir;
396 struct mon_bin_hdr *ep; 402 struct mon_bin_hdr *ep;
397 char data_tag = 0; 403 char data_tag = 0;
398 404
@@ -415,11 +421,14 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
415 length = 0; 421 length = 0;
416 data_tag = '<'; 422 data_tag = '<';
417 } 423 }
424 /* Cannot rely on endpoint number in case of control ep.0 */
425 dir = USB_DIR_IN;
418 } else { 426 } else {
419 if (ev_type == 'C') { 427 if (ev_type == 'C') {
420 length = 0; 428 length = 0;
421 data_tag = '>'; 429 data_tag = '>';
422 } 430 }
431 dir = 0;
423 } 432 }
424 433
425 if (rp->mmap_active) 434 if (rp->mmap_active)
@@ -440,21 +449,8 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
440 */ 449 */
441 memset(ep, 0, PKT_SIZE); 450 memset(ep, 0, PKT_SIZE);
442 ep->type = ev_type; 451 ep->type = ev_type;
443 switch (usb_endpoint_type(&urb->ep->desc)) { 452 ep->xfer_type = xfer_to_pipe[usb_endpoint_type(epd)];
444 case USB_ENDPOINT_XFER_CONTROL: 453 ep->epnum = dir | usb_endpoint_num(epd);
445 ep->xfer_type = PIPE_CONTROL;
446 break;
447 case USB_ENDPOINT_XFER_BULK:
448 ep->xfer_type = PIPE_BULK;
449 break;
450 case USB_ENDPOINT_XFER_INT:
451 ep->xfer_type = PIPE_INTERRUPT;
452 break;
453 default:
454 ep->xfer_type = PIPE_ISOCHRONOUS;
455 break;
456 }
457 ep->epnum = urb->ep->desc.bEndpointAddress;
458 ep->devnum = urb->dev->devnum; 454 ep->devnum = urb->dev->devnum;
459 ep->busnum = urb->dev->bus->busnum; 455 ep->busnum = urb->dev->bus->busnum;
460 ep->id = (unsigned long) urb; 456 ep->id = (unsigned long) urb;
@@ -512,21 +508,9 @@ static void mon_bin_error(void *data, struct urb *urb, int error)
512 508
513 memset(ep, 0, PKT_SIZE); 509 memset(ep, 0, PKT_SIZE);
514 ep->type = 'E'; 510 ep->type = 'E';
515 switch (usb_endpoint_type(&urb->ep->desc)) { 511 ep->xfer_type = xfer_to_pipe[usb_endpoint_type(&urb->ep->desc)];
516 case USB_ENDPOINT_XFER_CONTROL: 512 ep->epnum = usb_urb_dir_in(urb) ? USB_DIR_IN : 0;
517 ep->xfer_type = PIPE_CONTROL; 513 ep->epnum |= usb_endpoint_num(&urb->ep->desc);
518 break;
519 case USB_ENDPOINT_XFER_BULK:
520 ep->xfer_type = PIPE_BULK;
521 break;
522 case USB_ENDPOINT_XFER_INT:
523 ep->xfer_type = PIPE_INTERRUPT;
524 break;
525 default:
526 ep->xfer_type = PIPE_ISOCHRONOUS;
527 break;
528 }
529 ep->epnum = urb->ep->desc.bEndpointAddress;
530 ep->devnum = urb->dev->devnum; 514 ep->devnum = urb->dev->devnum;
531 ep->busnum = urb->dev->bus->busnum; 515 ep->busnum = urb->dev->bus->busnum;
532 ep->id = (unsigned long) urb; 516 ep->id = (unsigned long) urb;