From patchwork Fri Oct 4 10:21:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13822132 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B46B7CFA763 for ; Fri, 4 Oct 2024 10:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=btihpCL0vUh1N7+vGVV6qF1UsDzMDCL36GJO4Y2gy+Y=; b=BeZdkSlazIEdtZ38WY0yAObRd2 CZ4Z0LVZOocJyYQzUm6DNj/lcR6VuxTeqZyQoHWhS3t+sXIX7ltyFQBbqOp694buaXdY1jaGJF0tv iRdLyI5HZ/pkXuqyOwWeQ3BlnmhFdLgb2Iu8mV9G/vZlVBD0CPnwm9Dm9CE6jNjAEIrdkX49iYN0Q qXBP8KKK/Gks/KLlYOCIXAcY7dyCKLTRy9r7tVzNhS3wi3NFr/SkLYBH2w3yfAQjgw8VG3/gIPZtL oGaPXvrjiEvJRlqduMYPpjXh9USSgcTOIIDV5d/oVMMjtrSnDshOM+F4ifl6dPMEURVOnAZk26G/j FHNrHEcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swfds-0000000Bssy-2fFK; Fri, 04 Oct 2024 10:34:36 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swfRM-0000000Boul-2XSQ for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2024 10:21:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=btihpCL0vUh1N7+vGVV6qF1UsDzMDCL36GJO4Y2gy+Y=; b=wc6uvFeCMjSi9nKAvG9zyLmnnd /II+7rH8cSHKbjwufJqlw6rsxakwSrS9ApcP9Ua5y78fjLI90z9TDNVfTjXRk80o1uMOyOo1Vbf5a ZatVuK48pu0iCJFWJXn1WTOJ9TAGkgCR3+XNxkEFhhWdAaL5KVv2GGNWsxmEzFn4fmKYXcKqs2jDT 0FX2WCZaoIgdW0XQKZ1dv2BFr4cOF2qqn6iYgy2uj0UYoXOcvQftlSufFSJ1Uz40nidJK/ycPYM90 Y57hnv1qDrqeoEE5I4Yrn+/NXTtiDe1izFaOZDNN1sG3KPqmpvSiHrWeK2dA8IkErn5AtSJ6fGBJh K2hzJvEg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45040 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1swfRB-0001iW-2E; Fri, 04 Oct 2024 11:21:29 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1swfR9-006Dfs-Ee; Fri, 04 Oct 2024 11:21:27 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Alexandre Torgue , "David S. Miller" , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Jiawen Wu , Jose Abreu , Jose Abreu , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , Mengyuan Lou , netdev@vger.kernel.org, Paolo Abeni , Vladimir Oltean Subject: [PATCH net-next 10/13] net: pcs: xpcs: convert to use read_poll_timeout() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 04 Oct 2024 11:21:27 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241004_032140_679975_D4248C1F X-CRM114-Status: GOOD ( 11.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the xpcs driver to use read_poll_timeout() when waiting for reset to complete, rather than open-coding this. Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-xpcs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 5ac8262ac264..06a495135418 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -220,18 +220,15 @@ static int xpcs_modify_vpcs(struct dw_xpcs *xpcs, int reg, u16 mask, u16 val) static int xpcs_poll_reset(struct dw_xpcs *xpcs, int dev) { - /* Poll until the reset bit clears (50ms per retry == 0.6 sec) */ - unsigned int retries = 12; - int ret; + int ret, val; - do { - msleep(50); - ret = xpcs_read(xpcs, dev, MDIO_CTRL1); - if (ret < 0) - return ret; - } while (ret & MDIO_CTRL1_RESET && --retries); + ret = read_poll_timeout(xpcs_read, val, + val < 0 || !(val & MDIO_CTRL1_RESET), + 50000, 600000, true, xpcs, dev, MDIO_CTRL1); + if (val < 0) + ret = val; - return (ret & MDIO_CTRL1_RESET) ? -ETIMEDOUT : 0; + return ret; } static int xpcs_soft_reset(struct dw_xpcs *xpcs,