Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3264609ybb; Sun, 22 Mar 2020 19:58:47 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv+RLCPKMSzvRPOFQQ9oshEnoSny94TNLQx0IugNYNyz5NCjsOHKVc5z0HFl8UD0zDvoFBl X-Received: by 2002:aca:a9d4:: with SMTP id s203mr16000681oie.106.1584932327760; Sun, 22 Mar 2020 19:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584932327; cv=none; d=google.com; s=arc-20160816; b=sSORayK+SpC8W8kV+2TQT15Cp2HzMw3Hk41ap3D/LzV1c/lQWqGQFREQbMDVNhREmS FjAd5N6sLdAY/NcjG/VcsLXQ8pKJd3yOA3YGQAwqPagZwzE8hsNphRLYPCvGbC0W2KR1 iFvaK7AL9MQgASDSxaJ/hXtxw0peG1QgJL0OaQLG+AVg6KL7DkplQFixnZlOLKlpowHo kWa7V6S6WwIfL5oMTT9KRHC/3wUgwD72Clmuw30W/M7uupfbA0xk+S4VBlDnIbAjsXnZ Vm3g1C8X4Qm6lfcpq+5/SKvE1wY5lJwrs9B5bSyW5t9QOCtnPhuB7PdSTGVgv7xjbEXz KfhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2RzrjnjlFsoE4gKq8dQtt+6wyLVwzt/6FPHXx4r1hZA=; b=rrL0jT4QIXCsm35RBrgDk5xy45O2IQUrWKSqQAHWNZ5D3e/cGGdShJ5HkKu/iIaWVl sjE71JwY9oWxok8/qRUoCQm7H1ZKEIqW1RU/24DhjRk3y6kgcyhQ0ApBm+xKqV7K/Hkv tQRy2ga1N3JMPu1Ak159haQ8VY5DASr0tdKRIeSjNxbGlF5w0fLP6O0cBQ2tXRu8qpx1 YVMFrtxoMB9C+QrfkoFurVpFv9C4U0MXbvqldIJvfGL4BI4dM8U3/q6xA1hSLcg2mjCv 8Oo4qfe1UHE4qXqb+xI6llOfj7lSivZmQ2rgWV0UQa2D35expGe/4iYy0fUwuT97CEMT C1hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nzeGKEcW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r19si6853378otg.54.2020.03.22.19.58.35; Sun, 22 Mar 2020 19:58:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nzeGKEcW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727332AbgCWC5u (ORCPT + 99 others); Sun, 22 Mar 2020 22:57:50 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42500 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726983AbgCWC5u (ORCPT ); Sun, 22 Mar 2020 22:57:50 -0400 Received: by mail-pg1-f196.google.com with SMTP id h8so6438194pgs.9; Sun, 22 Mar 2020 19:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2RzrjnjlFsoE4gKq8dQtt+6wyLVwzt/6FPHXx4r1hZA=; b=nzeGKEcWF80+UA+29o2nRKvtsVKO7NLrB2Fs8rln3kn/f9OuoDarpGeRXZhqQXWHYZ FlM0huwSRiS9tNjMmd9kFCdLKBD/85rZynKRWnVgzZdOrUI8Dc4bvvnz59BUuCyNZ5xA 5FX964y6HwMDCRKZyI+0oZ/iMo/iXuMiSiKNKdmfPxUlrG8YoVFq+yYtjN8Lo0xaewjG ElDJEH1fVcLTcL8+0qqZ755FZKVFHWlghv8FczyHHjX0DjVEtlwb85EGwD6t06vHXs+Y Rhup4Uu7yVmNBFkqyTxlX84/dSqHIUi3uIR9xRYHeOAa/mJmMqoMAPXeIVai6JkXXMys 2bWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2RzrjnjlFsoE4gKq8dQtt+6wyLVwzt/6FPHXx4r1hZA=; b=N0sLGz27LIbbdOwWOvDKsbzJiGAHc6uyLIlfEjRfzJXL8u8BLuVaEcPEzZDhQ0KRsv j4GoCgTKxKK+c9mdUtKFp56ZhmHYdyCDq/clRb+2uSNOmv1a8OWg1LpOrRsEZ6rEZm+R bjJRcQFeNXWHUwkabQZHh3c+7vf9EV+spiJ1GHHlIbAK7hp1MT5DdBKZMN8HJYje2I7B qoV9vHQzM4Zde1Wvg6ORbuR0GOJeEC3a1HBNspd85wEBo8qLI2CqH/cL09NZPGnFAe7e Yf6nUiLzBYCEOUH51iUvtrWJaS0MqgDauylyh+UkJmkhe7Z+DIkLxC8kVUIAAjC8EXBH ifSA== X-Gm-Message-State: ANhLgQ3BbFlag7VAenpWmdwWkxkB9WFMqX4O10i6EfYsMx5BjskzoLT7 3BWiZ6rfdW9QVekydImBnXI= X-Received: by 2002:aa7:94a5:: with SMTP id a5mr22524685pfl.67.1584932268481; Sun, 22 Mar 2020 19:57:48 -0700 (PDT) Received: from localhost (104.128.80.227.16clouds.com. [104.128.80.227]) by smtp.gmail.com with ESMTPSA id z17sm11762499pff.12.2020.03.22.19.57.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Mar 2020 19:57:48 -0700 (PDT) From: Dejin Zheng To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, mchehab+samsung@kernel.org, gregkh@linuxfoundation.org, broonie@kernel.org, tglx@linutronix.de, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH net-next v6 09/10] net: phy: smsc: use phy_read_poll_timeout() to simplify the code Date: Mon, 23 Mar 2020 10:56:32 +0800 Message-Id: <20200323025633.6069-10-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200323025633.6069-1-zhengdejin5@gmail.com> References: <20200323025633.6069-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org use phy_read_poll_timeout() to replace the poll codes for simplify lan87xx_read_status() function. it should be add msleep(10) before call phy_read_poll_timeout() to keep the code more similar, but it will report that warning, so modify it to msleep(20). ./scripts/checkpatch.pl v5-0009-net-phy-smsc-use-phy_read_poll_timeout-to-simplif.patch WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.rst #42: FILE: drivers/net/phy/smsc.c:126: + msleep(10); Suggested-by: Andrew Lunn Signed-off-by: Dejin Zheng --- v5 -> v6: - no changed. v4 -> v5: - add msleep before phy_read_poll_timeout() to keep the code more similar v3 -> v4: - add this patch by Andrew's suggestion. Thanks Andrew! drivers/net/phy/smsc.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c index b73298250793..f888523086ed 100644 --- a/drivers/net/phy/smsc.c +++ b/drivers/net/phy/smsc.c @@ -112,8 +112,6 @@ static int lan87xx_read_status(struct phy_device *phydev) int err = genphy_read_status(phydev); if (!phydev->link && priv->energy_enable) { - int i; - /* Disable EDPD to wake up PHY */ int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS); if (rc < 0) @@ -125,15 +123,12 @@ static int lan87xx_read_status(struct phy_device *phydev) return rc; /* Wait max 640 ms to detect energy */ - for (i = 0; i < 64; i++) { - /* Sleep to allow link test pulses to be sent */ - msleep(10); - rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS); - if (rc < 0) - return rc; - if (rc & MII_LAN83C185_ENERGYON) - break; - } + msleep(20); + phy_read_poll_timeout(phydev, MII_LAN83C185_CTRL_STATUS, rc, + rc & MII_LAN83C185_ENERGYON, 10000, + 620000); + if (rc < 0) + return rc; /* Re-enable EDPD */ rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS); -- 2.25.0