Commit aa8d5d99 authored by Gwenhael Goavec-Merou's avatar Gwenhael Goavec-Merou Committed by Juan David González Cobas

kernel: wr_nic: endpoint: use timer_setup instead of setup_timer with kernel > 4.15

Since kernel 4.15, setup_timer is no more available and compilation fails with :
make -C kernel
make[1]: Entering directory '/.../wr-starting-kit/spec-sw/kernel'
make -C /lib/modules/4.18.0-1-amd64/build M=/.../wr-starting-kit/spec-sw/kernel FMC_BUS_ABS=/.../wr-starting-kit/spec-sw/fmc-bus modules
make[2]: Entering directory '/usr/src/linux-headers-4.18.0-1-amd64'
  CC [M]  /.../wr-starting-kit/spec-sw/kernel/wr_nic/endpoint.o
/.../wr-starting-kit/spec-sw/kernel/wr_nic/endpoint.c: In function 'wrn_ep_open':
/.../wr-starting-kit/spec-sw/kernel/wr_nic/endpoint.c:193:2: error: implicit declaration of function 'setup_timer'; did you mean 'del_timer'? [-Werror=implicit-function-declaration]
  setup_timer(&ep->ep_link_timer, wrn_ep_check_link, timerarg);
  ^~~~~~~~~~~
  del_timer
cc1: some warnings being treated as errors
make[5]: *** [/usr/src/linux-headers-4.18.0-1-common/scripts/Makefile.build:323: /.../wr-starting-kit/spec-sw/kernel/wr_nic/endpoint.o] Error 1
make[4]: *** [/usr/src/linux-headers-4.18.0-1-common/Makefile:1518: _module_/.../wr-starting-kit/spec-sw/kernel] Error 2
make[3]: *** [Makefile:146: sub-make] Error 2
make[2]: *** [Makefile:8: all] Error 2
make[2]: Leaving directory '/usr/src/linux-headers-4.18.0-1-amd64'
make[1]: *** [Makefile:20: all] Error 2
make[1]: Leaving directory '/.../wr-starting-kit/spec-sw/kernel'
make: *** [Makefile:28: kernel] Error 2

This patch add preprocessor case to detect kernel version.
For kernel > 4.15 timer_setup is use instead of setup_timer and callback is
adapted to the new need.
Signed-off-by: 's avatarGwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
parent 481b8821
......@@ -11,6 +11,7 @@
* published by the Free Software Foundation.
*/
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
......@@ -129,10 +130,17 @@ static void wrn_update_link_status(struct net_device *dev)
}
/* Actual timer function. Takes the lock and calls above function */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
static void wrn_ep_check_link(unsigned long dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct wrn_ep *ep = netdev_priv(dev);
#else
static void wrn_ep_check_link(struct timer_list *t)
{
struct wrn_ep *ep = from_timer(ep, t, ep_link_timer);
struct net_device *dev = ep->mii.dev;
#endif
unsigned long flags;
spin_lock_irqsave(&ep->lock, flags);
......@@ -146,7 +154,9 @@ static void wrn_ep_check_link(unsigned long dev_id)
int wrn_ep_open(struct net_device *dev)
{
struct wrn_ep *ep = netdev_priv(dev);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
unsigned long timerarg = (unsigned long)dev;
#endif
if (1) {
netif_carrier_on(dev);
......@@ -177,7 +187,11 @@ int wrn_ep_open(struct net_device *dev)
wrn_phy_write(dev, 0, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
/* Prepare the timer for link-up notifications */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
setup_timer(&ep->ep_link_timer, wrn_ep_check_link, timerarg);
#else
timer_setup(&ep->ep_link_timer, wrn_ep_check_link, 0);
#endif
if (0) {
/* not on spec */
mod_timer(&ep->ep_link_timer, jiffies + WRN_LINK_POLL_INTERVAL);
......
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