From patchwork Mon May 4 13:44:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Ferre X-Patchwork-Id: 219953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D77B2C3A5A9 for ; Mon, 4 May 2020 13:46:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2B1421582 for ; Mon, 4 May 2020 13:46:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="JB1nZxZc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgEDNqn (ORCPT ); Mon, 4 May 2020 09:46:43 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:36514 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728477AbgEDNql (ORCPT ); Mon, 4 May 2020 09:46:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1588600000; x=1620136000; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=whBsw4kM37oC48LZNraq7LicT0Inj42IPZNti4XR4P4=; b=JB1nZxZcop9oJQXQ1g0k7HfR2dI8BNz2X1SOnziKWgVitSjIFfyyFFlv odiEm+jVeowsqrYXN/hclCYEAvrOgL8WJtoUBZGGSz/3KbSMnDHpivJ+8 dXh+Mn+B0EBht/B7BZumIY9nKCSBKpy8JGzGUIEuxeeV3alFHZU8L3sIL TCR8tNY64m2SFCB7hA7XIB6Umhe72zQbwZAL41V8Jb3YPBeJE/YXKrSwB sfrzBQSzYomjxYzkMLIlOb0dKQ9hvWeecaglNCLqVB3gfXSkWiT6Rh3y6 0E37lTItHixP62OQOVMelJ4eHRHfbWtP9VdnNh3UIZxKR3DXhkaPHRRJs g==; IronPort-SDR: LumqkHTJSRFkcdQcszXWJ/1BI2OAqeYYMllFqaJw6msYulxLZmBwaO4kiyQxsaD1AF15W6l/0f hykMO6hI9hD1zb67vv4LAntP1+9lDW3TiJbqzYYWJgg2bTz6ac1pHOH4lHYG0JzSsAFtnY9/5o 8VMwEeF9UemY0FK9TBt57+XeWiiTjihQpkLlQmJ7o4NkxyoL3CVtzlLkHspxu4KfubjtTbDooI QlRxY0EhCcewXHbC2bncWYsHMR+ve5X43cl69c/T1UaAYxlz/AwQNApx32iLjyKD3eFA1k3E75 lu4= X-IronPort-AV: E=Sophos;i="5.73,352,1583218800"; d="scan'208";a="72332636" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 04 May 2020 06:46:39 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 4 May 2020 06:46:40 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Mon, 4 May 2020 06:46:36 -0700 From: To: , , "Claudiu Beznea" , CC: , "David S. Miller" , Alexandre Belloni , , , , , , "Nicolas Ferre" Subject: [PATCH v3 3/7] net: macb: fix macb_get/set_wol() when moving to phylink Date: Mon, 4 May 2020 15:44:18 +0200 Message-ID: <77a2227ac02b432f42ed454e1ad94e15863ae2ff.1588597759.git.nicolas.ferre@microchip.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nicolas Ferre Keep previous function goals and integrate phylink actions to them. phylink_ethtool_get_wol() is not enough to figure out if Ethernet driver supports Wake-on-Lan. Initialization of "supported" and "wolopts" members is done in phylink function, no need to keep them in calling function. phylink_ethtool_set_wol() return value is not enough to determine if WoL is enabled for the calling Ethernet driver. Call it first but don't rely on its return value as most of simple PHY drivers don't implement a set_wol() function. Fixes: 7897b071ac3b ("net: macb: convert to phylink") Cc: Claudiu Beznea Cc: Harini Katakam Cc: Antoine Tenart Reviewed-by: Florian Fainelli Signed-off-by: Nicolas Ferre --- drivers/net/ethernet/cadence/macb_main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 629660d9f17e..b17a33c60cd4 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2813,21 +2813,23 @@ static void macb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct macb *bp = netdev_priv(netdev); - wol->supported = 0; - wol->wolopts = 0; - - if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) + if (bp->wol & MACB_WOL_HAS_MAGIC_PACKET) { phylink_ethtool_get_wol(bp->phylink, wol); + wol->supported |= WAKE_MAGIC; + + if (bp->wol & MACB_WOL_ENABLED) + wol->wolopts |= WAKE_MAGIC; + } } static int macb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct macb *bp = netdev_priv(netdev); - int ret; - ret = phylink_ethtool_set_wol(bp->phylink, wol); - if (!ret) - return 0; + /* Pass the order to phylink layer. + * Don't test return value as set_wol() is often not supported. + */ + phylink_ethtool_set_wol(bp->phylink, wol); if (!(bp->wol & MACB_WOL_HAS_MAGIC_PACKET) || (wol->wolopts & ~WAKE_MAGIC))