Return-Path: Received: from mail-wm0-f67.google.com ([74.125.82.67]:36135 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750991AbeCPVZo (ORCPT ); Fri, 16 Mar 2018 17:25:44 -0400 Received: by mail-wm0-f67.google.com with SMTP id n3so5498003wmd.1 for ; Fri, 16 Mar 2018 14:25:44 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH RFC v2 1/7] net: phy: unconditionally resume and re-enable interrupts, in phy_start To: Florian Fainelli , Andrew Lunn , Geert Uytterhoeven Cc: "netdev@vger.kernel.org" References: <6618f53c-778a-cb12-deb4-c618a728b43e@gmail.com> Message-ID: Date: Fri, 16 Mar 2018 22:14:52 +0100 MIME-Version: 1.0 In-Reply-To: <6618f53c-778a-cb12-deb4-c618a728b43e@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: In subsequent patches of this series interrupts will be disabled during system suspend, also we will have to resume the PHY in states other than PHY_HALTED. To prepare for this unconditionally resume and re-enable interrupts in phy_start(). Signed-off-by: Heiner Kallweit --- v2: - no changes --- drivers/net/phy/phy.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 05c1e8ef..0aef35ef 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -791,10 +791,16 @@ EXPORT_SYMBOL(phy_stop); */ void phy_start(struct phy_device *phydev) { - int err = 0; + /* if phy was suspended, bring the physical link up again */ + phy_resume(phydev); - mutex_lock(&phydev->lock); + /* make sure interrupts are re-enabled for the PHY */ + if (phy_interrupt_is_valid(phydev) && phy_enable_interrupts(phydev)) { + phy_error(phydev); + return; + } + mutex_lock(&phydev->lock); switch (phydev->state) { case PHY_STARTING: phydev->state = PHY_PENDING; @@ -803,16 +809,6 @@ void phy_start(struct phy_device *phydev) phydev->state = PHY_UP; break; case PHY_HALTED: - /* if phy was suspended, bring the physical link up again */ - __phy_resume(phydev); - - /* make sure interrupts are re-enabled for the PHY */ - if (phy_interrupt_is_valid(phydev)) { - err = phy_enable_interrupts(phydev); - if (err < 0) - break; - } - phydev->state = PHY_RESUMING; break; default: -- 2.16.2