usb_mon.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_events;
  25. unsigned int cnt_text_lost;
  26. };
  27. /*
  28. * An instance of a process which opened a file (but can fork later)
  29. */
  30. struct mon_reader {
  31. struct list_head r_link;
  32. struct mon_bus *m_bus;
  33. void *r_data; /* Use container_of instead? */
  34. void (*rnf_submit)(void *data, struct urb *urb);
  35. void (*rnf_error)(void *data, struct urb *urb, int error);
  36. void (*rnf_complete)(void *data, struct urb *urb);
  37. };
  38. void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
  39. void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
  40. /*
  41. */
  42. extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
  43. extern struct mutex mon_lock;
  44. extern struct file_operations mon_fops_text;
  45. extern struct file_operations mon_fops_stat;
  46. #endif /* __USB_MON_H */