diff options
author | Pete Zaitcev <zaitcev@redhat.com> | 2006-06-10 01:03:32 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-21 18:04:17 -0400 |
commit | 12e72feab5d9a23107f245b0f241a2484cbb5a4e (patch) | |
tree | 0a7325d03fddd768118e42e25cf7a8214b99a560 | |
parent | 5b1c674d223eef6c6494be8be91e9e3a3054817e (diff) |
[PATCH] USB: implement error event in usbmon
Implement the "error" event in usbmon.
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/mon/mon_main.c | 20 | ||||
-rw-r--r-- | drivers/usb/mon/mon_text.c | 27 | ||||
-rw-r--r-- | drivers/usb/mon/usb_mon.h | 1 |
3 files changed, 44 insertions, 4 deletions
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index 86db92b4915b..275a66f83058 100644 --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c | |||
@@ -114,20 +114,32 @@ out_unlocked: | |||
114 | 114 | ||
115 | /* | 115 | /* |
116 | */ | 116 | */ |
117 | static void mon_submit_error(struct usb_bus *ubus, struct urb *urb, int err) | 117 | static void mon_submit_error(struct usb_bus *ubus, struct urb *urb, int error) |
118 | { | 118 | { |
119 | struct mon_bus *mbus; | 119 | struct mon_bus *mbus; |
120 | unsigned long flags; | ||
121 | struct list_head *pos; | ||
122 | struct mon_reader *r; | ||
120 | 123 | ||
121 | mbus = ubus->mon_bus; | 124 | mbus = ubus->mon_bus; |
122 | if (mbus == NULL) | 125 | if (mbus == NULL) |
123 | goto out_unlocked; | 126 | goto out_unlocked; |
124 | 127 | ||
125 | /* | 128 | spin_lock_irqsave(&mbus->lock, flags); |
126 | * XXX Capture the error code and the 'E' event. | 129 | if (mbus->nreaders == 0) |
127 | */ | 130 | goto out_locked; |
128 | 131 | ||
132 | mbus->cnt_events++; | ||
133 | list_for_each (pos, &mbus->r_list) { | ||
134 | r = list_entry(pos, struct mon_reader, r_link); | ||
135 | r->rnf_error(r->r_data, urb, error); | ||
136 | } | ||
137 | |||
138 | spin_unlock_irqrestore(&mbus->lock, flags); | ||
129 | return; | 139 | return; |
130 | 140 | ||
141 | out_locked: | ||
142 | spin_unlock_irqrestore(&mbus->lock, flags); | ||
131 | out_unlocked: | 143 | out_unlocked: |
132 | return; | 144 | return; |
133 | } | 145 | } |
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index 9f9236bf62d2..e02c1a30c4cd 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c | |||
@@ -182,6 +182,32 @@ static void mon_text_complete(void *data, struct urb *urb) | |||
182 | mon_text_event(rp, urb, 'C'); | 182 | mon_text_event(rp, urb, 'C'); |
183 | } | 183 | } |
184 | 184 | ||
185 | static void mon_text_error(void *data, struct urb *urb, int error) | ||
186 | { | ||
187 | struct mon_reader_text *rp = data; | ||
188 | struct mon_event_text *ep; | ||
189 | |||
190 | if (rp->nevents >= EVENT_MAX || | ||
191 | (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) { | ||
192 | rp->r.m_bus->cnt_text_lost++; | ||
193 | return; | ||
194 | } | ||
195 | |||
196 | ep->type = 'E'; | ||
197 | ep->pipe = urb->pipe; | ||
198 | ep->id = (unsigned long) urb; | ||
199 | ep->tstamp = 0; | ||
200 | ep->length = 0; | ||
201 | ep->status = error; | ||
202 | |||
203 | ep->setup_flag = '-'; | ||
204 | ep->data_flag = 'E'; | ||
205 | |||
206 | rp->nevents++; | ||
207 | list_add_tail(&ep->e_link, &rp->e_list); | ||
208 | wake_up(&rp->wait); | ||
209 | } | ||
210 | |||
185 | /* | 211 | /* |
186 | * Fetch next event from the circular buffer. | 212 | * Fetch next event from the circular buffer. |
187 | */ | 213 | */ |
@@ -235,6 +261,7 @@ static int mon_text_open(struct inode *inode, struct file *file) | |||
235 | rp->r.m_bus = mbus; | 261 | rp->r.m_bus = mbus; |
236 | rp->r.r_data = rp; | 262 | rp->r.r_data = rp; |
237 | rp->r.rnf_submit = mon_text_submit; | 263 | rp->r.rnf_submit = mon_text_submit; |
264 | rp->r.rnf_error = mon_text_error; | ||
238 | rp->r.rnf_complete = mon_text_complete; | 265 | rp->r.rnf_complete = mon_text_complete; |
239 | 266 | ||
240 | snprintf(rp->slab_name, SLAB_NAME_SZ, "mon%dt_%lx", ubus->busnum, | 267 | snprintf(rp->slab_name, SLAB_NAME_SZ, "mon%dt_%lx", ubus->busnum, |
diff --git a/drivers/usb/mon/usb_mon.h b/drivers/usb/mon/usb_mon.h index 92702835b1e5..33678c24ebee 100644 --- a/drivers/usb/mon/usb_mon.h +++ b/drivers/usb/mon/usb_mon.h | |||
@@ -40,6 +40,7 @@ struct mon_reader { | |||
40 | void *r_data; /* Use container_of instead? */ | 40 | void *r_data; /* Use container_of instead? */ |
41 | 41 | ||
42 | void (*rnf_submit)(void *data, struct urb *urb); | 42 | void (*rnf_submit)(void *data, struct urb *urb); |
43 | void (*rnf_error)(void *data, struct urb *urb, int error); | ||
43 | void (*rnf_complete)(void *data, struct urb *urb); | 44 | void (*rnf_complete)(void *data, struct urb *urb); |
44 | }; | 45 | }; |
45 | 46 | ||