Lines Matching full:mbus

21 static void mon_stop(struct mon_bus *mbus);
22 static void mon_dissolve(struct mon_bus *mbus, struct usb_bus *ubus);
34 * This must be called with mon_lock taken because of mbus->ref.
36 void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r) in mon_reader_add() argument
41 spin_lock_irqsave(&mbus->lock, flags); in mon_reader_add()
42 if (mbus->nreaders == 0) { in mon_reader_add()
43 if (mbus == &mon_bus0) { in mon_reader_add()
50 mbus->u_bus->monitored = 1; in mon_reader_add()
53 mbus->nreaders++; in mon_reader_add()
54 list_add_tail(&r->r_link, &mbus->r_list); in mon_reader_add()
55 spin_unlock_irqrestore(&mbus->lock, flags); in mon_reader_add()
57 kref_get(&mbus->ref); in mon_reader_add()
63 * This is called with mon_lock taken, so we can decrement mbus->ref.
65 void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r) in mon_reader_del() argument
69 spin_lock_irqsave(&mbus->lock, flags); in mon_reader_del()
71 --mbus->nreaders; in mon_reader_del()
72 if (mbus->nreaders == 0) in mon_reader_del()
73 mon_stop(mbus); in mon_reader_del()
74 spin_unlock_irqrestore(&mbus->lock, flags); in mon_reader_del()
76 kref_put(&mbus->ref, mon_bus_drop); in mon_reader_del()
81 static void mon_bus_submit(struct mon_bus *mbus, struct urb *urb) in mon_bus_submit() argument
86 spin_lock_irqsave(&mbus->lock, flags); in mon_bus_submit()
87 mbus->cnt_events++; in mon_bus_submit()
88 list_for_each_entry(r, &mbus->r_list, r_link) in mon_bus_submit()
90 spin_unlock_irqrestore(&mbus->lock, flags); in mon_bus_submit()
95 struct mon_bus *mbus; in mon_submit() local
97 mbus = ubus->mon_bus; in mon_submit()
98 if (mbus != NULL) in mon_submit()
99 mon_bus_submit(mbus, urb); in mon_submit()
105 static void mon_bus_submit_error(struct mon_bus *mbus, struct urb *urb, int error) in mon_bus_submit_error() argument
110 spin_lock_irqsave(&mbus->lock, flags); in mon_bus_submit_error()
111 mbus->cnt_events++; in mon_bus_submit_error()
112 list_for_each_entry(r, &mbus->r_list, r_link) in mon_bus_submit_error()
114 spin_unlock_irqrestore(&mbus->lock, flags); in mon_bus_submit_error()
119 struct mon_bus *mbus; in mon_submit_error() local
121 mbus = ubus->mon_bus; in mon_submit_error()
122 if (mbus != NULL) in mon_submit_error()
123 mon_bus_submit_error(mbus, urb, error); in mon_submit_error()
129 static void mon_bus_complete(struct mon_bus *mbus, struct urb *urb, int status) in mon_bus_complete() argument
134 spin_lock_irqsave(&mbus->lock, flags); in mon_bus_complete()
135 mbus->cnt_events++; in mon_bus_complete()
136 list_for_each_entry(r, &mbus->r_list, r_link) in mon_bus_complete()
138 spin_unlock_irqrestore(&mbus->lock, flags); in mon_bus_complete()
143 struct mon_bus *mbus; in mon_complete() local
145 mbus = ubus->mon_bus; in mon_complete()
146 if (mbus != NULL) in mon_complete()
147 mon_bus_complete(mbus, urb, status); in mon_complete()
156 static void mon_stop(struct mon_bus *mbus) in mon_stop() argument
160 if (mbus == &mon_bus0) { in mon_stop()
161 list_for_each_entry(mbus, &mon_buses, bus_link) { in mon_stop()
165 if (mbus->nreaders == 0 && (ubus = mbus->u_bus) != NULL) in mon_stop()
173 if (mon_bus0.nreaders == 0 && (ubus = mbus->u_bus) != NULL) { in mon_stop()
200 struct mon_bus *mbus = ubus->mon_bus; in mon_bus_remove() local
203 list_del(&mbus->bus_link); in mon_bus_remove()
204 if (mbus->text_inited) in mon_bus_remove()
205 mon_text_del(mbus); in mon_bus_remove()
206 if (mbus->bin_inited) in mon_bus_remove()
207 mon_bin_del(mbus); in mon_bus_remove()
209 mon_dissolve(mbus, ubus); in mon_bus_remove()
210 kref_put(&mbus->ref, mon_bus_drop); in mon_bus_remove()
243 static void mon_dissolve(struct mon_bus *mbus, struct usb_bus *ubus) in mon_dissolve() argument
252 mbus->u_bus = NULL; in mon_dissolve()
262 struct mon_bus *mbus = container_of(r, struct mon_bus, ref); in mon_bus_drop() local
263 kfree(mbus); in mon_bus_drop()
274 struct mon_bus *mbus; in mon_bus_init() local
276 mbus = kzalloc(sizeof(struct mon_bus), GFP_KERNEL); in mon_bus_init()
277 if (mbus == NULL) in mon_bus_init()
279 kref_init(&mbus->ref); in mon_bus_init()
280 spin_lock_init(&mbus->lock); in mon_bus_init()
281 INIT_LIST_HEAD(&mbus->r_list); in mon_bus_init()
287 mbus->u_bus = ubus; in mon_bus_init()
288 ubus->mon_bus = mbus; in mon_bus_init()
290 mbus->text_inited = mon_text_add(mbus, ubus); in mon_bus_init()
291 mbus->bin_inited = mon_bin_add(mbus, ubus); in mon_bus_init()
294 list_add_tail(&mbus->bus_link, &mon_buses); in mon_bus_init()
304 struct mon_bus *mbus = &mon_bus0; in mon_bus0_init() local
306 kref_init(&mbus->ref); in mon_bus0_init()
307 spin_lock_init(&mbus->lock); in mon_bus0_init()
308 INIT_LIST_HEAD(&mbus->r_list); in mon_bus0_init()
310 mbus->text_inited = mon_text_add(mbus, NULL); in mon_bus0_init()
311 mbus->bin_inited = mon_bin_add(mbus, NULL); in mon_bus0_init()
324 struct mon_bus *mbus; in mon_bus_lookup() local
329 list_for_each_entry(mbus, &mon_buses, bus_link) { in mon_bus_lookup()
330 if (mbus->u_bus->busnum == num) { in mon_bus_lookup()
331 return mbus; in mon_bus_lookup()
373 struct mon_bus *mbus; in mon_exit() local
383 mbus = list_entry(p, struct mon_bus, bus_link); in mon_exit()
386 if (mbus->text_inited) in mon_exit()
387 mon_text_del(mbus); in mon_exit()
388 if (mbus->bin_inited) in mon_exit()
389 mon_bin_del(mbus); in mon_exit()
396 if (mbus->nreaders) { in mon_exit()
399 mbus->nreaders, mbus->u_bus->busnum); in mon_exit()
400 kref_get(&mbus->ref); /* Force leak */ in mon_exit()
403 mon_dissolve(mbus, mbus->u_bus); in mon_exit()
404 kref_put(&mbus->ref, mon_bus_drop); in mon_exit()
407 mbus = &mon_bus0; in mon_exit()
408 if (mbus->text_inited) in mon_exit()
409 mon_text_del(mbus); in mon_exit()
410 if (mbus->bin_inited) in mon_exit()
411 mon_bin_del(mbus); in mon_exit()