@@ -10,15 +10,9 @@ static struct dentry *ixgbe_dbg_root;
10
10
11
11
static char ixgbe_dbg_reg_ops_buf [256 ] = "" ;
12
12
13
- /**
14
- * ixgbe_dbg_reg_ops_read - read for reg_ops datum
15
- * @filp: the opened file
16
- * @buffer: where to write the data for the user to read
17
- * @count: the size of the user's buffer
18
- * @ppos: file position offset
19
- **/
20
- static ssize_t ixgbe_dbg_reg_ops_read (struct file * filp , char __user * buffer ,
21
- size_t count , loff_t * ppos )
13
+ static ssize_t ixgbe_dbg_common_ops_read (struct file * filp , char __user * buffer ,
14
+ size_t count , loff_t * ppos ,
15
+ char * dbg_buf )
22
16
{
23
17
struct ixgbe_adapter * adapter = filp -> private_data ;
24
18
char * buf ;
@@ -29,8 +23,7 @@ static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char __user *buffer,
29
23
return 0 ;
30
24
31
25
buf = kasprintf (GFP_KERNEL , "%s: %s\n" ,
32
- adapter -> netdev -> name ,
33
- ixgbe_dbg_reg_ops_buf );
26
+ adapter -> netdev -> name , dbg_buf );
34
27
if (!buf )
35
28
return - ENOMEM ;
36
29
@@ -45,6 +38,20 @@ static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char __user *buffer,
45
38
return len ;
46
39
}
47
40
41
+ /**
42
+ * ixgbe_dbg_reg_ops_read - read for reg_ops datum
43
+ * @filp: the opened file
44
+ * @buffer: where to write the data for the user to read
45
+ * @count: the size of the user's buffer
46
+ * @ppos: file position offset
47
+ **/
48
+ static ssize_t ixgbe_dbg_reg_ops_read (struct file * filp , char __user * buffer ,
49
+ size_t count , loff_t * ppos )
50
+ {
51
+ return ixgbe_dbg_common_ops_read (filp , buffer , count , ppos ,
52
+ ixgbe_dbg_reg_ops_buf );
53
+ }
54
+
48
55
/**
49
56
* ixgbe_dbg_reg_ops_write - write into reg_ops datum
50
57
* @filp: the opened file
@@ -121,33 +128,11 @@ static char ixgbe_dbg_netdev_ops_buf[256] = "";
121
128
* @count: the size of the user's buffer
122
129
* @ppos: file position offset
123
130
**/
124
- static ssize_t ixgbe_dbg_netdev_ops_read (struct file * filp ,
125
- char __user * buffer ,
131
+ static ssize_t ixgbe_dbg_netdev_ops_read (struct file * filp , char __user * buffer ,
126
132
size_t count , loff_t * ppos )
127
133
{
128
- struct ixgbe_adapter * adapter = filp -> private_data ;
129
- char * buf ;
130
- int len ;
131
-
132
- /* don't allow partial reads */
133
- if (* ppos != 0 )
134
- return 0 ;
135
-
136
- buf = kasprintf (GFP_KERNEL , "%s: %s\n" ,
137
- adapter -> netdev -> name ,
138
- ixgbe_dbg_netdev_ops_buf );
139
- if (!buf )
140
- return - ENOMEM ;
141
-
142
- if (count < strlen (buf )) {
143
- kfree (buf );
144
- return - ENOSPC ;
145
- }
146
-
147
- len = simple_read_from_buffer (buffer , count , ppos , buf , strlen (buf ));
148
-
149
- kfree (buf );
150
- return len ;
134
+ return ixgbe_dbg_common_ops_read (filp , buffer , count , ppos ,
135
+ ixgbe_dbg_netdev_ops_buf );
151
136
}
152
137
153
138
/**
0 commit comments