Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2920638ybb; Sun, 22 Mar 2020 10:52:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtackLo+/s4goDxcTrKBH7ztLatR1CIZQiy5OH1iamTjAaxspHPVPRLM9wYZ1dSsRPhbsVX X-Received: by 2002:a05:6830:22f6:: with SMTP id t22mr15797847otc.229.1584899534799; Sun, 22 Mar 2020 10:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584899534; cv=none; d=google.com; s=arc-20160816; b=zQP1z025pB5KXiYnjXIWOnpvleXrQZlO487D/2S/xnHUoZGdcDhZ0aKL541psSyAyv HWcajyaZeNR/0RuBeCd1tN0qeEvxqnUKXGG3pvNlgxJD9psByC/5h2m81TDWWWd858Tk WQiimbCBqTutefkwSjEQagXRiutFFPGxd3hjCKjhFzyEFeRABshaOtpcfSmdCI1Oxvz+ qSwXd2OVnHMpADLqB2zOT+j2RXcfNmTtDUmB6q1r15J7JWZE5VQOCYueYbiMImWA+gLu QekHue8EaMYvHKH+GOek0H4a0ffWyxD3cSijIUWODQyUYLa/M+NT3RSFoGMcF6786Pp6 MdbA== 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=NDwcXbElIXd33ZID6UH6u9dMvaW921/FvHkSPleU3cw=; b=MBtdKzpwXLiGkS9gJEl/zGMCVwgtVZv1ZbjQGIvzUxNH5JIMhnbY4/X2/yq2kvMxts mPhNKoiR7RY1pQRxeHM4rhjOl5XPwIicrr3flwPvjRgRbmueFzI0Q/kJiz8emicBS+77 TgSpeumrcjq7b+lOcmpVqTaL/cnSekVJfYKX4PEsQWA7Ad3Vkho9VCPoQ/lvK/uIgeXj NDLLdU9SVgfxW9Pj78uNeEhSLnVSpsKoUkOtQCnp4BshMsXZEPgzvIVdN2bAdGhVzTjB 0wtieGKBTpwHZoGizj8C5sPc9zIu6Qi/xUsolMw8l59CSvMWIZVX0QUgaUHHuNpsFUiq LbUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GF+8JpWH; 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 o25si6281967otk.28.2020.03.22.10.52.03; Sun, 22 Mar 2020 10:52:14 -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=GF+8JpWH; 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 S1727175AbgCVRu3 (ORCPT + 99 others); Sun, 22 Mar 2020 13:50:29 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44193 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726781AbgCVRu1 (ORCPT ); Sun, 22 Mar 2020 13:50:27 -0400 Received: by mail-pg1-f194.google.com with SMTP id 142so694808pgf.11; Sun, 22 Mar 2020 10:50:25 -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=NDwcXbElIXd33ZID6UH6u9dMvaW921/FvHkSPleU3cw=; b=GF+8JpWHBGFvIgSO+k4NS9xkCAxr5UeaLnLWB+HDaGaIpTmX/DP8c7AU0kdAYM2QKq FYETp03CkLi4KbwiMwKZKZagglctOt7tkTuG49+l0EQM9KywalZDap/lUW1/psEZO6oX D1R1ifuxba7xW3VgNoro+1poTbAkd11PwSv7kTh7o6zULnHEtV4TpO03kX2C2nVlbM9R ZPoYR18WglrUYAP7VjxYu31Iqs8KUwBA3BjgDkTqQwnlberfNaVVLA9kmKUOpOq0j+2t Emo8R2ZPiDpmSOmUtajKghHSwqSClKKMGJVslgneh5il+Kmua78xQU3jRs1JmjSjLZsI b9QA== 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=NDwcXbElIXd33ZID6UH6u9dMvaW921/FvHkSPleU3cw=; b=BKCyhdxrAaCUNvXz9Eqz8TPIhueu3+LPNlxqNEHsydpZt574X3ZIUzljGbqii0q9bE rbmI75szDmPXotfqhByc0OsfjJwEyO0pnnS/OZK7Wxk1KlRp65Y5HA5d+s1pY12Ohy50 fwjId/Z7GuJafFp8rOaDJHrjEElOU5KZ9FOH0F0zJmfFw1Guz/Hsx8S5nTMtquXKsHKx 6oR1BkQ/kgERhdxnYNTZp81IYDlRgAA9qJpLGyM0PkSpoQAsUwepzQ8STAk3vVyY2wmu A7vYPNNEs6rySAcOJuzm2ZmlNi0L1+U19Man8gFI2bY0yGQKvlSoPDB2DyFMj9Lbz/52 NJCQ== X-Gm-Message-State: ANhLgQ07n3PgnGSMsf2j6LaRTregeHizgn5PtlSz12yqQma59I0rhX3L jJpAweYyI/cOb2eeW2aABDA= X-Received: by 2002:a62:1946:: with SMTP id 67mr21077830pfz.0.1584899425512; Sun, 22 Mar 2020 10:50:25 -0700 (PDT) Received: from localhost ([216.24.188.11]) by smtp.gmail.com with ESMTPSA id e126sm11000284pfa.122.2020.03.22.10.50.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Mar 2020 10:50:25 -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, corbet@lwn.net, 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 v5 08/10] net: phy: use phy_read_poll_timeout() to simplify the code Date: Mon, 23 Mar 2020 01:49:41 +0800 Message-Id: <20200322174943.26332-9-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200322174943.26332-1-zhengdejin5@gmail.com> References: <20200322174943.26332-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 --- v4 -> v5: - it can add msleep before call phy_read_poll_timeout() to keep the code more similar. so add it. v3 -> v4: - drop it. 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 | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index a585faf8b844..24297ee7f626 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1059,23 +1059,16 @@ 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; + msleep(50); + ret = phy_read_poll_timeout(phydev, MII_BMCR, val, !(val & BMCR_RESET), + 50000, 550000); /* 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