Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2344248ybb; Sat, 21 Mar 2020 19:51:52 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvLk4zGW54OYWoCYFL2uF0Avvy1OBavdi+sT5XUS5NglpqHmneZChM45KVB2lF1oDB2dJDz X-Received: by 2002:a9d:64ca:: with SMTP id n10mr13262216otl.325.1584845512761; Sat, 21 Mar 2020 19:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584845512; cv=none; d=google.com; s=arc-20160816; b=HodkBd/3l02xMmZhIfyd1GQbCv/ORqJUVPcvD5eYR8UUfpYXUhA0B7rgtg99dlkYEj UATpv8xXT4/YmbRBcqj4d9YUWL5mqT238sVO0JLNe8F8SF8lziQUxqZ32HLcgC/CiLST mkXSintHEfrHn/l/UA41X4aDSinXf8+k8G7qj5t5ombP//JHgyuX8vMhsUBqNrAFPQBP 5lasGNwkgrVZfwpjviuHbHZ6suUEy3RoIUNk1qXIuChmYL4bBjp6MoVEXh8Ugv4ZYoXG 8LbWj3ReXHiwv5WzLFsNTy2BHFzyR1JkyuEuvC2i1NR8EjCU6aTZsr0wsi9RRCdo7Exo +4eQ== 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=Us52jAlL+55uuDXphB68RLJ2IVOdVneyxLYuT22jhHI=; b=oYe5tpWkKJksj4RcHT+UZTf+IXcMk3AV1pCP6Zi7JuPTvqs4ojiPYHT/ctnYZGTGqI XsyCxpAVJJQztg6Bawb/ws8Ar83WUf6pjC0IsptGAhtg9ZkidkUcJgTMhTtD03xIwVis jJBKo4btTQm/nlRYRmWNfP54NMlblKqDpXFf2aRVQU76JSXfRySlhWfG2+wuBMglf1Fu 1v32Og8c46B8WBDrKUaVN5kDZG6YtrOOnhxS7+deJWvATtQEohTkkEjxCvsTJdnb4PA3 XufJhJOUp1y0+yxmUNCxLDkMabo+Opuu7ma/eYXNgY1/LbJhxZr5mQ4Heafkb6R3wO2G vnBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XGGjj6FL; 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 193si5266207oie.51.2020.03.21.19.51.41; Sat, 21 Mar 2020 19:51:52 -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=XGGjj6FL; 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 S1728487AbgCVCtx (ORCPT + 99 others); Sat, 21 Mar 2020 22:49:53 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:32892 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728474AbgCVCtu (ORCPT ); Sat, 21 Mar 2020 22:49:50 -0400 Received: by mail-pg1-f195.google.com with SMTP id d17so4683599pgo.0; Sat, 21 Mar 2020 19:49: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=Us52jAlL+55uuDXphB68RLJ2IVOdVneyxLYuT22jhHI=; b=XGGjj6FL+oA1WSqtGzwFK2Ee4MI+/xyDCgCdYJsfPXCRor8NB6BD2+aV9f0/1p9Y7L u2iDdBEUv0bllxYh8Hn4kv2NiO3R3LSq/ZPaEajxEkY3vksUDIeePlLuVXp4EsQPZPl3 gHKn6hy+dD7sVAMwdeKKpCq36OcCBwZVJO6BHEYy4XP5K/QEbJSYjSZldOMuq5pPSruq gVoEciYAliPE9zNaGNDBOupnXZKxpP7cCUDDzW8Jz/M+oZauZAU43EGIYMpMk2lP0TTk FdMsOgbKfJ8P83LhTErmbD2w/PNpktiXLy/3VEU0RxN4v04XWUCcRCFhSp0ViPs16Byk qZWw== 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=Us52jAlL+55uuDXphB68RLJ2IVOdVneyxLYuT22jhHI=; b=AULu17efb/wNU0KuV9Gksgw8nWzBZ2PPlCMoltWVjezeAUjVG4a0uMylMV4/sZ+FcD pVezTGkGU3Be+IP+xCgjskz+LCjwNOVpDPKsqIS/0sqRlrxg2I8xKmnYi3U72ckBmqXl 5ZhCZfxpMstZxqKdT2GNPt2GJHowiHOuB2pKsuQi/2RcDEV6ri6K7TjgmplTw1MUY7zQ gwupqmWMu+x3rpObMrndC2cKyjEt2gDfBGHlJcc3P5M5lWXY8kreeuJS7gD8EpSPnODj DG572AgRua6nyE4Z6394ckO33YEeZ1JX0s0tpIRxBha4kBRXfO8ANYCRbReh43jp6zDY Sfwg== X-Gm-Message-State: ANhLgQ1WJhNtqaRLYOvhB8HyjmlmmaTC95cBRZNV6aDh+cHn+4t2Jtmp i/bAzIcjwZXC90bB+rvPcbQlv5Hq X-Received: by 2002:a63:ba5d:: with SMTP id l29mr15530077pgu.67.1584845389316; Sat, 21 Mar 2020 19:49:49 -0700 (PDT) Received: from localhost ([216.24.188.11]) by smtp.gmail.com with ESMTPSA id u3sm9598372pfb.36.2020.03.21.19.49.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Mar 2020 19:49:48 -0700 (PDT) From: Dejin Zheng To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, allison@lohutok.net, tglx@linutronix.de, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH net-next v3 7/7] net: phy: use phy_read_poll_timeout() to simplify the code Date: Sun, 22 Mar 2020 10:48:34 +0800 Message-Id: <20200322024834.31402-8-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200322024834.31402-1-zhengdejin5@gmail.com> References: <20200322024834.31402-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 the code in phy_poll_reset() function. Signed-off-by: Dejin Zheng --- v2 -> v3: - adapt to it after modifying the parameter order of the newly added function v1 -> v2: - remove the handle of phy_read()'s return error. drivers/net/phy/phy_device.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index a585faf8b844..cfe7aae35084 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1059,23 +1059,15 @@ EXPORT_SYMBOL(phy_disconnect); static int phy_poll_reset(struct phy_device *phydev) { /* Poll until the reset bit clears (50ms per retry == 0.6 sec) */ - unsigned int retries = 12; - int ret; - - do { - msleep(50); - ret = phy_read(phydev, MII_BMCR); - if (ret < 0) - return ret; - } while (ret & BMCR_RESET && --retries); - if (ret & BMCR_RESET) - return -ETIMEDOUT; + int ret, val; + ret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET), + 50000, 600000); /* Some chips (smsc911x) may still need up to another 1ms after the * BMCR_RESET bit is cleared before they are usable. */ msleep(1); - return 0; + return ret; } int phy_init_hw(struct phy_device *phydev) -- 2.25.0