usb_mon.h 1.4 KB

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