Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3264442ybb; Sun, 22 Mar 2020 19:58:31 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtfq0ABsDwzydmfzm8eATEgQ4EqhruAoU28Fd+2CHEbPX3pmCDNQ3zrmVPgfhQSTnG/wL/U X-Received: by 2002:aca:b308:: with SMTP id c8mr14697572oif.131.1584932311360; Sun, 22 Mar 2020 19:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584932311; cv=none; d=google.com; s=arc-20160816; b=wRgYkimq/6fIlt2G952GunjAP29bm9bhcB/8Rktj+o7WTVBoB7CiK/sjNH57FAuq3F OXc6syUg7EcEvJvmEq8OBd6UQXmfHedPW71CY+P3Uiqm3wwqC1rcJ6Cqhrm3ImsnH6i2 kdcKV6qnDCcAzoYG5Rbl3d0jBjRJcUDMmsuA+CeKWHkbCD8oeu/+EsUtdGhvdjss44Dv OeUtx0spYm5/QDQ25BC9pXvIDMLojRJNWK+9MW4soS5AOUvT5jtBpM/Rvpa6iz0GXt5+ De4jNBiN7S4QYka7WnGXHPpaj9bkvtXcvoC/34xtPrtnlXqwiTp6Fjwt4AdTD+YahAWG PvHg== 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=Wf+vH9t8xqDaM0zERvmm5OJNRuJUj0RTS8Tt8FdtJX0=; b=04o42bTch6mEOk+tC0vg9epZGaf5tIuPwknurgQG/9vFAQJAsAesxU/3tSC3C/+ffF Yv1lwXM6sXZb1OP3djb1BR0Z3LknIVgqL41xPSDfqifB+fkbswD7IkVZjR6+IanH1wyf Gnc0wlQqLqv8ZvwRCPzlKkEEMNpuSrP2XaJaBZQbwqwaN1SZA63w2jLQzKHXc9/RxQPD oszIAvaFS49gLJrssfx+/sh5ba74mNbCRqvni6/92QkPaVoocbu44RBpYq7fmv74HM1M 5afLOAjBzwEsLCJ1XLnkNpNqPrbNW1kOtoT/HJ1eMXA0Qb2daFDTI11jBpHRizsq38b/ U6rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NUV78+bd; 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 h203si6631228oif.3.2020.03.22.19.58.19; Sun, 22 Mar 2020 19:58: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=NUV78+bd; 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 S1727277AbgCWC5a (ORCPT + 99 others); Sun, 22 Mar 2020 22:57:30 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46162 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726983AbgCWC53 (ORCPT ); Sun, 22 Mar 2020 22:57:29 -0400 Received: by mail-pl1-f195.google.com with SMTP id r3so5276497pls.13; Sun, 22 Mar 2020 19:57:28 -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=Wf+vH9t8xqDaM0zERvmm5OJNRuJUj0RTS8Tt8FdtJX0=; b=NUV78+bdWs2ov2/LGKno5Gr3IKthQJ2brX6ImVASTAXbJWAaVYWXspxpnTYXdOiQu7 tYd88j7LNd6RaN/SMoGOQPkNZo05fF+QQsi6N3pVZ+uSc4NSkrF22UPnW34Ak4qF9vfD +pwcoIPUBdf70gDYpm/Jml5ny0fzgXG/sOgYl7jCPinrjRwIehEIU4M3WqL/CbTvDirv 8/UeskC0pSiXQV6tH6GSJuQ1Ud0LIL+E3D1micygksIQhVjDsWhIQHGCP7GW05JBePwb mbjPy3s9JKPd806LdoMMKNrDSChmquTdOHrnsRY3QQYYV/+Bk/yHhvIXlk309BfYesJD xodA== 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=Wf+vH9t8xqDaM0zERvmm5OJNRuJUj0RTS8Tt8FdtJX0=; b=gld0wI/FdAhHMvrcHPNYXUleCvyLAwh3RQvb5gVRWFWV5ILfuiiZmza7J3wCpXj/XO 9dWHE3BeSaGm+MXZd4tQj/Y0DnPeVaRSBf3J1iZhSoSHKYr8k+dKHP51hnfkdf0svLEs CmBnab2/ytvUkbIKmiNpEnEsy2ldGzaBFvpL+3b8xnylmTV1w2KWVVvxJFccpBiQ+uSC yWRtd5AADfN5deQaPIDnmEl1QPCoSSTRbw10x7Dl2uf02Se6LlLA/M2BquoXcLnj6Xmc EMZPvDDi3Ey3Qzsj0y3sbBhLrFRYXn1W/VoBe+dpm86TIVhZIq/dUne3Ir/dhM4bJpVx caug== X-Gm-Message-State: ANhLgQ1ZJ9EOck5E2Fp1iWv4hXpn5WOEKEEc/gi4GnRdAz3ABFwKVwqm ETLjENJc3YzZ2eCCUs9x/NhLUBpH X-Received: by 2002:a17:90a:a484:: with SMTP id z4mr6008122pjp.77.1584932247774; Sun, 22 Mar 2020 19:57:27 -0700 (PDT) Received: from localhost (104.128.80.227.16clouds.com. [104.128.80.227]) by smtp.gmail.com with ESMTPSA id l2sm10696030pjn.27.2020.03.22.19.57.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Mar 2020 19:57:27 -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 06/10] net: phy: marvell10g: use phy_read_mmd_poll_timeout() to simplify the code Date: Mon, 23 Mar 2020 10:56:29 +0800 Message-Id: <20200323025633.6069-7-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 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 --- v5 -> v6: - no changed. 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