From patchwork Tue Jan 14 14:02:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13938814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB8B3E77188 for ; Tue, 14 Jan 2025 14:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=weR9Z/CkPANR3PvdWqGOb/Y+LHB/KJHILnKwZHgGiFY=; b=oKJBcgBwCge468AOnpIyJCJgKi WEYrp6rS5E/bWl8U7xu/nUaabfzdgI47TkbML8f3OdDesiDOUz20tYvf9bDO9qpj7g1f/l81+jAch UDw4+RnwGj6JHY5vVesS1QcH5Wse2DZhwb29zgV3duRl79Vkez4O1JU4hmI5BSma9HWot4UFvFPuk yLeb7AzOgJ4Vps0d0MsJpZhrmiLZzCJDhFuYy8eSfrsk6d6AS0sEdWsavhIXqh3raMRrD1twVOSsh 00ii9arXPhzzHAnYDFSUala6Q0IcVrzU2V7pAgob+yK+fdhBfUx0M33staJj1+7hKFOvCUKHICnqm N0JFKZ0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tXhYf-00000008bNj-1mfA; Tue, 14 Jan 2025 14:06:17 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tXhV8-00000008aZt-1bse for linux-arm-kernel@lists.infradead.org; Tue, 14 Jan 2025 14:02:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=weR9Z/CkPANR3PvdWqGOb/Y+LHB/KJHILnKwZHgGiFY=; b=o+QpDAP0WotUoCL8yFI3LC8G3h jkS3MNa5T4t2kW/SOVBqW0gLol0D7RdET1C9AIo/nB8TFr36CAKZATGINKL91e1kRYHm7Ib/dj/n3 CEGIfQWBSupPmCCfKeqPXT7RlBGjehGhDAsJ8+3JnokrOTEOrabMkXf8s0pmuQmoX9/LuLttUD+jE CuOAluaO9oo9rC4owCdT3zcUivSjc5fHQz+xSzh4AH0nPU2Aph4F9440uqAVPW/XtoZMpKFOcwzUY HPVkedwp+DL3Gt/2JmTGkvCAI70xxPQHLIUPgI7bzJ/3770WQ3Kb6/PVjmuEkWYmnmzHupD5vDh9Q +5Op+uQA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:52318 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tXhV3-00089E-0w; Tue, 14 Jan 2025 14:02:33 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1tXhUk-000n0S-6y; Tue, 14 Jan 2025 14:02:14 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , Andrew Lunn , Bryan Whitehead , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Marcin Wojtas , Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Simon Horman , UNGLinuxDriver@microchip.com, Vladimir Oltean Subject: [PATCH RFC net-next 03/10] net: phylink: add phylink_link_is_up() helper MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Tue, 14 Jan 2025 14:02:14 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250114_060238_419009_CFA1370F X-CRM114-Status: GOOD ( 10.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a helper to determine whether the link is up or down. Currently this is only used in one location, but becomes necessary to test when reconfiguring EEE. Reviewed-by: Andrew Lunn Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 31754d5fd659..e3fc1d1be1ed 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1641,20 +1641,21 @@ static void phylink_link_down(struct phylink *pl) phylink_info(pl, "Link is Down\n"); } +static bool phylink_link_is_up(struct phylink *pl) +{ + return pl->netdev ? netif_carrier_ok(pl->netdev) : pl->old_link_state; +} + static void phylink_resolve(struct work_struct *w) { struct phylink *pl = container_of(w, struct phylink, resolve); struct phylink_link_state link_state; - struct net_device *ndev = pl->netdev; bool mac_config = false; bool retrigger = false; bool cur_link_state; mutex_lock(&pl->state_mutex); - if (pl->netdev) - cur_link_state = netif_carrier_ok(ndev); - else - cur_link_state = pl->old_link_state; + cur_link_state = phylink_link_is_up(pl); if (pl->phylink_disable_state) { pl->link_failed = false;