Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2477332ybb; Sat, 21 Mar 2020 23:57:31 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvqKtjHIVyUvetlqwlgpJDQD97fQ6S05pHQsNGBgYuiYiJuSDKf4qZVxYQEGOfSwmX1x2ZH X-Received: by 2002:aca:ecd0:: with SMTP id k199mr13169383oih.60.1584860251742; Sat, 21 Mar 2020 23:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584860251; cv=none; d=google.com; s=arc-20160816; b=YT3sC3Rfym4woIJ41TvJP+ImefeLwqYB4lptOGo2APbOHJcBmTc2Bk/XNeWOmrl41e CGD/PO+hB15YZ/nm21vSxPdtGgX2ywoFnMgZ4aHZoL1T/EqyTgD8iKGNUbFJTezLFHjT CkkBZ33Mlsp9qjuCRlhFMPTSn4LtJA841r/wJP5aYvK02CwPscSALoDU9ubt6J1IdC1P h5RkGWxniBHrQ8jL5sePFzaipCLxXnFuhlm4BW8ZxIXTPZ/nUI7x45+db7KxHTsVgdbB gTrDhgjGU//fbqKauln2Z/Jj9a4s1VobMSKGsA9DxfwpDHykB4bMUVn8BiMw2u1dW5Eu Gg/g== 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=GdjHs4uUTEBEfa5bLl7pWyzl+sdKTsngOqpzF9tHKx0=; b=mZuVv2c8GSGjJYVa2hG/AdZf9qpdKnM2MuPwSsqS1Os/LWQloYXKtKLPxgJbtt042V /jLowmk/KDuULgV9AYLNLLWS3ZRNpLSXvZYJKa92HLIgO2qbCasbUZvrS6REj3nZrgYi Lv1atdC0Ow7ApN82nf0NPt9gn8/7wJ2cwp/fedFeffiEhwbTnlcNwWQRdp4ot2A8yNkO +OvyfbtzEPH6dh6aL5TRErTdJmu1H+MCqkE02BmsOfK+PEuZBpi8mDPSQOsNEcVQB2gG 3z+pVOP8OHtK0k4Bpglc90H50K0BLT1aZU17HnOPKcr8rHmPg9H7GMELZpSyDeIHhhai /rsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B+Fb7vYa; 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 w12si5733884ote.179.2020.03.21.23.57.20; Sat, 21 Mar 2020 23:57:31 -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=B+Fb7vYa; 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 S1727118AbgCVG4k (ORCPT + 99 others); Sun, 22 Mar 2020 02:56:40 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45786 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbgCVG4j (ORCPT ); Sun, 22 Mar 2020 02:56:39 -0400 Received: by mail-pl1-f193.google.com with SMTP id b9so4429131pls.12; Sat, 21 Mar 2020 23:56:39 -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=GdjHs4uUTEBEfa5bLl7pWyzl+sdKTsngOqpzF9tHKx0=; b=B+Fb7vYa1OwSqi53f2jHu81D4h+fKGweze3oPxYIxntMpACPtg8c6IVdrUzsN3Qt59 KCa7HLHaRC0RB+g/F1i3eGEefWIF9V3hH+hhkdk2QUHoRKAVpEr5Y0moCxYkhkzx3Rz3 gxJxTu8ZPssy1pCuDJCT3OOqMs4sFj85MN67xE7ry9iBO092b2JxPi7o3or4BSi9s1mo BQ/CUbJ33LUnRJ09cnm8byNn41awi8rsPjbq7vOSyeY/RJ2Nag7gDS9JIhtZjbD8KvMj n+ePhGdSpwKdPKDBrck1l/upp3oDXkNJi1e+WAG4f3ZHVUwJlN654HKPYOUja9gDBilG laNw== 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=GdjHs4uUTEBEfa5bLl7pWyzl+sdKTsngOqpzF9tHKx0=; b=hT3k06J5c2XUnQLkQpsCTYUUA8R7eQ9NjJHhBYfanDSH666niIKqZYXK4/ipF7+VVL HSsrUzeSf1pc6ZAa/Prry0ZQS0qeVjsuQ8RqmXkr99T/u/lTfOUGBBDR9MiKvxPSBjsg LSY2t7lX0uqWqQtknU3CdQev9xhEjooWfMGM2Duz2E1UpnMXHaiG75tWvdqYiN07WFfR M897BcnmCvuL+IfHVLeHhst4xi54jQ3E7C6VxJh39q4aKxL6bZRqVGtxP7mgGn2M4kaR 9HuoZK/egg9Bv30o6tWv3oLVzJGjClkwTHAtuDaU/Aa9xMQinjj/yspHfUQiRjNhdYJM wYZg== X-Gm-Message-State: ANhLgQ00kUjeMHQGAejSlrCu6gH4GgPEpX+c7A+WlEAjCiQfUeYd+otR VPfLukWqnTfpcJ08+Unujg0= X-Received: by 2002:a17:90b:1889:: with SMTP id mn9mr17983892pjb.85.1584860198569; Sat, 21 Mar 2020 23:56:38 -0700 (PDT) Received: from localhost (216.24.188.11.16clouds.com. [216.24.188.11]) by smtp.gmail.com with ESMTPSA id r14sm8877530pjj.48.2020.03.21.23.56.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Mar 2020 23:56:38 -0700 (PDT) From: Dejin Zheng To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, gregkh@linuxfoundation.org, broonie@kernel.org, alexios.zavras@intel.com, tglx@linutronix.de, mchehab+samsung@kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH net-next v4 9/9] net: phy: tja11xx: use phy_read_poll_timeout() to simplify the code Date: Sun, 22 Mar 2020 14:55:55 +0800 Message-Id: <20200322065555.17742-10-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200322065555.17742-1-zhengdejin5@gmail.com> References: <20200322065555.17742-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 Signed-off-by: Dejin Zheng --- 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