Merge branch 'locks' of git://linux-nfs.org/~bfields/linux
[deliverable/linux.git] / drivers / usb / mon / usb_mon.h
CommitLineData
1da177e4
LT
1/*
2 * The USB Monitor, inspired by Dave Harding's USBMon.
da5ca008
PZ
3 *
4 * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com)
1da177e4
LT
5 */
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;
6f23ee1f
PZ
20 struct usb_bus *u_bus;
21
22 int text_inited;
ce7cd137 23 int bin_inited;
1da177e4
LT
24 struct dentry *dent_s; /* Debugging file */
25 struct dentry *dent_t; /* Text interface file */
f1c9e30b 26 struct dentry *dent_u; /* Second text interface file */
ce7cd137 27 struct device *classdev; /* Device in usbmon class */
1da177e4
LT
28
29 /* Ref */
30 int nreaders; /* Under mon_lock AND mbus->lock */
31 struct list_head r_list; /* Chain of readers (usually one) */
32 struct kref ref; /* Under mon_lock */
33
34 /* Stats */
5b1c674d 35 unsigned int cnt_events;
1da177e4
LT
36 unsigned int cnt_text_lost;
37};
38
39/*
40 * An instance of a process which opened a file (but can fork later)
41 */
42struct mon_reader {
43 struct list_head r_link;
44 struct mon_bus *m_bus;
45 void *r_data; /* Use container_of instead? */
46
47 void (*rnf_submit)(void *data, struct urb *urb);
12e72fea 48 void (*rnf_error)(void *data, struct urb *urb, int error);
9347d51c 49 void (*rnf_complete)(void *data, struct urb *urb, int status);
1da177e4
LT
50};
51
52void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
53void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
54
6f23ee1f
PZ
55struct mon_bus *mon_bus_lookup(unsigned int num);
56
ce7cd137 57int /*bool*/ mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus);
6f23ee1f 58void mon_text_del(struct mon_bus *mbus);
ce7cd137
PZ
59int /*bool*/ mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus);
60void mon_bin_del(struct mon_bus *mbus);
6f23ee1f
PZ
61
62int __init mon_text_init(void);
21641e3f 63void mon_text_exit(void);
6f23ee1f 64int __init mon_bin_init(void);
21641e3f 65void mon_bin_exit(void);
6f23ee1f 66
02568396 67/*
6f23ee1f
PZ
68 * DMA interface.
69 *
70 * XXX The vectored side needs a serious re-thinking. Abstracting vectors,
71 * like in Paolo's original patch, produces a double pkmap. We need an idea.
72*/
02568396
PZ
73extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
74
6f23ee1f
PZ
75struct mon_reader_bin;
76extern void mon_dmapeek_vec(const struct mon_reader_bin *rp,
77 unsigned int offset, dma_addr_t dma_addr, unsigned int len);
78extern unsigned int mon_copy_to_buff(const struct mon_reader_bin *rp,
79 unsigned int offset, const unsigned char *from, unsigned int len);
80
81/*
82 */
4186ecf8 83extern struct mutex mon_lock;
1da177e4 84
066202dd 85extern const struct file_operations mon_fops_stat;
1da177e4 86
ecb658d3
PZ
87extern struct mon_bus mon_bus0; /* Only for redundant checks */
88
1da177e4 89#endif /* __USB_MON_H */
This page took 0.278641 seconds and 5 git commands to generate.