Commit 72adaa96 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] USB: convert usbmon to use usb notifiers

This also removes 2 usbmon callbacks.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 54a5c4cd
...@@ -793,7 +793,6 @@ static int usb_register_bus(struct usb_bus *bus) ...@@ -793,7 +793,6 @@ static int usb_register_bus(struct usb_bus *bus)
up (&usb_bus_list_lock); up (&usb_bus_list_lock);
usb_notify_add_bus(bus); usb_notify_add_bus(bus);
usbmon_notify_bus_add (bus);
dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum); dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum);
return 0; return 0;
...@@ -821,7 +820,6 @@ static void usb_deregister_bus (struct usb_bus *bus) ...@@ -821,7 +820,6 @@ static void usb_deregister_bus (struct usb_bus *bus)
up (&usb_bus_list_lock); up (&usb_bus_list_lock);
usb_notify_remove_bus(bus); usb_notify_remove_bus(bus);
usbmon_notify_bus_remove (bus);
clear_bit (bus->busnum, busmap.busmap); clear_bit (bus->busnum, busmap.busmap);
......
...@@ -421,8 +421,6 @@ struct usb_mon_operations { ...@@ -421,8 +421,6 @@ struct usb_mon_operations {
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);
/* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */ /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */
void (*bus_add)(struct usb_bus *bus);
void (*bus_remove)(struct usb_bus *bus);
}; };
extern struct usb_mon_operations *mon_ops; extern struct usb_mon_operations *mon_ops;
...@@ -445,18 +443,6 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) ...@@ -445,18 +443,6 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb)
if (bus->monitored) if (bus->monitored)
(*mon_ops->urb_complete)(bus, urb); (*mon_ops->urb_complete)(bus, urb);
} }
static inline void usbmon_notify_bus_add(struct usb_bus *bus)
{
if (mon_ops)
(*mon_ops->bus_add)(bus);
}
static inline void usbmon_notify_bus_remove(struct usb_bus *bus)
{
if (mon_ops)
(*mon_ops->bus_remove)(bus);
}
int usb_mon_register(struct usb_mon_operations *ops); int usb_mon_register(struct usb_mon_operations *ops);
void usb_mon_deregister(void); void usb_mon_deregister(void);
...@@ -467,8 +453,6 @@ static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb) {} ...@@ -467,8 +453,6 @@ 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) {}
static inline void usbmon_notify_bus_add(struct usb_bus *bus) {}
static inline void usbmon_notify_bus_remove(struct usb_bus *bus) {}
#endif /* CONFIG_USB_MON */ #endif /* CONFIG_USB_MON */
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/notifier.h>
#include "usb_mon.h" #include "usb_mon.h"
#include "../core/hcd.h" #include "../core/hcd.h"
...@@ -205,6 +206,23 @@ static void mon_bus_remove(struct usb_bus *ubus) ...@@ -205,6 +206,23 @@ static void mon_bus_remove(struct usb_bus *ubus)
up(&mon_lock); up(&mon_lock);
} }
static int mon_notify(struct notifier_block *self, unsigned long action,
void *dev)
{
switch (action) {
case USB_BUS_ADD:
mon_bus_add(dev);
break;
case USB_BUS_REMOVE:
mon_bus_remove(dev);
}
return NOTIFY_OK;
}
static struct notifier_block mon_nb = {
.notifier_call = mon_notify,
};
/* /*
* Ops * Ops
*/ */
...@@ -212,8 +230,6 @@ static struct usb_mon_operations mon_ops_0 = { ...@@ -212,8 +230,6 @@ static struct usb_mon_operations mon_ops_0 = {
.urb_submit = mon_submit, .urb_submit = mon_submit,
.urb_submit_error = mon_submit_error, .urb_submit_error = mon_submit_error,
.urb_complete = mon_complete, .urb_complete = mon_complete,
.bus_add = mon_bus_add,
.bus_remove = mon_bus_remove,
}; };
/* /*
...@@ -329,6 +345,8 @@ static int __init mon_init(void) ...@@ -329,6 +345,8 @@ static int __init mon_init(void)
} }
// MOD_INC_USE_COUNT(which_module?); // MOD_INC_USE_COUNT(which_module?);
usb_register_notify(&mon_nb);
down(&usb_bus_list_lock); down(&usb_bus_list_lock);
list_for_each_entry (ubus, &usb_bus_list, bus_list) { list_for_each_entry (ubus, &usb_bus_list, bus_list) {
mon_bus_init(mondir, ubus); mon_bus_init(mondir, ubus);
...@@ -342,6 +360,7 @@ static void __exit mon_exit(void) ...@@ -342,6 +360,7 @@ static void __exit mon_exit(void)
struct mon_bus *mbus; struct mon_bus *mbus;
struct list_head *p; struct list_head *p;
usb_unregister_notify(&mon_nb);
usb_mon_deregister(); usb_mon_deregister();
down(&mon_lock); down(&mon_lock);
......
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