usb_mon.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * The USB Monitor, inspired by Dave Harding's USBMon.
  3. *
  4. * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com)
  5. */
  6. #ifndef __USB_MON_H
  7. #define __USB_MON_H
  8. #include <linux/list.h>
  9. #include <linux/slab.h>
  10. #include <linux/kref.h>
  11. /* #include <linux/usb.h> */ /* We use struct pointers only in this header */
  12. #define TAG "usbmon"
  13. struct mon_bus {
  14. struct list_head bus_link;
  15. spinlock_t lock;
  16. struct usb_bus *u_bus;
  17. int text_inited;
  18. int bin_inited;
  19. struct dentry *dent_s; /* Debugging file */
  20. struct dentry *dent_t; /* Text interface file */
  21. struct dentry *dent_u; /* Second text interface file */
  22. struct device *classdev; /* Device in usbmon class */
  23. /* Ref */
  24. int nreaders; /* Under mon_lock AND mbus->lock */
  25. struct list_head r_list; /* Chain of readers (usually one) */
  26. struct kref ref; /* Under mon_lock */
  27. /* Stats */
  28. unsigned int cnt_events;
  29. unsigned int cnt_text_lost;
  30. };
  31. /*
  32. * An instance of a process which opened a file (but can fork later)
  33. */
  34. struct mon_reader {
  35. struct list_head r_link;
  36. struct mon_bus *m_bus;
  37. void *r_data; /* Use container_of instead? */
  38. void (*rnf_submit)(void *data, struct urb *urb);
  39. void (*rnf_error)(void *data, struct urb *urb, int error);
  40. void (*rnf_complete)(void *data, struct urb *urb, int status);
  41. };
  42. void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
  43. void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
  44. struct mon_bus *mon_bus_lookup(unsigned int num);
  45. int /*bool*/ mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus);
  46. void mon_text_del(struct mon_bus *mbus);
  47. int /*bool*/ mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus);
  48. void mon_bin_del(struct mon_bus *mbus);
  49. int __init mon_text_init(void);
  50. void mon_text_exit(void);
  51. int __init mon_bin_init(void);
  52. void mon_bin_exit(void);
  53. /*
  54. */
  55. extern struct mutex mon_lock;
  56. extern const struct file_operations mon_fops_stat;
  57. extern struct mon_bus mon_bus0; /* Only for redundant checks */
  58. #endif /* __USB_MON_H */