• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef __RTW_PROC_H__
16 #define __RTW_PROC_H__
17 
18 #include <linux/proc_fs.h>
19 #include <linux/seq_file.h>
20 
21 #define RTW_PROC_HDL_TYPE_SEQ	0
22 #define RTW_PROC_HDL_TYPE_SSEQ	1
23 #define RTW_PROC_HDL_TYPE_SZSEQ	2
24 
25 struct rtw_proc_hdl {
26 	char *name;
27 	u8 type;
28 	union {
29 		int (*show)(struct seq_file *, void *);
30 		struct seq_operations *seq_op;
31 		struct {
32 			int (*show)(struct seq_file *, void *);
33 			size_t size;
34 		} sz;
35 	} u;
36 	ssize_t (*write)(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data);
37 };
38 
39 #define RTW_PROC_HDL_SEQ(_name, _seq_op, _write) \
40 	{ .name = _name, .type = RTW_PROC_HDL_TYPE_SEQ, .u.seq_op = _seq_op, .write = _write}
41 
42 #define RTW_PROC_HDL_SSEQ(_name, _show, _write) \
43 	{ .name = _name, .type = RTW_PROC_HDL_TYPE_SSEQ, .u.show = _show, .write = _write}
44 
45 #define RTW_PROC_HDL_SZSEQ(_name, _show, _write, _size) \
46 	{ .name = _name, .type = RTW_PROC_HDL_TYPE_SZSEQ, .u.sz.show = _show, .write = _write, .u.sz.size = _size}
47 
48 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
49 #define rtw_proc_ops proc_ops
50 #else
51 #define rtw_proc_ops file_operations
52 #endif
53 
54 #ifdef CONFIG_PROC_DEBUG
55 
56 int rtw_drv_proc_init(void);
57 void rtw_drv_proc_deinit(void);
58 struct proc_dir_entry *rtw_adapter_proc_init(struct net_device *dev);
59 void rtw_adapter_proc_deinit(struct net_device *dev);
60 void rtw_adapter_proc_replace(struct net_device *dev);
61 
62 #else /* !CONFIG_PROC_DEBUG */
63 
rtw_drv_proc_init(void)64 static inline int rtw_drv_proc_init(void) {return _FAIL;}
65 #define rtw_drv_proc_deinit() do {} while (0)
rtw_adapter_proc_init(struct net_device * dev)66 static inline struct proc_dir_entry *rtw_adapter_proc_init(struct net_device *dev) {return NULL;}
67 #define rtw_adapter_proc_deinit(dev) do {} while (0)
68 #define rtw_adapter_proc_replace(dev) do {} while (0)
69 
70 #endif /* !CONFIG_PROC_DEBUG */
71 
72 #endif /* __RTW_PROC_H__ */
73