Skip to content

Commit

Permalink
can: only call can_stat_update with procfs
Browse files Browse the repository at this point in the history
The change to leave out procfs support in CAN when CONFIG_PROC_FS
is not set was incomplete and leads to a build error:

net/built-in.o: In function `can_init':
:(.init.text+0x9858): undefined reference to `can_stat_update'
ERROR: "can_stat_update" [net/can/can.ko] undefined!

This tries a better approach, encapsulating all of the calls
within IS_ENABLED(), so we also leave out the timer function
from the object file.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: a20fadf ("can: build proc support only if CONFIG_PROC_FS is activated")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Arnd Bergmann authored and Marc Kleine-Budde committed Jun 23, 2016
1 parent b95e592 commit 2781ff5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
22 changes: 12 additions & 10 deletions net/can/af_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,14 @@ static __init int can_init(void)
if (!rcv_cache)
return -ENOMEM;

if (stats_timer) {
if (IS_ENABLED(CONFIG_PROC_FS)) {
if (stats_timer) {
/* the statistics are updated every second (timer triggered) */
setup_timer(&can_stattimer, can_stat_update, 0);
mod_timer(&can_stattimer, round_jiffies(jiffies + HZ));
} else
can_stattimer.function = NULL;

can_init_proc();
setup_timer(&can_stattimer, can_stat_update, 0);
mod_timer(&can_stattimer, round_jiffies(jiffies + HZ));
}
can_init_proc();
}

/* protocol register */
sock_register(&can_family_ops);
Expand All @@ -933,10 +933,12 @@ static __exit void can_exit(void)
{
struct net_device *dev;

if (stats_timer)
del_timer_sync(&can_stattimer);
if (IS_ENABLED(CONFIG_PROC_FS)) {
if (stats_timer)
del_timer_sync(&can_stattimer);

can_remove_proc();
can_remove_proc();
}

/* protocol unregister */
dev_remove_pack(&canfd_packet);
Expand Down
11 changes: 0 additions & 11 deletions net/can/af_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,8 @@ struct s_pstats {
extern struct dev_rcv_lists can_rx_alldev_list;

/* function prototypes for the CAN networklayer procfs (proc.c) */
#ifdef CONFIG_PROC_FS
void can_init_proc(void);
void can_remove_proc(void);
#else
static inline void can_init_proc(void)
{
pr_info("can: Can't create /proc/net/can. CONFIG_PROC_FS missing!\n");
}

static inline void can_remove_proc(void)
{
}
#endif
void can_stat_update(unsigned long data);

/* structures and variables from af_can.c needed in proc.c for reading */
Expand Down

0 comments on commit 2781ff5

Please sign in to comment.