]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * The USB Monitor, inspired by Dave Harding's USBMon. | |
da5ca008 PZ |
4 | * |
5 | * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com) | |
1da177e4 LT |
6 | */ |
7 | ||
8 | #ifndef __USB_MON_H | |
9 | #define __USB_MON_H | |
10 | ||
11 | #include <linux/list.h> | |
12 | #include <linux/slab.h> | |
13 | #include <linux/kref.h> | |
14 | /* #include <linux/usb.h> */ /* We use struct pointers only in this header */ | |
15 | ||
16 | #define TAG "usbmon" | |
17 | ||
18 | struct mon_bus { | |
19 | struct list_head bus_link; | |
20 | spinlock_t lock; | |
6f23ee1f PZ |
21 | struct usb_bus *u_bus; |
22 | ||
23 | int text_inited; | |
ce7cd137 | 24 | int bin_inited; |
1da177e4 LT |
25 | struct dentry *dent_s; /* Debugging file */ |
26 | struct dentry *dent_t; /* Text interface file */ | |
f1c9e30b | 27 | struct dentry *dent_u; /* Second text interface file */ |
ce7cd137 | 28 | struct device *classdev; /* Device in usbmon class */ |
1da177e4 LT |
29 | |
30 | /* Ref */ | |
31 | int nreaders; /* Under mon_lock AND mbus->lock */ | |
32 | struct list_head r_list; /* Chain of readers (usually one) */ | |
33 | struct kref ref; /* Under mon_lock */ | |
34 | ||
35 | /* Stats */ | |
5b1c674d | 36 | unsigned int cnt_events; |
1da177e4 LT |
37 | unsigned int cnt_text_lost; |
38 | }; | |
39 | ||
40 | /* | |
41 | * An instance of a process which opened a file (but can fork later) | |
42 | */ | |
43 | struct mon_reader { | |
44 | struct list_head r_link; | |
45 | struct mon_bus *m_bus; | |
46 | void *r_data; /* Use container_of instead? */ | |
47 | ||
48 | void (*rnf_submit)(void *data, struct urb *urb); | |
12e72fea | 49 | void (*rnf_error)(void *data, struct urb *urb, int error); |
9347d51c | 50 | void (*rnf_complete)(void *data, struct urb *urb, int status); |
1da177e4 LT |
51 | }; |
52 | ||
53 | void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r); | |
54 | void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r); | |
55 | ||
6f23ee1f PZ |
56 | struct mon_bus *mon_bus_lookup(unsigned int num); |
57 | ||
ce7cd137 | 58 | int /*bool*/ mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus); |
6f23ee1f | 59 | void mon_text_del(struct mon_bus *mbus); |
ce7cd137 PZ |
60 | int /*bool*/ mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus); |
61 | void mon_bin_del(struct mon_bus *mbus); | |
6f23ee1f PZ |
62 | |
63 | int __init mon_text_init(void); | |
21641e3f | 64 | void mon_text_exit(void); |
6f23ee1f | 65 | int __init mon_bin_init(void); |
21641e3f | 66 | void mon_bin_exit(void); |
6f23ee1f | 67 | |
6f23ee1f PZ |
68 | /* |
69 | */ | |
4186ecf8 | 70 | extern struct mutex mon_lock; |
1da177e4 | 71 | |
066202dd | 72 | extern const struct file_operations mon_fops_stat; |
1da177e4 | 73 | |
ecb658d3 PZ |
74 | extern struct mon_bus mon_bus0; /* Only for redundant checks */ |
75 | ||
1da177e4 | 76 | #endif /* __USB_MON_H */ |