Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2920604ybb; Sun, 22 Mar 2020 10:52:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuHtP0FBvZYqFMvyn7QbagJ995XU4fzFULT4T5QMDiNxLHn8KDcMKPoG0vuWUHBRP79uWGY X-Received: by 2002:aca:cdd1:: with SMTP id d200mr13711985oig.153.1584899531397; Sun, 22 Mar 2020 10:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584899531; cv=none; d=google.com; s=arc-20160816; b=Z0fulWl05gpaHsERBMcLharLSYEwh6II0RHryL5OMzePWNOhyKZc/60qgGLUjjw5oG 5HxNAVtcOs2u1jR/Z098FqpqI/tWbZDW253yEhkS4wqA8hzQhu+u1zr1PIyUZhdemtiF QFfpSfqJy1ZDhUTkhPTrDSITCQLO34DzNTnUhkSPKp699G+XVFDN2ajtNvZZEnsdC8T3 QmEdrAcsiKNU5i+WmlG1Cgnw9+BGlqulWYYC8ne7cLfuR/Uy2uIegP63I6uEJlH02UdY 0CRGddhjJvhvZQ48lraszndmOk6m296p2S0JvI1EKCZHwvL+hTUZ/zR0oV6c+e5BeyAV mPdQ== 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=AymXtp3nG2LLyQijF0AdQUTMbx+e63yTlaZBg9wNr3E=; b=KmNJ4ENxRMRATZLBKCv8pJQef94Gf969jI3NAkPddZXIzoVYzB0bbRPc5tbYqyu+f8 VQT48g1M1WC0KgljxGvOqllrIo2bcKRbTAk6GPGdmlHd50Gg44JoOfdHGR8sqyKD1q7o 9iIihI1sknZTsMfFCGN7GmGiA9bed1VVTFZ7tHNIUBBfWOBk3Owzg+BW8TDKjoq+3ZUv ImsdsNyYRho9xCEm+r3Im4wbp9aFiy50O9obU08f5MkqhEYusEUv9qaUCJ0g+gNd0mXG mhaqCCAxR+TBlepIFXGZ796ZKG2Q4yO9EOpa89db9FKuxKX7D6e5biXPC9J+HYUNrDU0 ct/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IlEFI136; 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 z78si6588933oia.200.2020.03.22.10.51.59; Sun, 22 Mar 2020 10:52:11 -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=IlEFI136; 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 S1727230AbgCVRuj (ORCPT + 99 others); Sun, 22 Mar 2020 13:50:39 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44204 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbgCVRue (ORCPT ); Sun, 22 Mar 2020 13:50:34 -0400 Received: by mail-pg1-f195.google.com with SMTP id 142so694929pgf.11; Sun, 22 Mar 2020 10:50:33 -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=AymXtp3nG2LLyQijF0AdQUTMbx+e63yTlaZBg9wNr3E=; b=IlEFI136z2Ku169Qafi1L04lNH2PtWbJTwkZVbsZIH5y4xUSSUnY468PQp+D6aIJ73 HIH4XuPjOJ5ZYRDfLgnzR2fJfVLVcjM7B0Hk0B5DcmojpC2qnaBhFSHbd+M7ilNoiU+a VqPMI5HZHFugtDQF9TyN6mlczdpxlI1xRTxdJzXNaf03HwPWNHalBJs3h1uBo2QQEcpr ydD88vMRIOCDkYFu53YPaoyYBDvpumsFqf7ue7wzeAtREUsps/XCYgSEIBbqpJqYUeTB Bp4HjJdHldmCms0+4I08eDqRldrPUuUzdJPzlhFprC7YoqpVQLgdVzdGkgSl91F8538z uVNA== 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=AymXtp3nG2LLyQijF0AdQUTMbx+e63yTlaZBg9wNr3E=; b=qSa4WkxywL+AvxAcR6NQgROtPd/h18oPZkQ3+tR3bYrl3sdjpbtH+h2DiV0Qk5Gp5V fZb0sBLHwnuvFzF8hV9rBDk5AoUExjG+M2ZjN0YrdRxpxInL8nrrZh494ScXpkjQXmKm e8320WtKqQEA3jeIRDZK3jAl24vIAN5ZtMSiJV5lWJwnkazqo2u+Ik+8WoWi0gBaWiN1 NabkZdgluhs64Wtsp3gII8qZ7fvnI3hIcJo96p8DvxO9xh8hYN/+raa+bvXn+4/EWmtd AKr9cuE5lbRYAPdXuuPHGFd89Lcju3klg21neDqVWIwkEouCWFaFdlNI2WY8Z22NVITY fUNg== X-Gm-Message-State: ANhLgQ1ZCX8BOqurTAg5t/u6py5sPwnbEOHvn0VAdgC5asfP/nCcQFdG 8z3ZNXnoDKpk9OmoeR+syJ0= X-Received: by 2002:aa7:99c8:: with SMTP id v8mr19918083pfi.151.1584899433441; Sun, 22 Mar 2020 10:50:33 -0700 (PDT) Received: from localhost ([216.24.188.11]) by smtp.gmail.com with ESMTPSA id c8sm11594453pfj.108.2020.03.22.10.50.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Mar 2020 10:50:33 -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 10/10] net: phy: tja11xx: use phy_read_poll_timeout() to simplify the code Date: Mon, 23 Mar 2020 01:49:43 +0800 Message-Id: <20200322174943.26332-11-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 tja11xx_check() function. Suggested-by: Andrew Lunn Reviewed-by: Andrew Lunn Signed-off-by: Dejin Zheng --- 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..32ef32a4af3c 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); } static int phy_modify_check(struct phy_device *phydev, u8 reg, -- 2.25.0