Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2343556ybb; Sat, 21 Mar 2020 19:50:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvXDAElziGT8M1x0Lid5vUnsh0d8QsCTbWg87HDhlI2EI8Go8V6BiFO2NrFTrVZFRt1u5qY X-Received: by 2002:aca:4e08:: with SMTP id c8mr12541117oib.143.1584845424872; Sat, 21 Mar 2020 19:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584845424; cv=none; d=google.com; s=arc-20160816; b=wyiBPWcv4EDGeSyYahs3uSW8xr8iPQXGVV/cA1wcXEyCH8HM3MOXaRy0XaoTOqw/81 ZRZ+xID9Ar2uNtjnGdowDQE8araXYgjbF2DMV/gQGl9EQyfOk9wBu2l70INXgPSHmC81 5udnCha+rwEBFZs8XZhHSSqxJEvK1imADvhBlBdKYtipNgC40ahIUwq0XUo4lI5OAKss 1KQRgfmf+RPSrw2ahXi7sZ6D6198If7MfQWrt6rP9j8jAwxUuz7hYd6vNmgfmPU8wIIM reppP8taJT46uUto3GXhX0FH9UVo5ewvv3D5rG8Yqh6Q4Stiogvel3McMMWKCEUyQXMu J0pw== 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=vsYdU7rh2RiW9uB6cmSa7Aol56BWlbGP1JB/9O4K9os=; b=SncN8a7TpS/WmsU2S9QWDA2kcYRLzS+S/4kM0yXrQ8JzCf/ZiJpnit2YqX7EjMXGhv ETX4b8vE1A3LyyGbsUMAEpLnAaMOPwM4UN9/0A8mTLl5VuT3lSO/Jgs5KDh+ugh+az1m czPw0gxhZfpmFEqp4S98WPU1J+33spFaiMo9z9W4zqCqzIyCldV7cZcHwQvrVPKOgwVA G2l3FwIvgnH7lMCH3W/rGf43NaQTLnHhN/GNO0ht07TqkmKMO3lLXvzy6d8eAvd9NE7p 4ZGMI5M4B/YzxaNHmpYHcVPXX3QO1m5PgxgmLB/udapRBZt48UXh2EmuH/b7wgE3FoZ0 uLwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gy+CDJfg; 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 h6si5015066oib.246.2020.03.21.19.50.13; Sat, 21 Mar 2020 19:50:24 -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=Gy+CDJfg; 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 S1728416AbgCVCtl (ORCPT + 99 others); Sat, 21 Mar 2020 22:49:41 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:40712 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728390AbgCVCti (ORCPT ); Sat, 21 Mar 2020 22:49:38 -0400 Received: by mail-pl1-f193.google.com with SMTP id h11so4297686plk.7; Sat, 21 Mar 2020 19:49:37 -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=vsYdU7rh2RiW9uB6cmSa7Aol56BWlbGP1JB/9O4K9os=; b=Gy+CDJfgDqGXn0dlY+EV/zR7bqeOmMdxNPPyVrxJz8Nx67QoILGtuXu/tmjaF/x5Uh Bd1jLkNHUcqGBP8oiivNPXfVGqKl9ky3kb4qWq83lRHcPdPjU/K5OYLZLhk4WCGsQNJi 5BuEjW52NPLOrYQUurACb6G74Hk7Hs22qp2sNB5318GkXDCtnSXuQPEh4FwUh8Zj0K5o hJ1ixGrfr9bq2gWPbUiyLOq89AHv2B+5ejcgCzYYJt2LL0Eh0uhcadk9pUCArQC/Ug1G PF+Vcbr6pC20pWa/I04Z1gLs2voAvLF0ukoC2SxmwYHtGHTt43NbIWZOx+7uOzvArj8y +eYw== 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=vsYdU7rh2RiW9uB6cmSa7Aol56BWlbGP1JB/9O4K9os=; b=p5FUQln3W8L3IlIJPwxKvrnJAihCFS+ZsZZCng9Spu793xpmKtLX+VL2532e6l6nmz hmrduX/ibjc5947Nqll4OIEC0ImAZyOqJo5WLH7DmBzUdmqAZ0If0E/HC+/TKAHfgmhY Ry0r2TUSinTESRoI0TCag+hhOOnYZTZROJwYG1sizeikzLl9KPQq4HuegDb2yk6dPPkG NEAGjSnIpaaGrlGd9VvEMn7W1fze89YkE4qc1HphW/JBYrMSSbrn4lPmhC0l9fuwb+o/ OOFGFxGeO39T0+jkZ+Zx4cWa8IUBm7qcPMYaB02uMAgvzfRbfzVIW7abGkqDFKk5jBMI QpAA== X-Gm-Message-State: ANhLgQ2rGXQ2FD7dQ/YZrJoYyornGDZcuCYeQlFFSHb1c62XME6KM8HP KxHWT0jkHErkUzI9ICbtC60= X-Received: by 2002:a17:90a:928c:: with SMTP id n12mr17983736pjo.45.1584845377433; Sat, 21 Mar 2020 19:49:37 -0700 (PDT) Received: from localhost ([216.24.188.11]) by smtp.gmail.com with ESMTPSA id u129sm9451597pfb.101.2020.03.21.19.49.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Mar 2020 19:49:37 -0700 (PDT) From: Dejin Zheng To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, allison@lohutok.net, tglx@linutronix.de, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH net-next v3 4/7] net: phy: bcm84881: use phy_read_mmd_poll_timeout() to simplify the code Date: Sun, 22 Mar 2020 10:48:31 +0800 Message-Id: <20200322024834.31402-5-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200322024834.31402-1-zhengdejin5@gmail.com> References: <20200322024834.31402-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 the code in bcm84881_wait_init() function. Signed-off-by: Dejin Zheng --- 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..b70be775909c 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); } static int bcm84881_config_init(struct phy_device *phydev) -- 2.25.0