From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Subject: [PATCH net-next 4/4] net: systemport: Create helper to set MPD Date: Fri, 3 Aug 2018 11:08:44 -0700 Message-ID: <20180803180844.1010-5-f.fainelli@gmail.com> References: <20180803180844.1010-1-f.fainelli@gmail.com> Cc: Florian Fainelli , andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, davem@davemloft.net To: netdev@vger.kernel.org Return-path: Received: from mail-pl0-f67.google.com ([209.85.160.67]:41605 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727356AbeHCUHs (ORCPT ); Fri, 3 Aug 2018 16:07:48 -0400 Received: by mail-pl0-f67.google.com with SMTP id w19-v6so1239661ply.8 for ; Fri, 03 Aug 2018 11:10:25 -0700 (PDT) In-Reply-To: <20180803180844.1010-1-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: Create a helper function to turn on/off MPD, this will be used to avoid duplicating code as we are going to add additional types of wake-up types. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/bcmsysport.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index 7faad9e1a6f9..284581c9680e 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -1041,17 +1041,25 @@ static int bcm_sysport_poll(struct napi_struct *napi, int budget) return work_done; } -static void bcm_sysport_resume_from_wol(struct bcm_sysport_priv *priv) +static void mpd_enable_set(struct bcm_sysport_priv *priv, bool enable) { u32 reg; + reg = umac_readl(priv, UMAC_MPD_CTRL); + if (enable) + reg |= MPD_EN; + else + reg &= ~MPD_EN; + umac_writel(priv, reg, UMAC_MPD_CTRL); +} + +static void bcm_sysport_resume_from_wol(struct bcm_sysport_priv *priv) +{ /* Stop monitoring MPD interrupt */ intrl2_0_mask_set(priv, INTRL2_0_MPD); /* Clear the MagicPacket detection logic */ - reg = umac_readl(priv, UMAC_MPD_CTRL); - reg &= ~MPD_EN; - umac_writel(priv, reg, UMAC_MPD_CTRL); + mpd_enable_set(priv, false); netif_dbg(priv, wol, priv->netdev, "resumed from WOL\n"); } @@ -2447,9 +2455,7 @@ static int bcm_sysport_suspend_to_wol(struct bcm_sysport_priv *priv) /* Do not leave the UniMAC RBUF matching only MPD packets */ if (!timeout) { - reg = umac_readl(priv, UMAC_MPD_CTRL); - reg &= ~MPD_EN; - umac_writel(priv, reg, UMAC_MPD_CTRL); + mpd_enable_set(priv, false); netif_err(priv, wol, ndev, "failed to enter WOL mode\n"); return -ETIMEDOUT; } -- 2.14.1