Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] USB: convert usbmon to use usb notifiers

This also removes 2 usbmon callbacks.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

+21 -20
-2
drivers/usb/core/hcd.c
··· 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; ··· 820 821 up (&usb_bus_list_lock); 821 822 822 823 usb_notify_remove_bus(bus); 823 - usbmon_notify_bus_remove (bus); 824 824 825 825 clear_bit (bus->busnum, busmap.busmap); 826 826
-16
drivers/usb/core/hcd.h
··· 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; ··· 443 445 if (bus->monitored) 444 446 (*mon_ops->urb_complete)(bus, urb); 445 447 } 446 - 447 - static inline void usbmon_notify_bus_add(struct usb_bus *bus) 448 - { 449 - if (mon_ops) 450 - (*mon_ops->bus_add)(bus); 451 - } 452 - 453 - static inline void usbmon_notify_bus_remove(struct usb_bus *bus) 454 - { 455 - if (mon_ops) 456 - (*mon_ops->bus_remove)(bus); 457 - } 458 448 459 449 int usb_mon_register(struct usb_mon_operations *ops); 460 450 void usb_mon_deregister(void); ··· 453 467 static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, 454 468 int error) {} 455 469 static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) {} 456 - static inline void usbmon_notify_bus_add(struct usb_bus *bus) {} 457 - static inline void usbmon_notify_bus_remove(struct usb_bus *bus) {} 458 470 459 471 #endif /* CONFIG_USB_MON */ 460 472
+21 -2
drivers/usb/mon/mon_main.c
··· 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" ··· 206 205 up(&mon_lock); 207 206 } 208 207 208 + static int mon_notify(struct notifier_block *self, unsigned long action, 209 + void *dev) 210 + { 211 + switch (action) { 212 + case USB_BUS_ADD: 213 + mon_bus_add(dev); 214 + break; 215 + case USB_BUS_REMOVE: 216 + mon_bus_remove(dev); 217 + } 218 + return NOTIFY_OK; 219 + } 220 + 221 + static struct notifier_block mon_nb = { 222 + .notifier_call = mon_notify, 223 + }; 224 + 209 225 /* 210 226 * Ops 211 227 */ ··· 230 212 .urb_submit = mon_submit, 231 213 .urb_submit_error = mon_submit_error, 232 214 .urb_complete = mon_complete, 233 - .bus_add = mon_bus_add, 234 - .bus_remove = mon_bus_remove, 235 215 }; 236 216 237 217 /* ··· 345 329 } 346 330 // MOD_INC_USE_COUNT(which_module?); 347 331 332 + usb_register_notify(&mon_nb); 333 + 348 334 down(&usb_bus_list_lock); 349 335 list_for_each_entry (ubus, &usb_bus_list, bus_list) { 350 336 mon_bus_init(mondir, ubus); ··· 360 342 struct mon_bus *mbus; 361 343 struct list_head *p; 362 344 345 + usb_unregister_notify(&mon_nb); 363 346 usb_mon_deregister(); 364 347 365 348 down(&mon_lock);