Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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