9 #include <linux/kernel.h>
10 #include <linux/module.h>
13 #include <linux/slab.h>
20 static void mon_stop(
struct mon_bus *mbus);
21 static void mon_dissolve(
struct mon_bus *mbus,
struct usb_bus *ubus);
22 static void mon_bus_drop(
struct kref *
r);
23 static void mon_bus_init(
struct usb_bus *ubus);
46 m1->
u_bus->monitored = 1;
49 mbus->
u_bus->monitored = 1;
54 spin_unlock_irqrestore(&mbus->
lock, flags);
73 spin_unlock_irqrestore(&mbus->
lock, flags);
75 kref_put(&mbus->
ref, mon_bus_drop);
80 static void mon_bus_submit(
struct mon_bus *mbus,
struct urb *
urb)
92 spin_unlock_irqrestore(&mbus->
lock, flags);
95 static void mon_submit(
struct usb_bus *ubus,
struct urb *urb)
99 if ((mbus = ubus->mon_bus) !=
NULL)
100 mon_bus_submit(mbus, urb);
106 static void mon_bus_submit_error(
struct mon_bus *mbus,
struct urb *urb,
int error)
118 spin_unlock_irqrestore(&mbus->
lock, flags);
121 static void mon_submit_error(
struct usb_bus *ubus,
struct urb *urb,
int error)
125 if ((mbus = ubus->mon_bus) !=
NULL)
126 mon_bus_submit_error(mbus, urb, error);
127 mon_bus_submit_error(&
mon_bus0, urb, error);
132 static void mon_bus_complete(
struct mon_bus *mbus,
struct urb *urb,
int status)
144 spin_unlock_irqrestore(&mbus->
lock, flags);
147 static void mon_complete(
struct usb_bus *ubus,
struct urb *urb,
int status)
151 if ((mbus = ubus->mon_bus) !=
NULL)
152 mon_bus_complete(mbus, urb, status);
153 mon_bus_complete(&
mon_bus0, urb, status);
161 static void mon_stop(
struct mon_bus *mbus)
163 struct usb_bus *ubus;
193 static void mon_bus_add(
struct usb_bus *ubus)
205 static void mon_bus_remove(
struct usb_bus *ubus)
207 struct mon_bus *mbus = ubus->mon_bus;
216 mon_dissolve(mbus, ubus);
217 kref_put(&mbus->
ref, mon_bus_drop);
235 .notifier_call = mon_notify,
241 static struct usb_mon_operations mon_ops_0 = {
242 .urb_submit = mon_submit,
243 .urb_submit_error = mon_submit_error,
244 .urb_complete = mon_complete,
250 static void mon_dissolve(
struct mon_bus *mbus,
struct usb_bus *ubus)
253 if (ubus->monitored) {
258 ubus->mon_bus =
NULL;
267 static void mon_bus_drop(
struct kref *r)
279 static void mon_bus_init(
struct usb_bus *ubus)
285 kref_init(&mbus->
ref);
287 INIT_LIST_HEAD(&mbus->
r_list);
294 ubus->mon_bus = mbus;
308 static void mon_bus0_init(
void)
312 kref_init(&mbus->
ref);
314 INIT_LIST_HEAD(&mbus->
r_list);
338 if (mbus->
u_bus->busnum == num) {
345 static int __init mon_init(
void)
347 struct usb_bus *ubus;
357 if (usb_mon_register(&mon_ops_0) != 0) {
380 static void __exit mon_exit(
void)
386 usb_mon_deregister();
390 while (!list_empty(&mon_buses)) {
407 ": Outstanding opens (%d) on usb%d, leaking...\n",
412 mon_dissolve(mbus, mbus->
u_bus);
413 kref_put(&mbus->
ref, mon_bus_drop);