Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3264256ybb; Sun, 22 Mar 2020 19:58:15 -0700 (PDT) X-Google-Smtp-Source: ADFU+vshgneCQt8nVJ9k+0LioKJpgalwhr5h69oFprNHqQqUHQqDxGTEux6jbEJMcNfAneACC8j8 X-Received: by 2002:a9d:6a0b:: with SMTP id g11mr15427260otn.31.1584932295676; Sun, 22 Mar 2020 19:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584932295; cv=none; d=google.com; s=arc-20160816; b=ly06AJOjF8BO2fSyifVEskArrCLGlMJhdtV1MkUydvuKi4V9E7aC1ToDetG7hjH6K1 5ywpl1sgQhmEp0KSNKzz3cPYnljRkzA9D2cCaf/bf4LHq4wc9lWRJ2sJsN607usDnQ8R CanbrWC1V/scgUVFt7vtksaB5q6pWDKWxSQVFxcOeDLgTrG0o4+9xquZh2YOOq5AoA1c 8oZvOT8wlNy2z/I9+IISjDJr7zyg71UIzcT1pcq2mp0lL9E4HOuuN7fcNhbAYONC5zby 6j2E5txnPjX6dX4Ihbm6UrYWNC2IHenkCHtE7E5wgVsuXdSWRfhtXeSXdQxHWk5uIJbv 34iQ== 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=Mifl2ikKJNKf9Y0+MA8EZLncr03EmrnFMDIlWtiHq4E=; b=IZdUt9OnNK+ODeH0DHMvm/ryFiwIsyGTrBmd7y2vPXTZNcyIGJH0OVhtBOfjXttAOF vwmmKOipRXWZT8l7Hqp4wMO7SxVcur7gqohu6U16KkHkcCU7913qz+0HSYutumrT6JPv pZToAXWNjunVahfCVWAENz8HSZ5RPMchZqILrjMIxOvUI7G8DSiFo6lcsuqguPi5Y6mI 9G/dMGZdmGu++OFTD4DyMi6GpEtcxAvRauoq1SxrvWiO4ouw5vP68voDHX+44qv+Qd/c y40TguTf36Degm+UtAzGJ2b3hFfnsDBGXaRuMJB0KTYTDWygFudGVjdtv70KC7UtLAZO P5VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="vNb/KEz3"; 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 b197si6443353oii.198.2020.03.22.19.58.04; Sun, 22 Mar 2020 19:58:15 -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="vNb/KEz3"; 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 S1727260AbgCWC5Z (ORCPT + 99 others); Sun, 22 Mar 2020 22:57:25 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35380 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726983AbgCWC5Y (ORCPT ); Sun, 22 Mar 2020 22:57:24 -0400 Received: by mail-pg1-f195.google.com with SMTP id 7so6460764pgr.2; Sun, 22 Mar 2020 19:57:23 -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=Mifl2ikKJNKf9Y0+MA8EZLncr03EmrnFMDIlWtiHq4E=; b=vNb/KEz3bAt7X6kr6oAgcFWun+PsRezIj3xzygvRXA4JOwqsNnVMvncVjBwZCTMMNL T7AciISiKpIB6GnGz2uz87D6u6350q5Q/iPjrOxqOv5D9hYbSbWy0N1mW0xo/2AKy4zk 6dhhuWui6UydKJ4AJ4RWuBoPWOp4um2YzKIqiZaSapX9qXbOnZ3+3DMBQvMxugEFG+sd EKanBHoEC8oQ7qEGcYqakGHmaBcIMVYF98IboJ3iWoMD1e3mbmN83jgRjcfM/yzt9XM7 PiBvcNIiriX4TIUi0ogk+VlKgeLan5WNVZblMsXn34ryvhQFeJSQpdDt5dit2z9Y/5sx vKxw== 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=Mifl2ikKJNKf9Y0+MA8EZLncr03EmrnFMDIlWtiHq4E=; b=P+PwHB8XxbImrZxq7RctS7alvwxkqPQhbGiKe9BXB3MWWvw+ChKQkXAYlWf03CWxtT 5sAbuRec0ZHO/+RnL1Y5SI1WVMU0eRXNJhYlXe3ryWG4+QOQ6hqlLDMZA+drU9AxgEdU 4V078ZUJ3VFVpla8LzriqQ0mKHuj4pqS9QZNr7e7ekPJ/E1TiKNEOEnuIz/6vZFWCjok 0qqTjycW2prie3bk9MhYByNJMXxLA7jUiMzzmXAhupbnGYDf9lHDF8sw58CE9vPqwrwa 8iAhvmvCI86q2y3pEygNy9JSJxbvrNa7jsjDr/R1cg5OvO37JN2ujvmG/I4hbGoGPOJd Lfng== X-Gm-Message-State: ANhLgQ3cDB0ciqwhghfB4KGUMO/QI/1lTePfSDwyLX7HNTcP0bCDREzK grQLYmYEdwCzFWtvhbHetcY= X-Received: by 2002:a62:6807:: with SMTP id d7mr22401640pfc.230.1584932243020; Sun, 22 Mar 2020 19:57:23 -0700 (PDT) Received: from localhost (104.128.80.227.16clouds.com. [104.128.80.227]) by smtp.gmail.com with ESMTPSA id c15sm5600915pfo.139.2020.03.22.19.57.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Mar 2020 19:57:22 -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, 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 v6 05/10] net: phy: aquantia: use phy_read_mmd_poll_timeout() to simplify the code Date: Mon, 23 Mar 2020 10:56:28 +0800 Message-Id: <20200323025633.6069-6-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200323025633.6069-1-zhengdejin5@gmail.com> References: <20200323025633.6069-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 aqr107_wait_reset_complete() function. Reviewed-by: Andrew Lunn Signed-off-by: Dejin Zheng --- 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/aquantia_main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 31927b2c7d5a..db3e20938729 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -451,16 +451,11 @@ static int aqr107_set_tunable(struct phy_device *phydev, */ static int aqr107_wait_reset_complete(struct phy_device *phydev) { - int val, retries = 100; - - do { - val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLOBAL_FW_ID); - if (val < 0) - return val; - msleep(20); - } while (!val && --retries); + int val; - return val ? 0 : -ETIMEDOUT; + return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, + VEND1_GLOBAL_FW_ID, val, + val != 0, 20000, 2000000); } static void aqr107_chip_info(struct phy_device *phydev) -- 2.25.0