diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2018-10-08 03:02:29 -0400 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2019-09-04 07:29:14 -0400 |
commit | 448c7074947845718f8a6f5b8fe6a5f0c31a0889 (patch) | |
tree | e75eb97c53065a1850d29efd698a7b5ff7abc196 /net/can/proc.c | |
parent | e2c1f5c75008ae767f0b50c212abed60708c7332 (diff) |
can: proc: give variables holding CAN statistics a sensible name
This patch rename the variables holding the CAN statistics (can_stats
and can_pstats) to pkg_stats and rcv_lists_stats which reflect better
their meaning.
The conversion is done with:
sed -i \
-e "s/can_stats\([^_]\)/pkg_stats\1/g" \
-e "s/can_pstats/rcv_lists_stats/g" \
net/can/proc.c
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'net/can/proc.c')
-rw-r--r-- | net/can/proc.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/net/can/proc.c b/net/can/proc.c index 30d8da4cef5d..8390243f34c6 100644 --- a/net/can/proc.c +++ b/net/can/proc.c | |||
@@ -78,21 +78,21 @@ static const char rx_list_name[][8] = { | |||
78 | 78 | ||
79 | static void can_init_stats(struct net *net) | 79 | static void can_init_stats(struct net *net) |
80 | { | 80 | { |
81 | struct can_pkg_stats *can_stats = net->can.pkg_stats; | 81 | struct can_pkg_stats *pkg_stats = net->can.pkg_stats; |
82 | struct can_rcv_lists_stats *can_pstats = net->can.rcv_lists_stats; | 82 | struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; |
83 | /* | 83 | /* |
84 | * This memset function is called from a timer context (when | 84 | * This memset function is called from a timer context (when |
85 | * can_stattimer is active which is the default) OR in a process | 85 | * can_stattimer is active which is the default) OR in a process |
86 | * context (reading the proc_fs when can_stattimer is disabled). | 86 | * context (reading the proc_fs when can_stattimer is disabled). |
87 | */ | 87 | */ |
88 | memset(can_stats, 0, sizeof(struct can_pkg_stats)); | 88 | memset(pkg_stats, 0, sizeof(struct can_pkg_stats)); |
89 | can_stats->jiffies_init = jiffies; | 89 | pkg_stats->jiffies_init = jiffies; |
90 | 90 | ||
91 | can_pstats->stats_reset++; | 91 | rcv_lists_stats->stats_reset++; |
92 | 92 | ||
93 | if (user_reset) { | 93 | if (user_reset) { |
94 | user_reset = 0; | 94 | user_reset = 0; |
95 | can_pstats->user_reset++; | 95 | rcv_lists_stats->user_reset++; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
@@ -119,7 +119,7 @@ static unsigned long calc_rate(unsigned long oldjif, unsigned long newjif, | |||
119 | void can_stat_update(struct timer_list *t) | 119 | void can_stat_update(struct timer_list *t) |
120 | { | 120 | { |
121 | struct net *net = from_timer(net, t, can.can_stattimer); | 121 | struct net *net = from_timer(net, t, can.can_stattimer); |
122 | struct can_pkg_stats *can_stats = net->can.pkg_stats; | 122 | struct can_pkg_stats *pkg_stats = net->can.pkg_stats; |
123 | unsigned long j = jiffies; /* snapshot */ | 123 | unsigned long j = jiffies; /* snapshot */ |
124 | 124 | ||
125 | /* restart counting in timer context on user request */ | 125 | /* restart counting in timer context on user request */ |
@@ -127,54 +127,54 @@ void can_stat_update(struct timer_list *t) | |||
127 | can_init_stats(net); | 127 | can_init_stats(net); |
128 | 128 | ||
129 | /* restart counting on jiffies overflow */ | 129 | /* restart counting on jiffies overflow */ |
130 | if (j < can_stats->jiffies_init) | 130 | if (j < pkg_stats->jiffies_init) |
131 | can_init_stats(net); | 131 | can_init_stats(net); |
132 | 132 | ||
133 | /* prevent overflow in calc_rate() */ | 133 | /* prevent overflow in calc_rate() */ |
134 | if (can_stats->rx_frames > (ULONG_MAX / HZ)) | 134 | if (pkg_stats->rx_frames > (ULONG_MAX / HZ)) |
135 | can_init_stats(net); | 135 | can_init_stats(net); |
136 | 136 | ||
137 | /* prevent overflow in calc_rate() */ | 137 | /* prevent overflow in calc_rate() */ |
138 | if (can_stats->tx_frames > (ULONG_MAX / HZ)) | 138 | if (pkg_stats->tx_frames > (ULONG_MAX / HZ)) |
139 | can_init_stats(net); | 139 | can_init_stats(net); |
140 | 140 | ||
141 | /* matches overflow - very improbable */ | 141 | /* matches overflow - very improbable */ |
142 | if (can_stats->matches > (ULONG_MAX / 100)) | 142 | if (pkg_stats->matches > (ULONG_MAX / 100)) |
143 | can_init_stats(net); | 143 | can_init_stats(net); |
144 | 144 | ||
145 | /* calc total values */ | 145 | /* calc total values */ |
146 | if (can_stats->rx_frames) | 146 | if (pkg_stats->rx_frames) |
147 | can_stats->total_rx_match_ratio = (can_stats->matches * 100) / | 147 | pkg_stats->total_rx_match_ratio = (pkg_stats->matches * 100) / |
148 | can_stats->rx_frames; | 148 | pkg_stats->rx_frames; |
149 | 149 | ||
150 | can_stats->total_tx_rate = calc_rate(can_stats->jiffies_init, j, | 150 | pkg_stats->total_tx_rate = calc_rate(pkg_stats->jiffies_init, j, |
151 | can_stats->tx_frames); | 151 | pkg_stats->tx_frames); |
152 | can_stats->total_rx_rate = calc_rate(can_stats->jiffies_init, j, | 152 | pkg_stats->total_rx_rate = calc_rate(pkg_stats->jiffies_init, j, |
153 | can_stats->rx_frames); | 153 | pkg_stats->rx_frames); |
154 | 154 | ||
155 | /* calc current values */ | 155 | /* calc current values */ |
156 | if (can_stats->rx_frames_delta) | 156 | if (pkg_stats->rx_frames_delta) |
157 | can_stats->current_rx_match_ratio = | 157 | pkg_stats->current_rx_match_ratio = |
158 | (can_stats->matches_delta * 100) / | 158 | (pkg_stats->matches_delta * 100) / |
159 | can_stats->rx_frames_delta; | 159 | pkg_stats->rx_frames_delta; |
160 | 160 | ||
161 | can_stats->current_tx_rate = calc_rate(0, HZ, can_stats->tx_frames_delta); | 161 | pkg_stats->current_tx_rate = calc_rate(0, HZ, pkg_stats->tx_frames_delta); |
162 | can_stats->current_rx_rate = calc_rate(0, HZ, can_stats->rx_frames_delta); | 162 | pkg_stats->current_rx_rate = calc_rate(0, HZ, pkg_stats->rx_frames_delta); |
163 | 163 | ||
164 | /* check / update maximum values */ | 164 | /* check / update maximum values */ |
165 | if (can_stats->max_tx_rate < can_stats->current_tx_rate) | 165 | if (pkg_stats->max_tx_rate < pkg_stats->current_tx_rate) |
166 | can_stats->max_tx_rate = can_stats->current_tx_rate; | 166 | pkg_stats->max_tx_rate = pkg_stats->current_tx_rate; |
167 | 167 | ||
168 | if (can_stats->max_rx_rate < can_stats->current_rx_rate) | 168 | if (pkg_stats->max_rx_rate < pkg_stats->current_rx_rate) |
169 | can_stats->max_rx_rate = can_stats->current_rx_rate; | 169 | pkg_stats->max_rx_rate = pkg_stats->current_rx_rate; |
170 | 170 | ||
171 | if (can_stats->max_rx_match_ratio < can_stats->current_rx_match_ratio) | 171 | if (pkg_stats->max_rx_match_ratio < pkg_stats->current_rx_match_ratio) |
172 | can_stats->max_rx_match_ratio = can_stats->current_rx_match_ratio; | 172 | pkg_stats->max_rx_match_ratio = pkg_stats->current_rx_match_ratio; |
173 | 173 | ||
174 | /* clear values for 'current rate' calculation */ | 174 | /* clear values for 'current rate' calculation */ |
175 | can_stats->tx_frames_delta = 0; | 175 | pkg_stats->tx_frames_delta = 0; |
176 | can_stats->rx_frames_delta = 0; | 176 | pkg_stats->rx_frames_delta = 0; |
177 | can_stats->matches_delta = 0; | 177 | pkg_stats->matches_delta = 0; |
178 | 178 | ||
179 | /* restart timer (one second) */ | 179 | /* restart timer (one second) */ |
180 | mod_timer(&net->can.can_stattimer, round_jiffies(jiffies + HZ)); | 180 | mod_timer(&net->can.can_stattimer, round_jiffies(jiffies + HZ)); |
@@ -212,60 +212,60 @@ static void can_print_recv_banner(struct seq_file *m) | |||
212 | static int can_stats_proc_show(struct seq_file *m, void *v) | 212 | static int can_stats_proc_show(struct seq_file *m, void *v) |
213 | { | 213 | { |
214 | struct net *net = m->private; | 214 | struct net *net = m->private; |
215 | struct can_pkg_stats *can_stats = net->can.pkg_stats; | 215 | struct can_pkg_stats *pkg_stats = net->can.pkg_stats; |
216 | struct can_rcv_lists_stats *can_pstats = net->can.rcv_lists_stats; | 216 | struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; |
217 | 217 | ||
218 | seq_putc(m, '\n'); | 218 | seq_putc(m, '\n'); |
219 | seq_printf(m, " %8ld transmitted frames (TXF)\n", can_stats->tx_frames); | 219 | seq_printf(m, " %8ld transmitted frames (TXF)\n", pkg_stats->tx_frames); |
220 | seq_printf(m, " %8ld received frames (RXF)\n", can_stats->rx_frames); | 220 | seq_printf(m, " %8ld received frames (RXF)\n", pkg_stats->rx_frames); |
221 | seq_printf(m, " %8ld matched frames (RXMF)\n", can_stats->matches); | 221 | seq_printf(m, " %8ld matched frames (RXMF)\n", pkg_stats->matches); |
222 | 222 | ||
223 | seq_putc(m, '\n'); | 223 | seq_putc(m, '\n'); |
224 | 224 | ||
225 | if (net->can.can_stattimer.function == can_stat_update) { | 225 | if (net->can.can_stattimer.function == can_stat_update) { |
226 | seq_printf(m, " %8ld %% total match ratio (RXMR)\n", | 226 | seq_printf(m, " %8ld %% total match ratio (RXMR)\n", |
227 | can_stats->total_rx_match_ratio); | 227 | pkg_stats->total_rx_match_ratio); |
228 | 228 | ||
229 | seq_printf(m, " %8ld frames/s total tx rate (TXR)\n", | 229 | seq_printf(m, " %8ld frames/s total tx rate (TXR)\n", |
230 | can_stats->total_tx_rate); | 230 | pkg_stats->total_tx_rate); |
231 | seq_printf(m, " %8ld frames/s total rx rate (RXR)\n", | 231 | seq_printf(m, " %8ld frames/s total rx rate (RXR)\n", |
232 | can_stats->total_rx_rate); | 232 | pkg_stats->total_rx_rate); |
233 | 233 | ||
234 | seq_putc(m, '\n'); | 234 | seq_putc(m, '\n'); |
235 | 235 | ||
236 | seq_printf(m, " %8ld %% current match ratio (CRXMR)\n", | 236 | seq_printf(m, " %8ld %% current match ratio (CRXMR)\n", |
237 | can_stats->current_rx_match_ratio); | 237 | pkg_stats->current_rx_match_ratio); |
238 | 238 | ||
239 | seq_printf(m, " %8ld frames/s current tx rate (CTXR)\n", | 239 | seq_printf(m, " %8ld frames/s current tx rate (CTXR)\n", |
240 | can_stats->current_tx_rate); | 240 | pkg_stats->current_tx_rate); |
241 | seq_printf(m, " %8ld frames/s current rx rate (CRXR)\n", | 241 | seq_printf(m, " %8ld frames/s current rx rate (CRXR)\n", |
242 | can_stats->current_rx_rate); | 242 | pkg_stats->current_rx_rate); |
243 | 243 | ||
244 | seq_putc(m, '\n'); | 244 | seq_putc(m, '\n'); |
245 | 245 | ||
246 | seq_printf(m, " %8ld %% max match ratio (MRXMR)\n", | 246 | seq_printf(m, " %8ld %% max match ratio (MRXMR)\n", |
247 | can_stats->max_rx_match_ratio); | 247 | pkg_stats->max_rx_match_ratio); |
248 | 248 | ||
249 | seq_printf(m, " %8ld frames/s max tx rate (MTXR)\n", | 249 | seq_printf(m, " %8ld frames/s max tx rate (MTXR)\n", |
250 | can_stats->max_tx_rate); | 250 | pkg_stats->max_tx_rate); |
251 | seq_printf(m, " %8ld frames/s max rx rate (MRXR)\n", | 251 | seq_printf(m, " %8ld frames/s max rx rate (MRXR)\n", |
252 | can_stats->max_rx_rate); | 252 | pkg_stats->max_rx_rate); |
253 | 253 | ||
254 | seq_putc(m, '\n'); | 254 | seq_putc(m, '\n'); |
255 | } | 255 | } |
256 | 256 | ||
257 | seq_printf(m, " %8ld current receive list entries (CRCV)\n", | 257 | seq_printf(m, " %8ld current receive list entries (CRCV)\n", |
258 | can_pstats->rcv_entries); | 258 | rcv_lists_stats->rcv_entries); |
259 | seq_printf(m, " %8ld maximum receive list entries (MRCV)\n", | 259 | seq_printf(m, " %8ld maximum receive list entries (MRCV)\n", |
260 | can_pstats->rcv_entries_max); | 260 | rcv_lists_stats->rcv_entries_max); |
261 | 261 | ||
262 | if (can_pstats->stats_reset) | 262 | if (rcv_lists_stats->stats_reset) |
263 | seq_printf(m, "\n %8ld statistic resets (STR)\n", | 263 | seq_printf(m, "\n %8ld statistic resets (STR)\n", |
264 | can_pstats->stats_reset); | 264 | rcv_lists_stats->stats_reset); |
265 | 265 | ||
266 | if (can_pstats->user_reset) | 266 | if (rcv_lists_stats->user_reset) |
267 | seq_printf(m, " %8ld user statistic resets (USTR)\n", | 267 | seq_printf(m, " %8ld user statistic resets (USTR)\n", |
268 | can_pstats->user_reset); | 268 | rcv_lists_stats->user_reset); |
269 | 269 | ||
270 | seq_putc(m, '\n'); | 270 | seq_putc(m, '\n'); |
271 | return 0; | 271 | return 0; |
@@ -274,20 +274,20 @@ static int can_stats_proc_show(struct seq_file *m, void *v) | |||
274 | static int can_reset_stats_proc_show(struct seq_file *m, void *v) | 274 | static int can_reset_stats_proc_show(struct seq_file *m, void *v) |
275 | { | 275 | { |
276 | struct net *net = m->private; | 276 | struct net *net = m->private; |
277 | struct can_rcv_lists_stats *can_pstats = net->can.rcv_lists_stats; | 277 | struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats; |
278 | struct can_pkg_stats *can_stats = net->can.pkg_stats; | 278 | struct can_pkg_stats *pkg_stats = net->can.pkg_stats; |
279 | 279 | ||
280 | user_reset = 1; | 280 | user_reset = 1; |
281 | 281 | ||
282 | if (net->can.can_stattimer.function == can_stat_update) { | 282 | if (net->can.can_stattimer.function == can_stat_update) { |
283 | seq_printf(m, "Scheduled statistic reset #%ld.\n", | 283 | seq_printf(m, "Scheduled statistic reset #%ld.\n", |
284 | can_pstats->stats_reset + 1); | 284 | rcv_lists_stats->stats_reset + 1); |
285 | } else { | 285 | } else { |
286 | if (can_stats->jiffies_init != jiffies) | 286 | if (pkg_stats->jiffies_init != jiffies) |
287 | can_init_stats(net); | 287 | can_init_stats(net); |
288 | 288 | ||
289 | seq_printf(m, "Performed statistic reset #%ld.\n", | 289 | seq_printf(m, "Performed statistic reset #%ld.\n", |
290 | can_pstats->stats_reset); | 290 | rcv_lists_stats->stats_reset); |
291 | } | 291 | } |
292 | return 0; | 292 | return 0; |
293 | } | 293 | } |