usb_mon.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 dentry *dent_s; /* Debugging file */
  17. struct dentry *dent_t; /* Text interface file */
  18. struct usb_bus *u_bus;
  19. int uses_dma;
  20. /* Ref */
  21. int nreaders; /* Under mon_lock AND mbus->lock */
  22. struct list_head r_list; /* Chain of readers (usually one) */
  23. struct kref ref; /* Under mon_lock */
  24. /* Stats */
  25. unsigned int cnt_events;
  26. unsigned int cnt_text_lost;
  27. };
  28. /*
  29. * An instance of a process which opened a file (but can fork later)
  30. */
  31. struct mon_reader {
  32. struct list_head r_link;
  33. struct mon_bus *m_bus;
  34. void *r_data; /* Use container_of instead? */
  35. void (*rnf_submit)(void *data, struct urb *urb);
  36. void (*rnf_error)(void *data, struct urb *urb, int error);
  37. void (*rnf_complete)(void *data, struct urb *urb);
  38. };
  39. void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
  40. void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
  41. /*
  42. */
  43. extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
  44. extern struct mutex mon_lock;
  45. extern const struct file_operations mon_fops_text;
  46. extern const struct file_operations mon_fops_stat;
  47. #endif /* __USB_MON_H */