Commit 72adaa962741e8e910300b66bb123b1a9c31a8a8
1 parent
54a5c4cd2e
Exists in
master
and in
4 other branches
[PATCH] USB: convert usbmon to use usb notifiers
This also removes 2 usbmon callbacks. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 3 changed files with 21 additions and 20 deletions Side-by-side Diff
drivers/usb/core/hcd.c
| ... | ... | @@ -793,7 +793,6 @@ |
| 793 | 793 | up (&usb_bus_list_lock); |
| 794 | 794 | |
| 795 | 795 | usb_notify_add_bus(bus); |
| 796 | - usbmon_notify_bus_add (bus); | |
| 797 | 796 | |
| 798 | 797 | dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum); |
| 799 | 798 | return 0; |
| ... | ... | @@ -821,7 +820,6 @@ |
| 821 | 820 | up (&usb_bus_list_lock); |
| 822 | 821 | |
| 823 | 822 | usb_notify_remove_bus(bus); |
| 824 | - usbmon_notify_bus_remove (bus); | |
| 825 | 823 | |
| 826 | 824 | clear_bit (bus->busnum, busmap.busmap); |
| 827 | 825 |
drivers/usb/core/hcd.h
| ... | ... | @@ -421,8 +421,6 @@ |
| 421 | 421 | void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err); |
| 422 | 422 | void (*urb_complete)(struct usb_bus *bus, struct urb *urb); |
| 423 | 423 | /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */ |
| 424 | - void (*bus_add)(struct usb_bus *bus); | |
| 425 | - void (*bus_remove)(struct usb_bus *bus); | |
| 426 | 424 | }; |
| 427 | 425 | |
| 428 | 426 | extern struct usb_mon_operations *mon_ops; |
| 429 | 427 | |
| ... | ... | @@ -445,19 +443,7 @@ |
| 445 | 443 | if (bus->monitored) |
| 446 | 444 | (*mon_ops->urb_complete)(bus, urb); |
| 447 | 445 | } |
| 448 | - | |
| 449 | -static inline void usbmon_notify_bus_add(struct usb_bus *bus) | |
| 450 | -{ | |
| 451 | - if (mon_ops) | |
| 452 | - (*mon_ops->bus_add)(bus); | |
| 453 | -} | |
| 454 | 446 | |
| 455 | -static inline void usbmon_notify_bus_remove(struct usb_bus *bus) | |
| 456 | -{ | |
| 457 | - if (mon_ops) | |
| 458 | - (*mon_ops->bus_remove)(bus); | |
| 459 | -} | |
| 460 | - | |
| 461 | 447 | int usb_mon_register(struct usb_mon_operations *ops); |
| 462 | 448 | void usb_mon_deregister(void); |
| 463 | 449 | |
| ... | ... | @@ -467,8 +453,6 @@ |
| 467 | 453 | static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, |
| 468 | 454 | int error) {} |
| 469 | 455 | static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) {} |
| 470 | -static inline void usbmon_notify_bus_add(struct usb_bus *bus) {} | |
| 471 | -static inline void usbmon_notify_bus_remove(struct usb_bus *bus) {} | |
| 472 | 456 | |
| 473 | 457 | #endif /* CONFIG_USB_MON */ |
| 474 | 458 |
drivers/usb/mon/mon_main.c
| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #include <linux/usb.h> |
| 12 | 12 | #include <linux/debugfs.h> |
| 13 | 13 | #include <linux/smp_lock.h> |
| 14 | +#include <linux/notifier.h> | |
| 14 | 15 | |
| 15 | 16 | #include "usb_mon.h" |
| 16 | 17 | #include "../core/hcd.h" |
| ... | ... | @@ -205,6 +206,23 @@ |
| 205 | 206 | up(&mon_lock); |
| 206 | 207 | } |
| 207 | 208 | |
| 209 | +static int mon_notify(struct notifier_block *self, unsigned long action, | |
| 210 | + void *dev) | |
| 211 | +{ | |
| 212 | + switch (action) { | |
| 213 | + case USB_BUS_ADD: | |
| 214 | + mon_bus_add(dev); | |
| 215 | + break; | |
| 216 | + case USB_BUS_REMOVE: | |
| 217 | + mon_bus_remove(dev); | |
| 218 | + } | |
| 219 | + return NOTIFY_OK; | |
| 220 | +} | |
| 221 | + | |
| 222 | +static struct notifier_block mon_nb = { | |
| 223 | + .notifier_call = mon_notify, | |
| 224 | +}; | |
| 225 | + | |
| 208 | 226 | /* |
| 209 | 227 | * Ops |
| 210 | 228 | */ |
| ... | ... | @@ -212,8 +230,6 @@ |
| 212 | 230 | .urb_submit = mon_submit, |
| 213 | 231 | .urb_submit_error = mon_submit_error, |
| 214 | 232 | .urb_complete = mon_complete, |
| 215 | - .bus_add = mon_bus_add, | |
| 216 | - .bus_remove = mon_bus_remove, | |
| 217 | 233 | }; |
| 218 | 234 | |
| 219 | 235 | /* |
| ... | ... | @@ -329,6 +345,8 @@ |
| 329 | 345 | } |
| 330 | 346 | // MOD_INC_USE_COUNT(which_module?); |
| 331 | 347 | |
| 348 | + usb_register_notify(&mon_nb); | |
| 349 | + | |
| 332 | 350 | down(&usb_bus_list_lock); |
| 333 | 351 | list_for_each_entry (ubus, &usb_bus_list, bus_list) { |
| 334 | 352 | mon_bus_init(mondir, ubus); |
| ... | ... | @@ -342,6 +360,7 @@ |
| 342 | 360 | struct mon_bus *mbus; |
| 343 | 361 | struct list_head *p; |
| 344 | 362 | |
| 363 | + usb_unregister_notify(&mon_nb); | |
| 345 | 364 | usb_mon_deregister(); |
| 346 | 365 | |
| 347 | 366 | down(&mon_lock); |