diff options
Diffstat (limited to 'drivers/usb/mon/mon_bin.c')
-rw-r--r-- | drivers/usb/mon/mon_bin.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index c03dfd7a9d36..f06e4e2b49d3 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 | ||
175 | static unsigned char xfer_to_pipe[4] = { | ||
176 | PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT | ||
177 | }; | ||
178 | |||
175 | static struct class *mon_bin_class; | 179 | static struct class *mon_bin_class; |
176 | static dev_t mon_bin_dev0; | 180 | static dev_t mon_bin_dev0; |
177 | static struct cdev mon_bin_cdev; | 181 | static struct cdev mon_bin_cdev; |
@@ -354,13 +358,9 @@ static inline char mon_bin_get_setup(unsigned char *setupb, | |||
354 | const struct urb *urb, char ev_type) | 358 | const struct urb *urb, char ev_type) |
355 | { | 359 | { |
356 | 360 | ||
357 | if (!usb_pipecontrol(urb->pipe) || ev_type != 'S') | 361 | if (!usb_endpoint_xfer_control(&urb->ep->desc) || ev_type != 'S') |
358 | return '-'; | 362 | return '-'; |
359 | 363 | ||
360 | if (urb->dev->bus->uses_dma && | ||
361 | (urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) { | ||
362 | return mon_dmapeek(setupb, urb->setup_dma, SETUP_LEN); | ||
363 | } | ||
364 | if (urb->setup_packet == NULL) | 364 | if (urb->setup_packet == NULL) |
365 | return 'Z'; | 365 | return 'Z'; |
366 | 366 | ||
@@ -386,13 +386,15 @@ static char mon_bin_get_data(const struct mon_reader_bin *rp, | |||
386 | } | 386 | } |
387 | 387 | ||
388 | static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, | 388 | static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, |
389 | char ev_type) | 389 | char ev_type, int status) |
390 | { | 390 | { |
391 | const struct usb_endpoint_descriptor *epd = &urb->ep->desc; | ||
391 | unsigned long flags; | 392 | unsigned long flags; |
392 | struct timeval ts; | 393 | struct timeval ts; |
393 | unsigned int urb_length; | 394 | unsigned int urb_length; |
394 | unsigned int offset; | 395 | unsigned int offset; |
395 | unsigned int length; | 396 | unsigned int length; |
397 | unsigned char dir; | ||
396 | struct mon_bin_hdr *ep; | 398 | struct mon_bin_hdr *ep; |
397 | char data_tag = 0; | 399 | char data_tag = 0; |
398 | 400 | ||
@@ -410,16 +412,19 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, | |||
410 | if (length >= rp->b_size/5) | 412 | if (length >= rp->b_size/5) |
411 | length = rp->b_size/5; | 413 | length = rp->b_size/5; |
412 | 414 | ||
413 | if (usb_pipein(urb->pipe)) { | 415 | if (usb_urb_dir_in(urb)) { |
414 | if (ev_type == 'S') { | 416 | if (ev_type == 'S') { |
415 | length = 0; | 417 | length = 0; |
416 | data_tag = '<'; | 418 | data_tag = '<'; |
417 | } | 419 | } |
420 | /* Cannot rely on endpoint number in case of control ep.0 */ | ||
421 | dir = USB_DIR_IN; | ||
418 | } else { | 422 | } else { |
419 | if (ev_type == 'C') { | 423 | if (ev_type == 'C') { |
420 | length = 0; | 424 | length = 0; |
421 | data_tag = '>'; | 425 | data_tag = '>'; |
422 | } | 426 | } |
427 | dir = 0; | ||
423 | } | 428 | } |
424 | 429 | ||
425 | if (rp->mmap_active) | 430 | if (rp->mmap_active) |
@@ -440,15 +445,14 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, | |||
440 | */ | 445 | */ |
441 | memset(ep, 0, PKT_SIZE); | 446 | memset(ep, 0, PKT_SIZE); |
442 | ep->type = ev_type; | 447 | ep->type = ev_type; |
443 | ep->xfer_type = usb_pipetype(urb->pipe); | 448 | ep->xfer_type = xfer_to_pipe[usb_endpoint_type(epd)]; |
444 | /* We use the fact that usb_pipein() returns 0x80 */ | 449 | ep->epnum = dir | usb_endpoint_num(epd); |
445 | ep->epnum = usb_pipeendpoint(urb->pipe) | usb_pipein(urb->pipe); | 450 | ep->devnum = urb->dev->devnum; |
446 | ep->devnum = usb_pipedevice(urb->pipe); | ||
447 | ep->busnum = urb->dev->bus->busnum; | 451 | ep->busnum = urb->dev->bus->busnum; |
448 | ep->id = (unsigned long) urb; | 452 | ep->id = (unsigned long) urb; |
449 | ep->ts_sec = ts.tv_sec; | 453 | ep->ts_sec = ts.tv_sec; |
450 | ep->ts_usec = ts.tv_usec; | 454 | ep->ts_usec = ts.tv_usec; |
451 | ep->status = urb->status; | 455 | ep->status = status; |
452 | ep->len_urb = urb_length; | 456 | ep->len_urb = urb_length; |
453 | ep->len_cap = length; | 457 | ep->len_cap = length; |
454 | 458 | ||
@@ -471,13 +475,13 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, | |||
471 | static void mon_bin_submit(void *data, struct urb *urb) | 475 | static void mon_bin_submit(void *data, struct urb *urb) |
472 | { | 476 | { |
473 | struct mon_reader_bin *rp = data; | 477 | struct mon_reader_bin *rp = data; |
474 | mon_bin_event(rp, urb, 'S'); | 478 | mon_bin_event(rp, urb, 'S', -EINPROGRESS); |
475 | } | 479 | } |
476 | 480 | ||
477 | static void mon_bin_complete(void *data, struct urb *urb) | 481 | static void mon_bin_complete(void *data, struct urb *urb, int status) |
478 | { | 482 | { |
479 | struct mon_reader_bin *rp = data; | 483 | struct mon_reader_bin *rp = data; |
480 | mon_bin_event(rp, urb, 'C'); | 484 | mon_bin_event(rp, urb, 'C', status); |
481 | } | 485 | } |
482 | 486 | ||
483 | static void mon_bin_error(void *data, struct urb *urb, int error) | 487 | static void mon_bin_error(void *data, struct urb *urb, int error) |
@@ -500,10 +504,10 @@ static void mon_bin_error(void *data, struct urb *urb, int error) | |||
500 | 504 | ||
501 | memset(ep, 0, PKT_SIZE); | 505 | memset(ep, 0, PKT_SIZE); |
502 | ep->type = 'E'; | 506 | ep->type = 'E'; |
503 | ep->xfer_type = usb_pipetype(urb->pipe); | 507 | ep->xfer_type = xfer_to_pipe[usb_endpoint_type(&urb->ep->desc)]; |
504 | /* We use the fact that usb_pipein() returns 0x80 */ | 508 | ep->epnum = usb_urb_dir_in(urb) ? USB_DIR_IN : 0; |
505 | ep->epnum = usb_pipeendpoint(urb->pipe) | usb_pipein(urb->pipe); | 509 | ep->epnum |= usb_endpoint_num(&urb->ep->desc); |
506 | ep->devnum = usb_pipedevice(urb->pipe); | 510 | ep->devnum = urb->dev->devnum; |
507 | ep->busnum = urb->dev->bus->busnum; | 511 | ep->busnum = urb->dev->bus->busnum; |
508 | ep->id = (unsigned long) urb; | 512 | ep->id = (unsigned long) urb; |
509 | ep->status = error; | 513 | ep->status = error; |