From patchwork Wed Dec 13 22:27:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 13491945 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="CV6RDYag" Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A84491 for ; Wed, 13 Dec 2023 14:27:56 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-28a5d0ebf1fso28238a91.0 for ; Wed, 13 Dec 2023 14:27:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1702506475; x=1703111275; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=iOLSB4d2eUew+8wfbH+tCKAZ+lf2yLoPsmG8Grblrxg=; b=CV6RDYag9/+/zIluPP3PAWNiPLFwdreFLiI3v5DbK2UQ99YLKuhrqomdcF1SlI2MUj 5WmaQb3dftps707QlyKtHu40rX6wU9WbCsCJqG6TCtdnS5NCj6BxP6S8ligtdNaBmeRT 8Ouo8jG7kjfNrwY1wxRxFaT6mKjxybWR8eIoY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702506475; x=1703111275; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iOLSB4d2eUew+8wfbH+tCKAZ+lf2yLoPsmG8Grblrxg=; b=K8xXEwiMl4PQbMFAPYz6Wjg+l8mYxCkhb1bZWdIMt/CulvENN+e8150MFZ4lMRAp3j /KVHx9+MCCG/ws8nuyJ8PKToPpCOPVBbinP+IvBPHNR0huJ7XGpF4pZLCXMJM2nBgLfn Qe0AixhDjT0G/Z20YfpMVffoSyCJUALLqlNfvDLSFLGSwzfOPqYjjNDLVty7211qics0 tBdsF+BJwDXQE+Mf7yELiH55J0VlV1xFk1fI+5lqDo8ommkrdakY8JI4RsJPmwwsNZoC SCWOo/PNtztlC6IegEenlcREOvITNcklxwv3uvWQON5srUW9Ga9XGyfQt7ST1Gek9mw/ sPew== X-Gm-Message-State: AOJu0YzoCkpI55vcYQoMncYMhxlZ6pk3gI5sQpIo7g63Y4WTLhhmtZ4b q3gYHljDKLf6LV/GvZicn4582VGxUUCghGJb2zMEJkDqGjnnbkma4k4G3XX5xAjj/bfwLaRKzmp AEakJDXeanrYlQM20HwGa+KVaD3dSa1VzF/L+0i2RysJA+dtIHX5u1Nw0xzQoi3+1TOpFA0id95 KHTF8xNg== X-Google-Smtp-Source: AGHT+IGLNz8wLTY4PXp+C23aDTr5gX7eNlU9NFOHbTBTgdL/K1IFu7wXBCAY9UVxTAEV7J5pluIacQ== X-Received: by 2002:a17:90a:c695:b0:28a:e68c:b268 with SMTP id n21-20020a17090ac69500b0028ae68cb268mr2058621pjt.46.1702506475331; Wed, 13 Dec 2023 14:27:55 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id nc4-20020a17090b37c400b00285545ac9d2sm11432515pjb.47.2023.12.13.14.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 14:27:54 -0800 (PST) From: Justin Chen To: netdev@vger.kernel.org Cc: opendmb@gmail.com, florian.fainelli@broadcom.com, bcm-kernel-feedback-list@broadcom.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Justin Chen Subject: [PATCH net v2 2/2] net: mdio: mdio-bcm-unimac: Use read_poll_timeout Date: Wed, 13 Dec 2023 14:27:44 -0800 Message-Id: <20231213222744.2891184-3-justin.chen@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231213222744.2891184-1-justin.chen@broadcom.com> References: <20231213222744.2891184-1-justin.chen@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Simplify the code by using read_poll_timeout(). Signed-off-by: Justin Chen Reviewed-by: Andrew Lunn --- drivers/net/mdio/mdio-bcm-unimac.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c index 297ea4a58d79..68f8ee0ec8ba 100644 --- a/drivers/net/mdio/mdio-bcm-unimac.c +++ b/drivers/net/mdio/mdio-bcm-unimac.c @@ -73,15 +73,10 @@ static inline void unimac_mdio_start(struct unimac_mdio_priv *priv) unimac_mdio_writel(priv, reg, MDIO_CMD); } -static inline unsigned int unimac_mdio_busy(struct unimac_mdio_priv *priv) -{ - return unimac_mdio_readl(priv, MDIO_CMD) & MDIO_START_BUSY; -} - static int unimac_mdio_poll(void *wait_func_data) { struct unimac_mdio_priv *priv = wait_func_data; - unsigned int timeout = 100; + u32 val; /* * C22 transactions should take ~25 usec, will need to adjust @@ -89,14 +84,8 @@ static int unimac_mdio_poll(void *wait_func_data) */ udelay(30); - do { - if (!unimac_mdio_busy(priv)) - return 0; - - usleep_range(1000, 2000); - } while (--timeout); - - return -ETIMEDOUT; + return read_poll_timeout(unimac_mdio_readl, val, !(val & MDIO_START_BUSY), + 2000, 100000, false, priv, MDIO_CMD); } static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg)