Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3812461ybb; Mon, 23 Mar 2020 08:09:09 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvehirxiG5y3pSsMfTWAeD9pUxomw4+0q8g1iw7hehqOIRziuSEfqOksgsCfVAp3P5Y/Vjh X-Received: by 2002:a9d:630f:: with SMTP id q15mr16115948otk.146.1584976149182; Mon, 23 Mar 2020 08:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584976149; cv=none; d=google.com; s=arc-20160816; b=Wc3V0RNi3WBkuaAkpGNccZgTQ1cMQ5YvmaRKY31lqGEPxSaA6Rd16OxeTFKEaNFqSY ulhIlLbk6j6j/dFSF3XaIINFI2RGx9AR2eJZWZxiTE9dNVCuLTWt62ksnKR36S/2IhJg wpF1eGHt8qI+B4neGzF8JTuOsRVyE0xWh2+FPQXllS9xS40fDgxP7zsW0GamaYLcLJqW MpwbIF5chSIdggBBpz0+H+u06leoked2gebq97DpBKgdYvwV/NYMH6m3taxrT/dgwglX /VkSc0s2+nu/dZEtZFAkty+0He4niwjTh17F/T88Or1ppJgbDrGwNOHwqf18E2n3T1PY +9Zw== 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=Aa6t6On9SFFaqUu6JfdwGcBHkFRJmU7LGTC9/kij2yU=; b=KdYTQyM9BccHzcT3KXiynv584D0nBpIBCbVDYyMxZPNEPPjRB+7kCLmsy7VqkC8mj+ QlO9i25Z4LvX99ZiP9Yu+pK1bEinv839R6vyLQRP4EM0MYJdlTGUQhyvo6Px8qD1Iz47 nhRmrtafBUVp3yJZUc2lK3NcMasMDawH/E++1tyhjRJpEMv2Wy2bY5hgCYKCB63UE3qn F1H2fKbCpCxfParbliZpe3exsPNdfrj9T+HUNEuYR7OLQMVrYQbOr//1ZUrleYeOPwm5 rhF6eD5B9EcOT3JjklPPPVolh3t7Iv0V2J+z/WEc4HE7tbBBjTl9ldu3TEQDbPbAlzj7 SFfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j4OeduM1; 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 j12si2358620otq.21.2020.03.23.08.08.49; Mon, 23 Mar 2020 08:09:09 -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=j4OeduM1; 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 S1727597AbgCWPH0 (ORCPT + 99 others); Mon, 23 Mar 2020 11:07:26 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46582 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727024AbgCWPH0 (ORCPT ); Mon, 23 Mar 2020 11:07:26 -0400 Received: by mail-pl1-f196.google.com with SMTP id r3so6008420pls.13; Mon, 23 Mar 2020 08:07: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=Aa6t6On9SFFaqUu6JfdwGcBHkFRJmU7LGTC9/kij2yU=; b=j4OeduM1npfKZ66EzlFeA2FKn4gSg+Klzf5Ykh0nJ37W3tuHmt4dGgjwU+r2fdUVBh WDNf9zL0XLqhB6vrPb7Pd9z5DSJxKYATXoiUW/DH7S98dRnzLO03BmqmM46WyA42VW8e kPO+3pE3hsogvJJ3CQa744J+yBS9w89ZLTeGK6T1lHyKxD3SCvTeOvyX1tG/M9tj64KP AFxa6f9nZKK5i3GLedFqtrkACxPLzgl6QEufAyYZfHqU8314nnwHfhIrH9xK2tAR6TOs 5vQ84b7w7VtrJvdjFtX+b1/vYKL0bEJy6z8kY0XBjmItjrQUH0IifKF0eqgucHUPbZn6 RNrA== 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=Aa6t6On9SFFaqUu6JfdwGcBHkFRJmU7LGTC9/kij2yU=; b=KyR8XGROI7lxrAWkXKJF/aCMkM+wM5K7U/6wPudae/+wWc/U8JVa27Q/6Kyh6Tf2kR TVGKghAorLnnkJ71rSb5EzspyC75AFQ3GkNyHyVaycOouK19zorRSHJU0qZeyAHozA8U S8vovDb9UOr++25+sCCWfuPJZfPWHzVGKwtiYi671G1nYWM3FYUaARqzNgqNALliBua6 sQhNCtEolYD5irb3yZZLf4Kw3xXr0BNDVvJBmsEoB8LOBbqd0jgsgTKRYKqm5FICUTM1 mdcC6GFC+jMUX7OQvhz8TU1pqss/aoOtCs2PtEWskijvM5ndGQw2myUs0aleU8TfRhNF EUZQ== X-Gm-Message-State: ANhLgQ3CUq0+WB52nzvgZQSUY4fG2LDL/ZPqoCDV3gYWD0qcHP0kdHPW l7Wix2RRXrBiw/daPOqcBJY= X-Received: by 2002:a17:90b:11c4:: with SMTP id gv4mr12148505pjb.148.1584976044918; Mon, 23 Mar 2020 08:07:24 -0700 (PDT) Received: from localhost (176.122.158.203.16clouds.com. [176.122.158.203]) by smtp.gmail.com with ESMTPSA id x75sm13914648pfc.161.2020.03.23.08.07.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Mar 2020 08:07:24 -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 10/10] net: phy: tja11xx: use phy_read_poll_timeout() to simplify the code Date: Mon, 23 Mar 2020 23:06:00 +0800 Message-Id: <20200323150600.21382-11-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_poll_timeout() to replace the poll codes for simplify tja11xx_check() function. Suggested-by: Andrew Lunn 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: - add this patch by Andrew's suggestion. Thanks Andrew! drivers/net/phy/nxp-tja11xx.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c index b705d0bd798b..47caae770ffc 100644 --- a/drivers/net/phy/nxp-tja11xx.c +++ b/drivers/net/phy/nxp-tja11xx.c @@ -72,20 +72,10 @@ static struct tja11xx_phy_stats tja11xx_hw_stats[] = { static int tja11xx_check(struct phy_device *phydev, u8 reg, u16 mask, u16 set) { - int i, ret; - - for (i = 0; i < 200; i++) { - ret = phy_read(phydev, reg); - if (ret < 0) - return ret; - - if ((ret & mask) == set) - return 0; - - usleep_range(100, 150); - } + int val; - return -ETIMEDOUT; + return phy_read_poll_timeout(phydev, reg, val, (val & mask) == set, + 150, 30000, false); } static int phy_modify_check(struct phy_device *phydev, u8 reg, -- 2.25.0