usb_mon.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * The USB Monitor, inspired by Dave Harding's USBMon.
  3. */
  4. #ifndef __USB_MON_H
  5. #define __USB_MON_H
  6. #include <linux/list.h>
  7. #include <linux/slab.h>
  8. #include <linux/kref.h>
  9. /* #include <linux/usb.h> */ /* We use struct pointers only in this header */
  10. #define TAG "usbmon"
  11. struct mon_bus {
  12. struct list_head bus_link;
  13. spinlock_t lock;
  14. struct dentry *dent_s; /* Debugging file */
  15. struct dentry *dent_t; /* Text interface file */
  16. struct usb_bus *u_bus;
  17. /* Ref */
  18. int nreaders; /* Under mon_lock AND mbus->lock */
  19. struct list_head r_list; /* Chain of readers (usually one) */
  20. struct kref ref; /* Under mon_lock */
  21. /* Stats */
  22. unsigned int cnt_text_lost;
  23. };
  24. /*
  25. * An instance of a process which opened a file (but can fork later)
  26. */
  27. struct mon_reader {
  28. struct list_head r_link;
  29. struct mon_bus *m_bus;
  30. void *r_data; /* Use container_of instead? */
  31. void (*rnf_submit)(void *data, struct urb *urb);
  32. void (*rnf_complete)(void *data, struct urb *urb);
  33. };
  34. void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
  35. void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
  36. extern struct semaphore mon_lock;
  37. extern struct file_operations mon_fops_text;
  38. extern struct file_operations mon_fops_stat;
  39. #endif /* __USB_MON_H */