blob: 9b06784d2c481055368bdd92f171d68801886d3f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * The USB Monitor, inspired by Dave Harding's USBMon.
Pete Zaitcevda5ca002005-08-16 15:16:46 -07003 *
4 * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6
7#ifndef __USB_MON_H
8#define __USB_MON_H
9
10#include <linux/list.h>
11#include <linux/slab.h>
12#include <linux/kref.h>
13/* #include <linux/usb.h> */ /* We use struct pointers only in this header */
14
15#define TAG "usbmon"
16
17struct mon_bus {
18 struct list_head bus_link;
19 spinlock_t lock;
20 struct dentry *dent_s; /* Debugging file */
21 struct dentry *dent_t; /* Text interface file */
22 struct usb_bus *u_bus;
23
24 /* Ref */
25 int nreaders; /* Under mon_lock AND mbus->lock */
26 struct list_head r_list; /* Chain of readers (usually one) */
27 struct kref ref; /* Under mon_lock */
28
29 /* Stats */
30 unsigned int cnt_text_lost;
31};
32
33/*
34 * An instance of a process which opened a file (but can fork later)
35 */
36struct mon_reader {
37 struct list_head r_link;
38 struct mon_bus *m_bus;
39 void *r_data; /* Use container_of instead? */
40
41 void (*rnf_submit)(void *data, struct urb *urb);
42 void (*rnf_complete)(void *data, struct urb *urb);
43};
44
45void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
46void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
47
48extern struct semaphore mon_lock;
49
50extern struct file_operations mon_fops_text;
51extern struct file_operations mon_fops_stat;
52
53#endif /* __USB_MON_H */