diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/can/af_can.h | 4 | ||||
-rw-r--r-- | net/can/proc.c | 28 |
2 files changed, 19 insertions, 13 deletions
diff --git a/net/can/af_can.h b/net/can/af_can.h index 6de58b40535c..b4bdaa32d7a4 100644 --- a/net/can/af_can.h +++ b/net/can/af_can.h | |||
@@ -59,12 +59,14 @@ struct receiver { | |||
59 | char *ident; | 59 | char *ident; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | #define CAN_SFF_RCV_ARRAY_SZ (1 << CAN_SFF_ID_BITS) | ||
63 | |||
62 | enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_EFF, RX_MAX }; | 64 | enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_EFF, RX_MAX }; |
63 | 65 | ||
64 | /* per device receive filters linked at dev->ml_priv */ | 66 | /* per device receive filters linked at dev->ml_priv */ |
65 | struct dev_rcv_lists { | 67 | struct dev_rcv_lists { |
66 | struct hlist_head rx[RX_MAX]; | 68 | struct hlist_head rx[RX_MAX]; |
67 | struct hlist_head rx_sff[0x800]; | 69 | struct hlist_head rx_sff[CAN_SFF_RCV_ARRAY_SZ]; |
68 | int remove_on_zero_entries; | 70 | int remove_on_zero_entries; |
69 | int entries; | 71 | int entries; |
70 | }; | 72 | }; |
diff --git a/net/can/proc.c b/net/can/proc.c index b543470c8f8b..1621e5909ee6 100644 --- a/net/can/proc.c +++ b/net/can/proc.c | |||
@@ -389,25 +389,26 @@ static const struct file_operations can_rcvlist_proc_fops = { | |||
389 | .release = single_release, | 389 | .release = single_release, |
390 | }; | 390 | }; |
391 | 391 | ||
392 | static inline void can_rcvlist_sff_proc_show_one(struct seq_file *m, | 392 | static inline void can_rcvlist_proc_show_array(struct seq_file *m, |
393 | struct net_device *dev, | 393 | struct net_device *dev, |
394 | struct dev_rcv_lists *d) | 394 | struct hlist_head *rcv_array, |
395 | unsigned int rcv_array_sz) | ||
395 | { | 396 | { |
396 | int i; | 397 | unsigned int i; |
397 | int all_empty = 1; | 398 | int all_empty = 1; |
398 | 399 | ||
399 | /* check whether at least one list is non-empty */ | 400 | /* check whether at least one list is non-empty */ |
400 | for (i = 0; i < 0x800; i++) | 401 | for (i = 0; i < rcv_array_sz; i++) |
401 | if (!hlist_empty(&d->rx_sff[i])) { | 402 | if (!hlist_empty(&rcv_array[i])) { |
402 | all_empty = 0; | 403 | all_empty = 0; |
403 | break; | 404 | break; |
404 | } | 405 | } |
405 | 406 | ||
406 | if (!all_empty) { | 407 | if (!all_empty) { |
407 | can_print_recv_banner(m); | 408 | can_print_recv_banner(m); |
408 | for (i = 0; i < 0x800; i++) { | 409 | for (i = 0; i < rcv_array_sz; i++) { |
409 | if (!hlist_empty(&d->rx_sff[i])) | 410 | if (!hlist_empty(&rcv_array[i])) |
410 | can_print_rcvlist(m, &d->rx_sff[i], dev); | 411 | can_print_rcvlist(m, &rcv_array[i], dev); |
411 | } | 412 | } |
412 | } else | 413 | } else |
413 | seq_printf(m, " (%s: no entry)\n", DNAME(dev)); | 414 | seq_printf(m, " (%s: no entry)\n", DNAME(dev)); |
@@ -425,12 +426,15 @@ static int can_rcvlist_sff_proc_show(struct seq_file *m, void *v) | |||
425 | 426 | ||
426 | /* sff receive list for 'all' CAN devices (dev == NULL) */ | 427 | /* sff receive list for 'all' CAN devices (dev == NULL) */ |
427 | d = &can_rx_alldev_list; | 428 | d = &can_rx_alldev_list; |
428 | can_rcvlist_sff_proc_show_one(m, NULL, d); | 429 | can_rcvlist_proc_show_array(m, NULL, d->rx_sff, ARRAY_SIZE(d->rx_sff)); |
429 | 430 | ||
430 | /* sff receive list for registered CAN devices */ | 431 | /* sff receive list for registered CAN devices */ |
431 | for_each_netdev_rcu(&init_net, dev) { | 432 | for_each_netdev_rcu(&init_net, dev) { |
432 | if (dev->type == ARPHRD_CAN && dev->ml_priv) | 433 | if (dev->type == ARPHRD_CAN && dev->ml_priv) { |
433 | can_rcvlist_sff_proc_show_one(m, dev, dev->ml_priv); | 434 | d = dev->ml_priv; |
435 | can_rcvlist_proc_show_array(m, dev, d->rx_sff, | ||
436 | ARRAY_SIZE(d->rx_sff)); | ||
437 | } | ||
434 | } | 438 | } |
435 | 439 | ||
436 | rcu_read_unlock(); | 440 | rcu_read_unlock(); |