Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3811490ybb; Mon, 23 Mar 2020 08:08:12 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuXdCPn6OXaBHW2v2mnisR/jiArNge0+Xpw3rJjYqGCle7wfeOhplaEGLrFupna9X3OoVsC X-Received: by 2002:a9d:4c8f:: with SMTP id m15mr18687972otf.273.1584976092371; Mon, 23 Mar 2020 08:08:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584976092; cv=none; d=google.com; s=arc-20160816; b=aDxIEKXJmNBIz0d9oXt1v807S05Rx6K99LUGZrNg56YTOEbVh7zkiyZg33ROsp+PPc 3669fwX39E0yVIWqIq7CrFQwFWosx3JUhgov7AKWyPGSesQSMQuvikm5SlJsqlVhw736 6blWdnTok9IFOrgGxVrrfe1LMbOm5TYGc1A6MLoIMXQvdj1HNQUQNt+/SSuTvoX65/gY Rip/WVIjzt5aM9E35mPIDOJdWnQ97EP/TWpf7ZV3H73xTonu8xtA+ErcgLoHgaCfEsDl ut7x0kKvE+t/nXqYBdL/IpehQTXEWQdb/uMevrj3n8wfIuM24AlcyOHwK6InZf5Tr8EF pF9A== 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=aczxO6GwDiorwLoDN3fHadbtsX816dfm9JlNEnnSNQE=; b=l7zsIZnh1Rnc6/vJ67a1sognr5MhcOOlbIf2LHNQqMzXxLUQgGybN+VzsRKcTLXjVn Ldei6uRD/JquIZJ4hvPsTn4fvU8ZaSWFEfQEZx+ILWDnWNFxED3lCcWE2n0oh1a87NAw 7EjW60rukdjdaO9OHNMtHpdgCe2xTyWx45NkP5Y7i+QIXKWFtSGEgOT79301F6A0fJf3 rroYeUj0ym+Y6C7ml85Q+mjImgFSb5BJgNwul+tPhmp2PGRaqwePEQ+nvvYclR/FoQjp dDEMC/iEwOLOCHpKlaDG51ZOkMCsChOCm0UQhhfMofvroW5o8b+57nucdQaXZjTuUAol rxMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dsT00cSS; 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 v6si7494644oif.149.2020.03.23.08.07.46; Mon, 23 Mar 2020 08:08:12 -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=dsT00cSS; 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 S1727425AbgCWPGq (ORCPT + 99 others); Mon, 23 Mar 2020 11:06:46 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36964 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727024AbgCWPGq (ORCPT ); Mon, 23 Mar 2020 11:06:46 -0400 Received: by mail-pf1-f193.google.com with SMTP id h72so5401518pfe.4; Mon, 23 Mar 2020 08:06:45 -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=aczxO6GwDiorwLoDN3fHadbtsX816dfm9JlNEnnSNQE=; b=dsT00cSS6aNi0DqhxCiXWUaVLOie4MnL/FkV6GzSP+zrMfIJBRCMJ6caPEqussT5LM rNc4ROPzbrQK19S4O8Ff2sJHpzeEB0rsharmB/ba/JEUPFqETGnbBTU5Hmf76iXsdNvJ ZhtGGzQBbEduKjFdUkRIPaNDrBtQh8d+jPEAuJhUpkksYmVLVCcEleHny1fwOCKSrccA 1KEUXgxBII10ZA3yCfmVn4BHQqoBZiDORmuS+IbhIgqII1CkzZl1linPSXi3Sqs4mUT9 rx0Ld206IooBDzumlITrqkik0EUmF9MGI+Ssb1xoagPZK0I0OCgkoUGigczQIwOuJgI4 dRqA== 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=aczxO6GwDiorwLoDN3fHadbtsX816dfm9JlNEnnSNQE=; b=scWa1HAFrFhdSacRJv4BsvrhzVhf01GjfB6mZjJk/f07jn0u2NoM0Aap4yvxWo8WK7 XGuLF41aBgmwCoOojHbcyvRTkZbCXWuaRy1BSne9upeBdG19CSBZZ7lcm3OxP4tOVZ/4 2qmI2A3rrf2TpWOGPxv7Ej3GD3vXqmr6FiTwVXlMLqwAWKhnDROLm7dNz4V3/N7tLOCa cZgy0zVRpOr1C1MamNvgC8dpBo1YpYMWRytLkFHCNlfzLogaApUPYGoTyhVehITVzCKJ tnKfORuQIjOlIORirM0lqoQHathSC20eFFOq+rgfDjo+FsdyAiJ8XwU8putDa857DKFT 4HEA== X-Gm-Message-State: ANhLgQ35qWumBTwXs0Kqu4bt7hBMxLejPW0qjWG/us6coiuJlBOb+GXV BUS3ZKfqhksG+je+YPQO7VU= X-Received: by 2002:aa7:8d82:: with SMTP id i2mr25503829pfr.179.1584976005502; Mon, 23 Mar 2020 08:06:45 -0700 (PDT) Received: from localhost (176.122.158.203.16clouds.com. [176.122.158.203]) by smtp.gmail.com with ESMTPSA id x15sm13306119pfq.107.2020.03.23.08.06.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Mar 2020 08:06:44 -0700 (PDT) From: Dejin Zheng To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, corbet@lwn.net, tglx@linutronix.de, gregkh@linuxfoundation.org, allison@lohutok.net, mchehab+samsung@kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH net-next v7 04/10] net: phy: bcm84881: use phy_read_mmd_poll_timeout() to simplify the code Date: Mon, 23 Mar 2020 23:05:54 +0800 Message-Id: <20200323150600.21382-5-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200323150600.21382-1-zhengdejin5@gmail.com> References: <20200323150600.21382-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_mmd_poll_timeout() to replace the poll codes for simplify bcm84881_wait_init() function. Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Dejin Zheng --- v6 -> v7: - adapt to a newly added parameter sleep_before_read. v5 -> v6: - no changed v4 -> v5: - no changed v3 -> v4: - no changed v2 -> v3: - adapt to it after modifying the parameter order of the newly added function v1 -> v2: - remove the handle of phy_read_mmd's return error. drivers/net/phy/bcm84881.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/net/phy/bcm84881.c b/drivers/net/phy/bcm84881.c index 14d55a77eb28..3840d2adbbb9 100644 --- a/drivers/net/phy/bcm84881.c +++ b/drivers/net/phy/bcm84881.c @@ -22,30 +22,11 @@ enum { static int bcm84881_wait_init(struct phy_device *phydev) { - unsigned int tries = 20; - int ret, val; - - do { - val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1); - if (val < 0) { - ret = val; - break; - } - if (!(val & MDIO_CTRL1_RESET)) { - ret = 0; - break; - } - if (!--tries) { - ret = -ETIMEDOUT; - break; - } - msleep(100); - } while (1); + int val; - if (ret) - phydev_err(phydev, "%s failed: %d\n", __func__, ret); - - return ret; + return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1, + val, !(val & MDIO_CTRL1_RESET), + 100000, 2000000, false); } static int bcm84881_config_init(struct phy_device *phydev) -- 2.25.0