diff options
author | Pete Zaitcev <zaitcev@redhat.com> | 2007-08-14 03:33:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:55:14 -0400 |
commit | 30c7431de3631d6a5482a87b7c2453b937e8aa51 (patch) | |
tree | 3780a78433e139b049827aa98a470ca33b491f26 /drivers/usb | |
parent | 283face86b002e670053e9189604852ccb81d357 (diff) |
usbmon: Update pipe removal to suit my taste
This is a set of small updates to Alan's work to make the code more to
my liking. Mostly premature optimizations, but also direction of control
transfers in the binary interface was always out.
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/mon/mon_bin.c | 44 | ||||
-rw-r--r-- | drivers/usb/mon/mon_text.c | 8 |
2 files changed, 18 insertions, 34 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 | ||
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; |
@@ -388,11 +392,13 @@ static char mon_bin_get_data(const struct mon_reader_bin *rp, | |||
388 | static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, | 392 | static 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; |
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index 9d0070ceef52..a74069c2e82b 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c | |||
@@ -52,10 +52,11 @@ struct mon_event_text { | |||
52 | int type; /* submit, complete, etc. */ | 52 | int type; /* submit, complete, etc. */ |
53 | unsigned long id; /* From pointer, most of the time */ | 53 | unsigned long id; /* From pointer, most of the time */ |
54 | unsigned int tstamp; | 54 | unsigned int tstamp; |
55 | int xfertype; | ||
56 | int busnum; | 55 | int busnum; |
57 | int devnum; | 56 | char devnum; |
58 | int epnum; | 57 | char epnum; |
58 | char is_in; | ||
59 | char xfertype; | ||
59 | int length; /* Depends on type: xfer length or act length */ | 60 | int length; /* Depends on type: xfer length or act length */ |
60 | int status; | 61 | int status; |
61 | int interval; | 62 | int interval; |
@@ -63,7 +64,6 @@ struct mon_event_text { | |||
63 | int error_count; | 64 | int error_count; |
64 | char setup_flag; | 65 | char setup_flag; |
65 | char data_flag; | 66 | char data_flag; |
66 | char is_in; | ||
67 | int numdesc; /* Full number */ | 67 | int numdesc; /* Full number */ |
68 | struct mon_iso_desc isodesc[ISODESC_MAX]; | 68 | struct mon_iso_desc isodesc[ISODESC_MAX]; |
69 | unsigned char setup[SETUP_MAX]; | 69 | unsigned char setup[SETUP_MAX]; |