Commit c2701b37 authored by Oliver Hartkopp's avatar Oliver Hartkopp Committed by Marc Kleine-Budde

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=2Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent b1513c35
...@@ -147,6 +147,7 @@ static inline ktime_t bcm_timeval_to_ktime(struct bcm_timeval tv) ...@@ -147,6 +147,7 @@ static inline ktime_t bcm_timeval_to_ktime(struct bcm_timeval tv)
/* /*
* procfs functions * procfs functions
*/ */
#if IS_ENABLED(CONFIG_PROC_FS)
static char *bcm_proc_getifname(struct net *net, char *result, int ifindex) static char *bcm_proc_getifname(struct net *net, char *result, int ifindex)
{ {
struct net_device *dev; struct net_device *dev;
...@@ -251,6 +252,7 @@ static const struct file_operations bcm_proc_fops = { ...@@ -251,6 +252,7 @@ static const struct file_operations bcm_proc_fops = {
.llseek = seq_lseek, .llseek = seq_lseek,
.release = single_release, .release = single_release,
}; };
#endif /* CONFIG_PROC_FS */
/* /*
* bcm_can_tx - send the (next) CAN frame to the appropriate CAN interface * bcm_can_tx - send the (next) CAN frame to the appropriate CAN interface
...@@ -1537,9 +1539,11 @@ static int bcm_release(struct socket *sock) ...@@ -1537,9 +1539,11 @@ static int bcm_release(struct socket *sock)
bcm_remove_op(op); bcm_remove_op(op);
} }
#if IS_ENABLED(CONFIG_PROC_FS)
/* remove procfs entry */ /* remove procfs entry */
if (net->can.bcmproc_dir && bo->bcm_proc_read) if (net->can.bcmproc_dir && bo->bcm_proc_read)
remove_proc_entry(bo->procname, net->can.bcmproc_dir); remove_proc_entry(bo->procname, net->can.bcmproc_dir);
#endif /* CONFIG_PROC_FS */
/* remove device reference */ /* remove device reference */
if (bo->bound) { if (bo->bound) {
...@@ -1598,6 +1602,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len, ...@@ -1598,6 +1602,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
bo->ifindex = 0; bo->ifindex = 0;
} }
#if IS_ENABLED(CONFIG_PROC_FS)
if (net->can.bcmproc_dir) { if (net->can.bcmproc_dir) {
/* unique socket address as filename */ /* unique socket address as filename */
sprintf(bo->procname, "%lu", sock_i_ino(sk)); sprintf(bo->procname, "%lu", sock_i_ino(sk));
...@@ -1609,6 +1614,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len, ...@@ -1609,6 +1614,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
goto fail; goto fail;
} }
} }
#endif /* CONFIG_PROC_FS */
bo->bound = 1; bo->bound = 1;
...@@ -1691,22 +1697,21 @@ static const struct can_proto bcm_can_proto = { ...@@ -1691,22 +1697,21 @@ static const struct can_proto bcm_can_proto = {
static int canbcm_pernet_init(struct net *net) static int canbcm_pernet_init(struct net *net)
{ {
#if IS_ENABLED(CONFIG_PROC_FS)
/* create /proc/net/can-bcm directory */ /* create /proc/net/can-bcm directory */
if (IS_ENABLED(CONFIG_PROC_FS)) { net->can.bcmproc_dir = proc_net_mkdir(net, "can-bcm", net->proc_net);
net->can.bcmproc_dir = #endif /* CONFIG_PROC_FS */
proc_net_mkdir(net, "can-bcm", net->proc_net);
}
return 0; return 0;
} }
static void canbcm_pernet_exit(struct net *net) static void canbcm_pernet_exit(struct net *net)
{ {
#if IS_ENABLED(CONFIG_PROC_FS)
/* remove /proc/net/can-bcm directory */ /* remove /proc/net/can-bcm directory */
if (IS_ENABLED(CONFIG_PROC_FS)) { if (net->can.bcmproc_dir)
if (net->can.bcmproc_dir) remove_proc_entry("can-bcm", net->proc_net);
remove_proc_entry("can-bcm", net->proc_net); #endif /* CONFIG_PROC_FS */
}
} }
static struct pernet_operations canbcm_pernet_ops __read_mostly = { static struct pernet_operations canbcm_pernet_ops __read_mostly = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment