USB: reorganize urb->status use in usbmon

This patch (as978) reorganizes the way usbmon uses urb->status.  It
now accepts the status value as an argument.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Alan Stern 2007-08-24 15:41:41 -04:00 committed by Greg Kroah-Hartman
parent 888fda4705
commit 9347d51c52
6 changed files with 24 additions and 21 deletions

View file

@ -1275,7 +1275,7 @@ void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb)
urb->status = -EREMOTEIO; urb->status = -EREMOTEIO;
unmap_urb_for_dma(hcd, urb); unmap_urb_for_dma(hcd, urb);
usbmon_urb_complete(&hcd->self, urb); usbmon_urb_complete(&hcd->self, urb, urb->status);
usb_unanchor_urb(urb); usb_unanchor_urb(urb);
/* pass ownership to the completion handler */ /* pass ownership to the completion handler */

View file

@ -413,7 +413,7 @@ static inline void usbfs_cleanup(void) { }
struct usb_mon_operations { struct usb_mon_operations {
void (*urb_submit)(struct usb_bus *bus, struct urb *urb); void (*urb_submit)(struct usb_bus *bus, struct urb *urb);
void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err); void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err);
void (*urb_complete)(struct usb_bus *bus, struct urb *urb); void (*urb_complete)(struct usb_bus *bus, struct urb *urb, int status);
/* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */ /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */
}; };
@ -432,10 +432,11 @@ static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb,
(*mon_ops->urb_submit_error)(bus, urb, error); (*mon_ops->urb_submit_error)(bus, urb, error);
} }
static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
int status)
{ {
if (bus->monitored) if (bus->monitored)
(*mon_ops->urb_complete)(bus, urb); (*mon_ops->urb_complete)(bus, urb, status);
} }
int usb_mon_register(struct usb_mon_operations *ops); int usb_mon_register(struct usb_mon_operations *ops);
@ -446,7 +447,8 @@ void usb_mon_deregister(void);
static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb) {} static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb) {}
static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb,
int error) {} int error) {}
static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) {} static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
int status) {}
#endif /* CONFIG_USB_MON */ #endif /* CONFIG_USB_MON */

View file

@ -386,7 +386,7 @@ static char mon_bin_get_data(const struct mon_reader_bin *rp,
} }
static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb, static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
char ev_type) char ev_type, int status)
{ {
const struct usb_endpoint_descriptor *epd = &urb->ep->desc; const struct usb_endpoint_descriptor *epd = &urb->ep->desc;
unsigned long flags; unsigned long flags;
@ -452,7 +452,7 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
ep->id = (unsigned long) urb; ep->id = (unsigned long) urb;
ep->ts_sec = ts.tv_sec; ep->ts_sec = ts.tv_sec;
ep->ts_usec = ts.tv_usec; ep->ts_usec = ts.tv_usec;
ep->status = urb->status; ep->status = status;
ep->len_urb = urb_length; ep->len_urb = urb_length;
ep->len_cap = length; ep->len_cap = length;
@ -475,13 +475,13 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,
static void mon_bin_submit(void *data, struct urb *urb) static void mon_bin_submit(void *data, struct urb *urb)
{ {
struct mon_reader_bin *rp = data; struct mon_reader_bin *rp = data;
mon_bin_event(rp, urb, 'S'); mon_bin_event(rp, urb, 'S', -EINPROGRESS);
} }
static void mon_bin_complete(void *data, struct urb *urb) static void mon_bin_complete(void *data, struct urb *urb, int status)
{ {
struct mon_reader_bin *rp = data; struct mon_reader_bin *rp = data;
mon_bin_event(rp, urb, 'C'); mon_bin_event(rp, urb, 'C', status);
} }
static void mon_bin_error(void *data, struct urb *urb, int error) static void mon_bin_error(void *data, struct urb *urb, int error)

View file

@ -129,7 +129,8 @@ static void mon_submit_error(struct usb_bus *ubus, struct urb *urb, int error)
/* /*
*/ */
static void mon_bus_complete(struct mon_bus *mbus, struct urb *urb) static void mon_bus_complete(struct mon_bus *mbus, struct urb *urb,
int status)
{ {
unsigned long flags; unsigned long flags;
struct list_head *pos; struct list_head *pos;
@ -139,18 +140,18 @@ static void mon_bus_complete(struct mon_bus *mbus, struct urb *urb)
mbus->cnt_events++; mbus->cnt_events++;
list_for_each (pos, &mbus->r_list) { list_for_each (pos, &mbus->r_list) {
r = list_entry(pos, struct mon_reader, r_link); r = list_entry(pos, struct mon_reader, r_link);
r->rnf_complete(r->r_data, urb); r->rnf_complete(r->r_data, urb, status);
} }
spin_unlock_irqrestore(&mbus->lock, flags); spin_unlock_irqrestore(&mbus->lock, flags);
} }
static void mon_complete(struct usb_bus *ubus, struct urb *urb) static void mon_complete(struct usb_bus *ubus, struct urb *urb, int status)
{ {
struct mon_bus *mbus; struct mon_bus *mbus;
if ((mbus = ubus->mon_bus) != NULL) if ((mbus = ubus->mon_bus) != NULL)
mon_bus_complete(mbus, urb); mon_bus_complete(mbus, urb, status);
mon_bus_complete(&mon_bus0, urb); mon_bus_complete(&mon_bus0, urb, status);
} }
/* int (*unlink_urb) (struct urb *urb, int status); */ /* int (*unlink_urb) (struct urb *urb, int status); */

View file

@ -183,7 +183,7 @@ static inline unsigned int mon_get_timestamp(void)
} }
static void mon_text_event(struct mon_reader_text *rp, struct urb *urb, static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
char ev_type) char ev_type, int status)
{ {
struct mon_event_text *ep; struct mon_event_text *ep;
unsigned int stamp; unsigned int stamp;
@ -210,7 +210,7 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
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 = status;
if (ep->xfertype == USB_ENDPOINT_XFER_INT) { if (ep->xfertype == USB_ENDPOINT_XFER_INT) {
ep->interval = urb->interval; ep->interval = urb->interval;
@ -248,13 +248,13 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
static void mon_text_submit(void *data, struct urb *urb) static void mon_text_submit(void *data, struct urb *urb)
{ {
struct mon_reader_text *rp = data; struct mon_reader_text *rp = data;
mon_text_event(rp, urb, 'S'); mon_text_event(rp, urb, 'S', -EINPROGRESS);
} }
static void mon_text_complete(void *data, struct urb *urb) static void mon_text_complete(void *data, struct urb *urb, int status)
{ {
struct mon_reader_text *rp = data; struct mon_reader_text *rp = data;
mon_text_event(rp, urb, 'C'); mon_text_event(rp, urb, 'C', status);
} }
static void mon_text_error(void *data, struct urb *urb, int error) static void mon_text_error(void *data, struct urb *urb, int error)

View file

@ -46,7 +46,7 @@ struct mon_reader {
void (*rnf_submit)(void *data, struct urb *urb); void (*rnf_submit)(void *data, struct urb *urb);
void (*rnf_error)(void *data, struct urb *urb, int error); void (*rnf_error)(void *data, struct urb *urb, int error);
void (*rnf_complete)(void *data, struct urb *urb); void (*rnf_complete)(void *data, struct urb *urb, int status);
}; };
void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r); void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);