Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2920511ybb; Sun, 22 Mar 2020 10:52:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvZSc9OkQhSVGl6oQybuj6BAQx1c+SDPceo+CoW+hCjFfUsz03K5HrUHwJc6LBRezuDd80b X-Received: by 2002:a9d:6443:: with SMTP id m3mr14514425otl.20.1584899524412; Sun, 22 Mar 2020 10:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584899524; cv=none; d=google.com; s=arc-20160816; b=BD0FIhrDD/4SAgHisvdRGaJBr3DC/GEp9ySpugsn0eh6jqXbSOtDinKcdXybioAZ0z lDfuXbSkrnejzkH6JMh8kuaGvLVFtuqnuzRTd6Iz3VE1ZVQcuepO8jqXDylCpK7+a6+l s7wU6FXamp2kxMV/vmqiOPpWwy+5MfIKNztfe8vfqC0IXKPKNJvpvNCEtaqYhT8fwiz7 r2VkXQ2lOnKhQoKE8cQqIJmo27GE/vfG6q2Eu+4q8c6PNmAn8UPa+FhTCrNMEjRV7NRz /0BkJ0WFh9mEMJ2VmBWptqyKYbfieB2XRgSZAm9HCrC8P5CjgMAGvYnofv9j5NBBHlGP h7tw== 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=+KK3Ro2FLwCDE/TwXjj4wqViR4KSXhk4w82GFr36fy4=; b=ehyH3no68Ijgl8OCL8SrSJu+C0mW2Mv5mn3XEbWIQ9Ro/cZfqDr1eo0KjQjauDqcQo 9Szlvgac272+E+037mzTan0UJHwHhN/8fbCeVb02qEYT5Dr03SOIkx1/djSyGCSMY/Wf Ol7f9meLCDzoCO7L/O2Ny+gygbYdOUS5XaRWj7bs3X3h51/pvuf71N6sC5bAYwkHWRYu UcVhjWyr0hhNXUOu/X5wR9cGy7kJopa/PXtCKSWJCUyGtx1MLNHlzjHC3FF65yKrTpzu /7pV6zNY6jDwtLEYxmWH1FJ1bNvI0/ecJa8I2sPTw7iaW1OIOshUjh2NB7bKLiWAkv44 j9ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KjXKCqIP; 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 w1si6989521otl.7.2020.03.22.10.51.52; Sun, 22 Mar 2020 10:52:04 -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=KjXKCqIP; 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 S1727124AbgCVRuT (ORCPT + 99 others); Sun, 22 Mar 2020 13:50:19 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:51101 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727103AbgCVRuR (ORCPT ); Sun, 22 Mar 2020 13:50:17 -0400 Received: by mail-pj1-f66.google.com with SMTP id v13so5016748pjb.0; Sun, 22 Mar 2020 10:50:16 -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=+KK3Ro2FLwCDE/TwXjj4wqViR4KSXhk4w82GFr36fy4=; b=KjXKCqIPvUSlSTFndLJj/ygE3t+yMKnldDlXqXrdjnGEyAnIY6v1PposD3DYeRRpDa fhwijHMJaE1Lt16cooebo9YTytFz4iVy2MzW8/WUeWVQCi0ghawsdSAY8KfGqxRdUwNH RRSTfOWyJYvOaHvygxoibRWzvNx8XQlLoRA8+iU4vWK6hiXMVrZyJOQWpnHpNnrVPVO/ WjvyMLzA0IIcfHchdPCZG7tdQbkoFEJs9v7K40UXBes8ZSJ1WZGpGGqUPGYh/Qdfo7rL IchSHNxEW4RsqbrDK/B31bf1peAkPcEQzbYMhHvzRfjteTzi1nf6jkJBpm2+nx94DhZh q4qg== 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=+KK3Ro2FLwCDE/TwXjj4wqViR4KSXhk4w82GFr36fy4=; b=ECUgVizKcAMOuKOoaLx3po4acwd/JnGlatzcDUComK8FWjJQPsjVTuOp8TdGwcJFdj 0+K0bddv5GlUfd0qaVguQN8dpcsDUi9t4ZTPYOdN0Syu5n3TWsPUQWoyqu0bs9orv+8N jU7+2gbXakVBqTWyATgVbDfk4MFE7V/QiXuZoVU75OUHPuEr2LKXMW8tphJ0slZ7zTjL 9Q39ba30VeV5t+juN9FaLkZGVxvOrpMbZXzLcKZKG8A8VzBa8UaQQ3dp3wcSCFiSCNG3 +JJrnj0C86UlDJMefVGoefwil8AnGjcoog58ryAsrULaW/F6OsQWF0E3i+bgaQCALZlO MNYQ== X-Gm-Message-State: ANhLgQ0+mA7bz51Dkl3JRErxlEBewnulBGXM3CCejrFVlEjvMu9Ecwha AZWpqzrVi27dCTLbWyGlt64= X-Received: by 2002:a17:902:82c5:: with SMTP id u5mr1947470plz.254.1584899416291; Sun, 22 Mar 2020 10:50:16 -0700 (PDT) Received: from localhost ([216.24.188.11]) by smtp.gmail.com with ESMTPSA id t3sm4609244pfl.26.2020.03.22.10.50.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Mar 2020 10:50:15 -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 06/10] net: phy: marvell10g: use phy_read_mmd_poll_timeout() to simplify the code Date: Mon, 23 Mar 2020 01:49:39 +0800 Message-Id: <20200322174943.26332-7-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_mmd_poll_timeout() to replace the poll codes for simplify mv3310_reset() function. it should be add msleep(5) before call phy_read_mmd_poll_timeout() to keep the code more similar, but it will report that warning, so modify it to msleep(20). ./scripts/checkpatch.pl v5-0006-net-phy-marvell10g-use-phy_read_mmd_poll_timeout-.patch WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.rst #41: FILE: drivers/net/phy/marvell10g.c:251: + msleep(5); Suggested-by: Andrew Lunn Signed-off-by: Dejin Zheng --- v4 -> v5: - add msleep() to before call phy_read_mmd_poll_timeout() to keep the code more similar. v3 -> v4: - add this patch by Andrew's suggestion. Thanks Andrew! drivers/net/phy/marvell10g.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c index 7e05b92504f0..c0fb8391c75b 100644 --- a/drivers/net/phy/marvell10g.c +++ b/drivers/net/phy/marvell10g.c @@ -241,22 +241,18 @@ static int mv3310_power_up(struct phy_device *phydev) static int mv3310_reset(struct phy_device *phydev, u32 unit) { - int retries, val, err; + int val, err; err = phy_modify_mmd(phydev, MDIO_MMD_PCS, unit + MDIO_CTRL1, MDIO_CTRL1_RESET, MDIO_CTRL1_RESET); if (err < 0) return err; - retries = 20; - do { - msleep(5); - val = phy_read_mmd(phydev, MDIO_MMD_PCS, unit + MDIO_CTRL1); - if (val < 0) - return val; - } while (val & MDIO_CTRL1_RESET && --retries); - - return val & MDIO_CTRL1_RESET ? -ETIMEDOUT : 0; + msleep(20); + return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_PCS, + unit + MDIO_CTRL1, val, + !(val & MDIO_CTRL1_RESET), + 5000, 80000); } static int mv3310_get_edpd(struct phy_device *phydev, u16 *edpd) -- 2.25.0