Skip to content

Commit c2701b3

Browse files
hartkoppmarckleinebudde
authored andcommitted
can: fix CAN BCM build with CONFIG_PROC_FS disabled
The introduced namespace support moved the BCM variables for procfs into a per-net data structure. This leads to a build failure with disabled procfs: on x86_64: when CONFIG_PROC_FS is not enabled: ../net/can/bcm.c:1541:14: error: 'struct netns_can' has no member named 'bcmproc_dir' ../net/can/bcm.c:1601:14: error: 'struct netns_can' has no member named 'bcmproc_dir' ../net/can/bcm.c:1696:11: error: 'struct netns_can' has no member named 'bcmproc_dir' ../net/can/bcm.c:1707:15: error: 'struct netns_can' has no member named 'bcmproc_dir' http://marc.info/?l=linux-can&m=149321842526524&w=2 Reported-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent b1513c3 commit c2701b3

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

net/can/bcm.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ static inline ktime_t bcm_timeval_to_ktime(struct bcm_timeval tv)
147147
/*
148148
* procfs functions
149149
*/
150+
#if IS_ENABLED(CONFIG_PROC_FS)
150151
static char *bcm_proc_getifname(struct net *net, char *result, int ifindex)
151152
{
152153
struct net_device *dev;
@@ -251,6 +252,7 @@ static const struct file_operations bcm_proc_fops = {
251252
.llseek = seq_lseek,
252253
.release = single_release,
253254
};
255+
#endif /* CONFIG_PROC_FS */
254256

255257
/*
256258
* bcm_can_tx - send the (next) CAN frame to the appropriate CAN interface
@@ -1537,9 +1539,11 @@ static int bcm_release(struct socket *sock)
15371539
bcm_remove_op(op);
15381540
}
15391541

1542+
#if IS_ENABLED(CONFIG_PROC_FS)
15401543
/* remove procfs entry */
15411544
if (net->can.bcmproc_dir && bo->bcm_proc_read)
15421545
remove_proc_entry(bo->procname, net->can.bcmproc_dir);
1546+
#endif /* CONFIG_PROC_FS */
15431547

15441548
/* remove device reference */
15451549
if (bo->bound) {
@@ -1598,6 +1602,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
15981602
bo->ifindex = 0;
15991603
}
16001604

1605+
#if IS_ENABLED(CONFIG_PROC_FS)
16011606
if (net->can.bcmproc_dir) {
16021607
/* unique socket address as filename */
16031608
sprintf(bo->procname, "%lu", sock_i_ino(sk));
@@ -1609,6 +1614,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
16091614
goto fail;
16101615
}
16111616
}
1617+
#endif /* CONFIG_PROC_FS */
16121618

16131619
bo->bound = 1;
16141620

@@ -1691,22 +1697,21 @@ static const struct can_proto bcm_can_proto = {
16911697

16921698
static int canbcm_pernet_init(struct net *net)
16931699
{
1700+
#if IS_ENABLED(CONFIG_PROC_FS)
16941701
/* create /proc/net/can-bcm directory */
1695-
if (IS_ENABLED(CONFIG_PROC_FS)) {
1696-
net->can.bcmproc_dir =
1697-
proc_net_mkdir(net, "can-bcm", net->proc_net);
1698-
}
1702+
net->can.bcmproc_dir = proc_net_mkdir(net, "can-bcm", net->proc_net);
1703+
#endif /* CONFIG_PROC_FS */
16991704

17001705
return 0;
17011706
}
17021707

17031708
static void canbcm_pernet_exit(struct net *net)
17041709
{
1710+
#if IS_ENABLED(CONFIG_PROC_FS)
17051711
/* remove /proc/net/can-bcm directory */
1706-
if (IS_ENABLED(CONFIG_PROC_FS)) {
1707-
if (net->can.bcmproc_dir)
1708-
remove_proc_entry("can-bcm", net->proc_net);
1709-
}
1712+
if (net->can.bcmproc_dir)
1713+
remove_proc_entry("can-bcm", net->proc_net);
1714+
#endif /* CONFIG_PROC_FS */
17101715
}
17111716

17121717
static struct pernet_operations canbcm_pernet_ops __read_mostly = {

0 commit comments

Comments
 (0)