Skip to content

Commit e3d3917

Browse files
hartkoppmarckleinebudde
authored andcommitted
can: proc: make array printing function indenpendent from sff frames
The can_rcvlist_sff_proc_show_one() function which prints the array of filters for the single SFF CAN identifiers is prepared to be used by a second caller. Therefore it is also renamed to properly describe its future functionality. Signed-off-by: Oliver Hartkopp <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 42193e3 commit e3d3917

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

net/can/af_can.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ struct receiver {
5959
char *ident;
6060
};
6161

62+
#define CAN_SFF_RCV_ARRAY_SZ (1 << CAN_SFF_ID_BITS)
63+
6264
enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_EFF, RX_MAX };
6365

6466
/* per device receive filters linked at dev->ml_priv */
6567
struct dev_rcv_lists {
6668
struct hlist_head rx[RX_MAX];
67-
struct hlist_head rx_sff[0x800];
69+
struct hlist_head rx_sff[CAN_SFF_RCV_ARRAY_SZ];
6870
int remove_on_zero_entries;
6971
int entries;
7072
};

net/can/proc.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,25 +389,26 @@ static const struct file_operations can_rcvlist_proc_fops = {
389389
.release = single_release,
390390
};
391391

392-
static inline void can_rcvlist_sff_proc_show_one(struct seq_file *m,
393-
struct net_device *dev,
394-
struct dev_rcv_lists *d)
392+
static inline void can_rcvlist_proc_show_array(struct seq_file *m,
393+
struct net_device *dev,
394+
struct hlist_head *rcv_array,
395+
unsigned int rcv_array_sz)
395396
{
396-
int i;
397+
unsigned int i;
397398
int all_empty = 1;
398399

399400
/* check whether at least one list is non-empty */
400-
for (i = 0; i < 0x800; i++)
401-
if (!hlist_empty(&d->rx_sff[i])) {
401+
for (i = 0; i < rcv_array_sz; i++)
402+
if (!hlist_empty(&rcv_array[i])) {
402403
all_empty = 0;
403404
break;
404405
}
405406

406407
if (!all_empty) {
407408
can_print_recv_banner(m);
408-
for (i = 0; i < 0x800; i++) {
409-
if (!hlist_empty(&d->rx_sff[i]))
410-
can_print_rcvlist(m, &d->rx_sff[i], dev);
409+
for (i = 0; i < rcv_array_sz; i++) {
410+
if (!hlist_empty(&rcv_array[i]))
411+
can_print_rcvlist(m, &rcv_array[i], dev);
411412
}
412413
} else
413414
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)
425426

426427
/* sff receive list for 'all' CAN devices (dev == NULL) */
427428
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));
429430

430431
/* sff receive list for registered CAN devices */
431432
for_each_netdev_rcu(&init_net, dev) {
432-
if (dev->type == ARPHRD_CAN && dev->ml_priv)
433-
can_rcvlist_sff_proc_show_one(m, dev, dev->ml_priv);
433+
if (dev->type == ARPHRD_CAN && 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+
}
434438
}
435439

436440
rcu_read_unlock();

0 commit comments

Comments
 (0)