Commit 14c688f0 authored by Miguel Jimenez Lopez's avatar Miguel Jimenez Lopez

sw/endpoint: Some fixes for kernels newer than 4.15.

parent 14d04c93
......@@ -163,10 +163,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);
......@@ -180,7 +187,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 (WR_IS_NODE) {
netif_carrier_on(dev);
......@@ -188,6 +197,10 @@ int wrn_ep_open(struct net_device *dev)
}
/* Prepare hardware registers: first config, then bring up */
writel(0
| EP_VCR0_QMODE_W(0x3) /* unqualified port */
| EP_VCR0_PRIO_VAL_W(4), /* some mid priority */
&ep->ep_regs->VCR0);
/*
* enable RX timestamping (it has no impact on performance)
......@@ -207,10 +220,18 @@ 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);
/* Not on spec. On spec this part of the function is never reached
* due to return in if(WR_IS_NODE) */
mod_timer(&ep->ep_link_timer, jiffies + WRN_LINK_POLL_INTERVAL);
#else
timer_setup(&ep->ep_link_timer, wrn_ep_check_link, 0);
#endif
if (WR_IS_SWITCH) {
/* not on spec */
mod_timer(&ep->ep_link_timer, jiffies + WRN_LINK_POLL_INTERVAL);
} else {
/* Assume it's already on */
netif_carrier_on(dev);
}
return 0;
}
......
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