aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/mon/mon_bin.c
diff options
context:
space:
mode:
authorPete Zaitcev <zaitcev@redhat.com>2007-04-11 16:47:26 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 16:28:39 -0400
commitecb658d387dc09f344b3d755e8674076072032c7 (patch)
treeb24067478554d5514db22ca6b107b8258e22b7e3 /drivers/usb/mon/mon_bin.c
parent35d07fd58f47284adecf219d3b73e4ea197cf29f (diff)
usbmon: bus zero
Add the "bus zero" feature to the usbmon. If a user process specifies bus with number zero, it receives events from all buses. This is useful when we wish to see initial enumeration when a bus is created, typically after a modprobe. Until now, an application had to loop until a new bus could be open, then start capturing on it. This procedure was cumbersome and could lose initial events. Also, often it's too bothersome to find exactly to which bus a specific device is attached. Paolo Albeni provided the original concept implementation. I added the handling of "bus->monitored" flag and generally fixed it up. Signed-off-by: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/mon/mon_bin.c')
-rw-r--r--drivers/usb/mon/mon_bin.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index b2bedd974ac3..0af11a66207c 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -356,8 +356,10 @@ static inline char mon_bin_get_setup(unsigned char *setupb,
356 if (!usb_pipecontrol(urb->pipe) || ev_type != 'S') 356 if (!usb_pipecontrol(urb->pipe) || ev_type != 'S')
357 return '-'; 357 return '-';
358 358
359 if (urb->transfer_flags & URB_NO_SETUP_DMA_MAP) 359 if (urb->dev->bus->uses_dma &&
360 (urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) {
360 return mon_dmapeek(setupb, urb->setup_dma, SETUP_LEN); 361 return mon_dmapeek(setupb, urb->setup_dma, SETUP_LEN);
362 }
361 if (urb->setup_packet == NULL) 363 if (urb->setup_packet == NULL)
362 return 'Z'; 364 return 'Z';
363 365
@@ -369,7 +371,8 @@ static char mon_bin_get_data(const struct mon_reader_bin *rp,
369 unsigned int offset, struct urb *urb, unsigned int length) 371 unsigned int offset, struct urb *urb, unsigned int length)
370{ 372{
371 373
372 if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) { 374 if (urb->dev->bus->uses_dma &&
375 (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) {
373 mon_dmapeek_vec(rp, offset, urb->transfer_dma, length); 376 mon_dmapeek_vec(rp, offset, urb->transfer_dma, length);
374 return 0; 377 return 0;
375 } 378 }
@@ -440,7 +443,7 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
440 /* We use the fact that usb_pipein() returns 0x80 */ 443 /* We use the fact that usb_pipein() returns 0x80 */
441 ep->epnum = usb_pipeendpoint(urb->pipe) | usb_pipein(urb->pipe); 444 ep->epnum = usb_pipeendpoint(urb->pipe) | usb_pipein(urb->pipe);
442 ep->devnum = usb_pipedevice(urb->pipe); 445 ep->devnum = usb_pipedevice(urb->pipe);
443 ep->busnum = rp->r.m_bus->u_bus->busnum; 446 ep->busnum = urb->dev->bus->busnum;
444 ep->id = (unsigned long) urb; 447 ep->id = (unsigned long) urb;
445 ep->ts_sec = ts.tv_sec; 448 ep->ts_sec = ts.tv_sec;
446 ep->ts_usec = ts.tv_usec; 449 ep->ts_usec = ts.tv_usec;
@@ -500,7 +503,7 @@ static void mon_bin_error(void *data, struct urb *urb, int error)
500 /* We use the fact that usb_pipein() returns 0x80 */ 503 /* We use the fact that usb_pipein() returns 0x80 */
501 ep->epnum = usb_pipeendpoint(urb->pipe) | usb_pipein(urb->pipe); 504 ep->epnum = usb_pipeendpoint(urb->pipe) | usb_pipein(urb->pipe);
502 ep->devnum = usb_pipedevice(urb->pipe); 505 ep->devnum = usb_pipedevice(urb->pipe);
503 ep->busnum = rp->r.m_bus->u_bus->busnum; 506 ep->busnum = urb->dev->bus->busnum;
504 ep->id = (unsigned long) urb; 507 ep->id = (unsigned long) urb;
505 ep->status = error; 508 ep->status = error;
506 509
@@ -515,7 +518,6 @@ static void mon_bin_error(void *data, struct urb *urb, int error)
515static int mon_bin_open(struct inode *inode, struct file *file) 518static int mon_bin_open(struct inode *inode, struct file *file)
516{ 519{
517 struct mon_bus *mbus; 520 struct mon_bus *mbus;
518 struct usb_bus *ubus;
519 struct mon_reader_bin *rp; 521 struct mon_reader_bin *rp;
520 size_t size; 522 size_t size;
521 int rc; 523 int rc;
@@ -525,7 +527,7 @@ static int mon_bin_open(struct inode *inode, struct file *file)
525 mutex_unlock(&mon_lock); 527 mutex_unlock(&mon_lock);
526 return -ENODEV; 528 return -ENODEV;
527 } 529 }
528 if ((ubus = mbus->u_bus) == NULL) { 530 if (mbus != &mon_bus0 && mbus->u_bus == NULL) {
529 printk(KERN_ERR TAG ": consistency error on open\n"); 531 printk(KERN_ERR TAG ": consistency error on open\n");
530 mutex_unlock(&mon_lock); 532 mutex_unlock(&mon_lock);
531 return -ENODEV; 533 return -ENODEV;