Commit 18ea5d00 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

USB: avoid urb->pipe in usbmon

This patch (as949) changes the usbmon driver to use the new urb->ep
field rather than urb->pipe.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 93cf9b90
...@@ -354,7 +354,7 @@ static inline char mon_bin_get_setup(unsigned char *setupb, ...@@ -354,7 +354,7 @@ static inline char mon_bin_get_setup(unsigned char *setupb,
const struct urb *urb, char ev_type) const struct urb *urb, char ev_type)
{ {
if (!usb_pipecontrol(urb->pipe) || ev_type != 'S') if (!usb_endpoint_xfer_control(&urb->ep->desc) || ev_type != 'S')
return '-'; return '-';
if (urb->dev->bus->uses_dma && if (urb->dev->bus->uses_dma &&
...@@ -410,7 +410,7 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, ...@@ -410,7 +410,7 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
if (length >= rp->b_size/5) if (length >= rp->b_size/5)
length = rp->b_size/5; length = rp->b_size/5;
if (usb_pipein(urb->pipe)) { if (usb_urb_dir_in(urb)) {
if (ev_type == 'S') { if (ev_type == 'S') {
length = 0; length = 0;
data_tag = '<'; data_tag = '<';
...@@ -440,10 +440,22 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, ...@@ -440,10 +440,22 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
*/ */
memset(ep, 0, PKT_SIZE); memset(ep, 0, PKT_SIZE);
ep->type = ev_type; ep->type = ev_type;
ep->xfer_type = usb_pipetype(urb->pipe); switch (usb_endpoint_type(&urb->ep->desc)) {
/* We use the fact that usb_pipein() returns 0x80 */ case USB_ENDPOINT_XFER_CONTROL:
ep->epnum = usb_pipeendpoint(urb->pipe) | usb_pipein(urb->pipe); ep->xfer_type = PIPE_CONTROL;
ep->devnum = usb_pipedevice(urb->pipe); break;
case USB_ENDPOINT_XFER_BULK:
ep->xfer_type = PIPE_BULK;
break;
case USB_ENDPOINT_XFER_INT:
ep->xfer_type = PIPE_INTERRUPT;
break;
default:
ep->xfer_type = PIPE_ISOCHRONOUS;
break;
}
ep->epnum = urb->ep->desc.bEndpointAddress;
ep->devnum = urb->dev->devnum;
ep->busnum = urb->dev->bus->busnum; ep->busnum = urb->dev->bus->busnum;
ep->id = (unsigned long) urb; ep->id = (unsigned long) urb;
ep->ts_sec = ts.tv_sec; ep->ts_sec = ts.tv_sec;
...@@ -500,10 +512,22 @@ static void mon_bin_error(void *data, struct urb *urb, int error) ...@@ -500,10 +512,22 @@ static void mon_bin_error(void *data, struct urb *urb, int error)
memset(ep, 0, PKT_SIZE); memset(ep, 0, PKT_SIZE);
ep->type = 'E'; ep->type = 'E';
ep->xfer_type = usb_pipetype(urb->pipe); switch (usb_endpoint_type(&urb->ep->desc)) {
/* We use the fact that usb_pipein() returns 0x80 */ case USB_ENDPOINT_XFER_CONTROL:
ep->epnum = usb_pipeendpoint(urb->pipe) | usb_pipein(urb->pipe); ep->xfer_type = PIPE_CONTROL;
ep->devnum = usb_pipedevice(urb->pipe); break;
case USB_ENDPOINT_XFER_BULK:
ep->xfer_type = PIPE_BULK;
break;
case USB_ENDPOINT_XFER_INT:
ep->xfer_type = PIPE_INTERRUPT;
break;
default:
ep->xfer_type = PIPE_ISOCHRONOUS;
break;
}
ep->epnum = urb->ep->desc.bEndpointAddress;
ep->devnum = urb->dev->devnum;
ep->busnum = urb->dev->bus->busnum; ep->busnum = urb->dev->bus->busnum;
ep->id = (unsigned long) urb; ep->id = (unsigned long) urb;
ep->status = error; ep->status = error;
......
...@@ -154,8 +154,8 @@ static void mon_complete(struct usb_bus *ubus, struct urb *urb) ...@@ -154,8 +154,8 @@ static void mon_complete(struct usb_bus *ubus, struct urb *urb)
* This should not happen. * This should not happen.
* At this point we do not even know the bus number... * At this point we do not even know the bus number...
*/ */
printk(KERN_ERR TAG ": Null mon bus in URB, pipe 0x%x\n", printk(KERN_ERR TAG ": Null mon bus in URB, address %p\n",
urb->pipe); urb);
return; return;
} }
......
...@@ -50,10 +50,12 @@ struct mon_iso_desc { ...@@ -50,10 +50,12 @@ struct mon_iso_desc {
struct mon_event_text { struct mon_event_text {
struct list_head e_link; struct list_head e_link;
int type; /* submit, complete, etc. */ int type; /* submit, complete, etc. */
unsigned int pipe; /* Pipe */
unsigned long id; /* From pointer, most of the time */ unsigned long id; /* From pointer, most of the time */
unsigned int tstamp; unsigned int tstamp;
int xfertype;
int busnum; int busnum;
int devnum;
int epnum;
int length; /* Depends on type: xfer length or act length */ int length; /* Depends on type: xfer length or act length */
int status; int status;
int interval; int interval;
...@@ -61,6 +63,7 @@ struct mon_event_text { ...@@ -61,6 +63,7 @@ struct mon_event_text {
int error_count; int error_count;
char setup_flag; char setup_flag;
char data_flag; char data_flag;
char is_in;
int numdesc; /* Full number */ int numdesc; /* Full number */
struct mon_iso_desc isodesc[ISODESC_MAX]; struct mon_iso_desc isodesc[ISODESC_MAX];
unsigned char setup[SETUP_MAX]; unsigned char setup[SETUP_MAX];
...@@ -121,7 +124,7 @@ static inline char mon_text_get_setup(struct mon_event_text *ep, ...@@ -121,7 +124,7 @@ static inline char mon_text_get_setup(struct mon_event_text *ep,
struct urb *urb, char ev_type, struct mon_bus *mbus) struct urb *urb, char ev_type, struct mon_bus *mbus)
{ {
if (!usb_pipecontrol(urb->pipe) || ev_type != 'S') if (ep->xfertype != USB_ENDPOINT_XFER_CONTROL || ev_type != 'S')
return '-'; return '-';
if (urb->dev->bus->uses_dma && if (urb->dev->bus->uses_dma &&
...@@ -138,14 +141,12 @@ static inline char mon_text_get_setup(struct mon_event_text *ep, ...@@ -138,14 +141,12 @@ static inline char mon_text_get_setup(struct mon_event_text *ep,
static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb, static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
int len, char ev_type, struct mon_bus *mbus) int len, char ev_type, struct mon_bus *mbus)
{ {
int pipe = urb->pipe;
if (len <= 0) if (len <= 0)
return 'L'; return 'L';
if (len >= DATA_MAX) if (len >= DATA_MAX)
len = DATA_MAX; len = DATA_MAX;
if (usb_pipein(pipe)) { if (ep->is_in) {
if (ev_type != 'C') if (ev_type != 'C')
return '<'; return '<';
} else { } else {
...@@ -203,24 +204,28 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb, ...@@ -203,24 +204,28 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
} }
ep->type = ev_type; ep->type = ev_type;
ep->pipe = urb->pipe;
ep->id = (unsigned long) urb; ep->id = (unsigned long) urb;
ep->busnum = urb->dev->bus->busnum; ep->busnum = urb->dev->bus->busnum;
ep->devnum = urb->dev->devnum;
ep->epnum = usb_endpoint_num(&urb->ep->desc);
ep->xfertype = usb_endpoint_type(&urb->ep->desc);
ep->is_in = usb_urb_dir_in(urb);
ep->tstamp = stamp; ep->tstamp = stamp;
ep->length = (ev_type == 'S') ? ep->length = (ev_type == 'S') ?
urb->transfer_buffer_length : urb->actual_length; urb->transfer_buffer_length : urb->actual_length;
/* Collecting status makes debugging sense for submits, too */ /* Collecting status makes debugging sense for submits, too */
ep->status = urb->status; ep->status = urb->status;
if (usb_pipeint(urb->pipe)) { if (ep->xfertype == USB_ENDPOINT_XFER_INT) {
ep->interval = urb->interval; ep->interval = urb->interval;
} else if (usb_pipeisoc(urb->pipe)) { } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) {
ep->interval = urb->interval; ep->interval = urb->interval;
ep->start_frame = urb->start_frame; ep->start_frame = urb->start_frame;
ep->error_count = urb->error_count; ep->error_count = urb->error_count;
} }
ep->numdesc = urb->number_of_packets; ep->numdesc = urb->number_of_packets;
if (usb_pipeisoc(urb->pipe) && urb->number_of_packets > 0) { if (ep->xfertype == USB_ENDPOINT_XFER_ISOC &&
urb->number_of_packets > 0) {
if ((ndesc = urb->number_of_packets) > ISODESC_MAX) if ((ndesc = urb->number_of_packets) > ISODESC_MAX)
ndesc = ISODESC_MAX; ndesc = ISODESC_MAX;
fp = urb->iso_frame_desc; fp = urb->iso_frame_desc;
...@@ -268,9 +273,12 @@ static void mon_text_error(void *data, struct urb *urb, int error) ...@@ -268,9 +273,12 @@ static void mon_text_error(void *data, struct urb *urb, int error)
} }
ep->type = 'E'; ep->type = 'E';
ep->pipe = urb->pipe;
ep->id = (unsigned long) urb; ep->id = (unsigned long) urb;
ep->busnum = 0; ep->busnum = 0;
ep->devnum = urb->dev->devnum;
ep->epnum = usb_endpoint_num(&urb->ep->desc);
ep->xfertype = usb_endpoint_type(&urb->ep->desc);
ep->is_in = usb_urb_dir_in(urb);
ep->tstamp = 0; ep->tstamp = 0;
ep->length = 0; ep->length = 0;
ep->status = error; ep->status = error;
...@@ -413,10 +421,10 @@ static ssize_t mon_text_read_u(struct file *file, char __user *buf, ...@@ -413,10 +421,10 @@ static ssize_t mon_text_read_u(struct file *file, char __user *buf,
mon_text_read_head_u(rp, &ptr, ep); mon_text_read_head_u(rp, &ptr, ep);
if (ep->type == 'E') { if (ep->type == 'E') {
mon_text_read_statset(rp, &ptr, ep); mon_text_read_statset(rp, &ptr, ep);
} else if (usb_pipeisoc(ep->pipe)) { } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) {
mon_text_read_isostat(rp, &ptr, ep); mon_text_read_isostat(rp, &ptr, ep);
mon_text_read_isodesc(rp, &ptr, ep); mon_text_read_isodesc(rp, &ptr, ep);
} else if (usb_pipeint(ep->pipe)) { } else if (ep->xfertype == USB_ENDPOINT_XFER_INT) {
mon_text_read_intstat(rp, &ptr, ep); mon_text_read_intstat(rp, &ptr, ep);
} else { } else {
mon_text_read_statset(rp, &ptr, ep); mon_text_read_statset(rp, &ptr, ep);
...@@ -468,18 +476,17 @@ static void mon_text_read_head_t(struct mon_reader_text *rp, ...@@ -468,18 +476,17 @@ static void mon_text_read_head_t(struct mon_reader_text *rp,
{ {
char udir, utype; char udir, utype;
udir = usb_pipein(ep->pipe) ? 'i' : 'o'; udir = (ep->is_in ? 'i' : 'o');
switch (usb_pipetype(ep->pipe)) { switch (ep->xfertype) {
case PIPE_ISOCHRONOUS: utype = 'Z'; break; case USB_ENDPOINT_XFER_ISOC: utype = 'Z'; break;
case PIPE_INTERRUPT: utype = 'I'; break; case USB_ENDPOINT_XFER_INT: utype = 'I'; break;
case PIPE_CONTROL: utype = 'C'; break; case USB_ENDPOINT_XFER_CONTROL: utype = 'C'; break;
default: /* PIPE_BULK */ utype = 'B'; default: /* PIPE_BULK */ utype = 'B';
} }
p->cnt += snprintf(p->pbuf + p->cnt, p->limit - p->cnt, p->cnt += snprintf(p->pbuf + p->cnt, p->limit - p->cnt,
"%lx %u %c %c%c:%03u:%02u", "%lx %u %c %c%c:%03u:%02u",
ep->id, ep->tstamp, ep->type, ep->id, ep->tstamp, ep->type,
utype, udir, utype, udir, ep->devnum, ep->epnum);
usb_pipedevice(ep->pipe), usb_pipeendpoint(ep->pipe));
} }
static void mon_text_read_head_u(struct mon_reader_text *rp, static void mon_text_read_head_u(struct mon_reader_text *rp,
...@@ -487,18 +494,17 @@ static void mon_text_read_head_u(struct mon_reader_text *rp, ...@@ -487,18 +494,17 @@ static void mon_text_read_head_u(struct mon_reader_text *rp,
{ {
char udir, utype; char udir, utype;
udir = usb_pipein(ep->pipe) ? 'i' : 'o'; udir = (ep->is_in ? 'i' : 'o');
switch (usb_pipetype(ep->pipe)) { switch (ep->xfertype) {
case PIPE_ISOCHRONOUS: utype = 'Z'; break; case USB_ENDPOINT_XFER_ISOC: utype = 'Z'; break;
case PIPE_INTERRUPT: utype = 'I'; break; case USB_ENDPOINT_XFER_INT: utype = 'I'; break;
case PIPE_CONTROL: utype = 'C'; break; case USB_ENDPOINT_XFER_CONTROL: utype = 'C'; break;
default: /* PIPE_BULK */ utype = 'B'; default: /* PIPE_BULK */ utype = 'B';
} }
p->cnt += snprintf(p->pbuf + p->cnt, p->limit - p->cnt, p->cnt += snprintf(p->pbuf + p->cnt, p->limit - p->cnt,
"%lx %u %c %c%c:%d:%03u:%u", "%lx %u %c %c%c:%d:%03u:%u",
ep->id, ep->tstamp, ep->type, ep->id, ep->tstamp, ep->type,
utype, udir, utype, udir, ep->busnum, ep->devnum, ep->epnum);
ep->busnum, usb_pipedevice(ep->pipe), usb_pipeendpoint(ep->pipe));
} }
static void mon_text_read_statset(struct mon_reader_text *rp, static void mon_text_read_statset(struct mon_reader_text *rp,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment