From patchwork Sun Sep 1 18:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13786573 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 37246C54FC6 for ; Sun, 1 Sep 2024 18:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OPHrMKxx9pfIHj+K7xvNaPqq9ZKwdyRmGVqNHm7Hyk0=; b=NOQG7NqZ3fca66 F6YVPHCGUZT+acpipwtXc0riren8M4UIEY7NbIIcj27WNnf4S4HJuV1Ngu8oiyQu9bD6lF++N7iSV UBA97/cGwWiQNB9ExHOvKKSWieF5XV5K92wTShqj0t0bwbFNRGV+bN4jOLoKLv09YcTFA0nccc7Zl W6PibOHUz0FcQuwPF1T52Il3rrNCxCDvLnzpl378Zkn8tya9hUYE9mTkAw+ESnRbNEfWx+MjQ41x7 CI0TTT0eOIsYlb8h2z38ZF9cC6b0Oh0qYLApQ5nPEYf/iMhkfYANYMPD1f4YEMhlOl/EO+aSeAbU1 6MQRippIMEgjYiSGmukw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skpRB-0000000C8qG-3Ui6; Sun, 01 Sep 2024 18:36:33 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skpOn-0000000C8JM-2O7l; Sun, 01 Sep 2024 18:34:06 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2055a3f80a4so4206035ad.2; Sun, 01 Sep 2024 11:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725215644; x=1725820444; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cs7r7/Zx+L7jgSgyX/lH7TsYQ/OmfRm7Q2KA/O4kFP4=; b=Lb9FS/V60JK6kbHS1OLWDO5RHdA+ppivd+CQlouDFpFbUmqB9EltIQzmP15wGzCFRk sD8IIoA4aGu3y7awpoyESz1FNvLxWBGbWphw8c7xZ7WKE6CVAIoFGM5veX7iGhUdPTkG iH66XOp3ghlEsoFoiZpxt6mXCa4HjZAVfnk+z/5Iw03Sa6bvzr7OEvXj1600vXxGaBDH WRaABGNSjF9OBa4zNOHB4iGWFlOwgwMuY+bx/84DNvB+vNrq+kS5SswikrFjO5G5DLu7 /6xIJ8Nxydh+ERk391zr/B2tcRFcHTtfUgZ6iL3V0QhHDN9yATAf5ca+Tx3noA1i5Xwx rTAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725215644; x=1725820444; h=content-transfer-encoding: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=Cs7r7/Zx+L7jgSgyX/lH7TsYQ/OmfRm7Q2KA/O4kFP4=; b=oXJaU+Ejzqxh/bkVBIGstYWY9nxBjZFFWsLCQw7elDB4zkuExWnBHmapaH4bo3CHTJ fKRCh53KLttCihPp5cmC/HSY98qaFKYkwvLAkD7RrD2Gv+HBz2eyEcROAZVE/fIpDvR9 0r5/9D7mT4tcoa1ZsoSHKn2DbNmc4OzkdKPuArrt8AnjaWePPgk6tHeP6SYKu06OYYJO Sl2nDRS/R/fTyhVMZ3LXaxGNG2oUU1VcLAEiEGEavAX0T9ellNNDIvm4Ih/JmOuWdLE4 SC2zQnFGIo9jWLAa50F3n7jpI7Awn9byqNfcEmdHhckawwf1aLBzMkwNKOJ2arqQGYV9 ZAaw== X-Forwarded-Encrypted: i=1; AJvYcCX4HG3+CN1Y5dMs19/U8tM1AW0ND1n15//fxgEAvVA2OYQfKSkvS4EJpj3GlK1vuDXrV3b8ldItuSGTm55AtrY=@lists.infradead.org, AJvYcCXMZJ4nShbBvmph2vPDGK5rTKKNR40aBygY9azMOrDFF0IsBP3K2qHkTXpPSI1tv25xvXNoGYucvcpj@lists.infradead.org, AJvYcCXg50vRwqyplMb7YGTxMIVLXlTwkTTSeckYbCe7z5mqauCfjRviYsOwU6ERFPSHLujbapqU9K/4zZrOmoq+0mCY@lists.infradead.org X-Gm-Message-State: AOJu0YykIGOz7j+cuJry0mv+zzhAKGBuB1PQDCZNNm22lOIzqihjkbcG jrLe8dMyIwbmb0s4FVc6StupZwUxoCsnMVBcaUONe2BB4yCKCh5C X-Google-Smtp-Source: AGHT+IEC1rG0a4oSqwPB+FBRd7vgpBdtvMr3n/IBlgrouflEoKepJ4FUNU7icdPjsa6KdeQlrynBGw== X-Received: by 2002:a17:902:ec81:b0:201:efe7:cafc with SMTP id d9443c01a7336-205444fc15fmr66090815ad.23.1725215644468; Sun, 01 Sep 2024 11:34:04 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.222]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20559b793f8sm16262405ad.15.2024.09.01.11.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2024 11:34:04 -0700 (PDT) From: Anand Moon To: Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner Cc: Anand Moon , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/6] phy: rockchip-pcie: Simplify error handling with dev_err_probe() Date: Mon, 2 Sep 2024 00:02:11 +0530 Message-ID: <20240901183221.240361-5-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240901183221.240361-1-linux.amoon@gmail.com> References: <20240901183221.240361-1-linux.amoon@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240901_113405_628807_39B28654 X-CRM114-Status: GOOD ( 14.19 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Use the dev_err_probe() helper to simplify error handling during probe. This also handle scenario, when -EDEFER is returned and useless error is printed. Signed-off-by: Anand Moon --- v5: New patch in this series --- drivers/phy/rockchip/phy-rockchip-pcie.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c index 51cc5ece0e63..51e636a1ce33 100644 --- a/drivers/phy/rockchip/phy-rockchip-pcie.c +++ b/drivers/phy/rockchip/phy-rockchip-pcie.c @@ -371,12 +371,9 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev) mutex_init(&rk_phy->pcie_mutex); rk_phy->phy_rst = devm_reset_control_get(dev, "phy"); - if (IS_ERR(rk_phy->phy_rst)) { - if (PTR_ERR(rk_phy->phy_rst) != -EPROBE_DEFER) - dev_err(dev, - "missing phy property for reset controller\n"); - return PTR_ERR(rk_phy->phy_rst); - } + if (IS_ERR(rk_phy->phy_rst)) + return dev_err_probe(&pdev->dev, PTR_ERR(rk_phy->phy_rst), + "missing phy property for reset controller\n"); rk_phy->clk_pciephy_ref = devm_clk_get(dev, "refclk"); if (IS_ERR(rk_phy->clk_pciephy_ref)) { From patchwork Sun Sep 1 18:32:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13786574 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 EEBC7C54FC6 for ; Sun, 1 Sep 2024 18:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sP/yOLGfDIf0ieF8IbThaDjX1OGr3TGnVC3IGSPQTrE=; b=OcJHGoIx5ufg8/ Khe9JfqsljUTjYfZ/CIg6Yi5tI88A86kkQa5hz//lVL0dyMEz75sUAYq6qpKtcDtBte1PnXARhqN3 gD+cuNeE2uh6tGXTjUjpva3+6EAqtry49M71ktDkOmAeu06ZZPN0BuB+uwVK4strhx5lPO8ZwZ4Ix KVovyAQMNe69xaTvINty9Epo+ZNstUz47whTEEfaGMV+5yX3diSu+9CLNa3N89rq2pLu0O5XzJDOZ xjeRzOFLv27yTkAPnkUY63UJM3D3oKYGxkFtXXt2IOGm5AW0kEuNzCvG0ZBx+WAaQQn2WFp2ZQdvd WkLiGE/k61rFeXHxCV0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skpS2-0000000C8xI-2NTf; Sun, 01 Sep 2024 18:37:26 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skpOr-0000000C8Ka-3BLT; Sun, 01 Sep 2024 18:34:11 +0000 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-7cd8c8b07fbso1234215a12.3; Sun, 01 Sep 2024 11:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725215649; x=1725820449; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W1OZckweW5Fso4kEkpFhONlk2Rygt1dqEGGEL98qz2s=; b=QX234dMNEQr7jFXgxHzvnmHhYk+OcCy7YaPogBWF7qboOiYDy+8NK2Rwp0MK3mOMGY mppZZNKT3fZW7KzsgQXfObQP7liDbHp9nNylsXuhtYHtvBfXbEsVIea9pNWM3+APmIg1 XMixDmgDKiEvOGI8FxHTwOgJic2VBuFhfY7PyLVkfPTDl436BYpadXfrK2KkZq+7Hq6C GYAb5gavX2ZSTGyIsTwOyZD/V5YVlYjYceYf/1GlKReqz4GYY2N9KDVyGbuelw+Lk0kJ lXPtlkkKgMBQh01PRj9SQ/FTxJCTQfs4L8wtu3mpJJkSxyTuHKZAFCrSdONi38lR3Cb3 T33w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725215649; x=1725820449; h=content-transfer-encoding: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=W1OZckweW5Fso4kEkpFhONlk2Rygt1dqEGGEL98qz2s=; b=O8LGpCS4cTEM5eLO096cEQoDS+RNZgfWdn9kGQrA6L8B8oABtQ1nRLLMBMpob51wa9 8fqBLPvKZtsk8gx9mKoStahghzEw3w8oH81lb5+W835IwR81VxDQjJbjeVt6DYcPwDN8 2nrxTrKJ/oA1oF9K7dO2olZLUeloxZ8yOXhOlCIPamghn7QLclYG8CYHdsxCNoCgovOQ DMS2co+6eSGEzYZp96qg93DbIEy9k8PLhGwxr5pabQPUISbxwa1PgIlFVVuYppLo8+/i p/EyKoh2yDUUsR+Dpn/DM7R/9Xx3eLvT7i8TjFNqznDEyJvjn3gkRN3ZeydS+YziNKtM c/7Q== X-Forwarded-Encrypted: i=1; AJvYcCUwkHB9lUQAngZCjOWOVeEEMpAmBuM5Rbyd8+6EI2S5gekn6H9vtcpS8wCTglcT2VEXWSUv5ZUs//Cv9C1M8Ew=@lists.infradead.org, AJvYcCVz/o4FWfU/J2uYx9Rak7BgyPN0YSAmwVGKwiyZ39IkA7/zi2iSl7wmsER8NsLfCe++ruyjv0gnLy0d@lists.infradead.org, AJvYcCXRwE4QzQFF0lf153xoHblncaiIhWYtB1UqowGhgUN6C6gs4u+ywlaI6EBUnxZwz+7xA5yAK5iGMk0lcAC8ETAa@lists.infradead.org X-Gm-Message-State: AOJu0Yw6UZt6ie9D0G1FH+rLcLbNEYO0ASdYhCj9kZXVOierMnWNSd3k Svm208KmFaGTOEKAaFRNkfidJ6SZCpF8CV7tc4BDSJDh8uW0pnRE X-Google-Smtp-Source: AGHT+IFqD4cq32sJgonIzbTceZ/6isHD9h4Ev1uaZFsEW7Xxuog+FeUhQLuaeZwURmm3Ht2J2S2xow== X-Received: by 2002:a17:903:22c4:b0:202:13b0:f8d2 with SMTP id d9443c01a7336-2058422304dmr187195ad.46.1725215648617; Sun, 01 Sep 2024 11:34:08 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.222]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20559b793f8sm16262405ad.15.2024.09.01.11.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2024 11:34:08 -0700 (PDT) From: Anand Moon To: Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner Cc: Anand Moon , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 5/6] phy: rockchip-pcie: Change to use devm_clk_get_enabled() helper Date: Mon, 2 Sep 2024 00:02:12 +0530 Message-ID: <20240901183221.240361-6-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240901183221.240361-1-linux.amoon@gmail.com> References: <20240901183221.240361-1-linux.amoon@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240901_113409_817578_C5ACCB4F X-CRM114-Status: GOOD ( 15.87 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Use devm_clk_get_enabled() instead of devm_clk_get() to make the code cleaner and avoid calling clk_disable_unprepare(), as this is exactly what this function does. Use the dev_err_probe() helper to simplify error handling during probe. Signed-off-by: Anand Moon --- v5: New patch in this series --- drivers/phy/rockchip/phy-rockchip-pcie.c | 25 ++++++------------------ 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c index 51e636a1ce33..a1b4b0323e9d 100644 --- a/drivers/phy/rockchip/phy-rockchip-pcie.c +++ b/drivers/phy/rockchip/phy-rockchip-pcie.c @@ -277,26 +277,16 @@ static int rockchip_pcie_phy_init(struct phy *phy) if (rk_phy->init_cnt++) goto err_out; - err = clk_prepare_enable(rk_phy->clk_pciephy_ref); - if (err) { - dev_err(&phy->dev, "Fail to enable pcie ref clock.\n"); - goto err_refclk; - } - err = reset_control_assert(rk_phy->phy_rst); if (err) { dev_err(&phy->dev, "assert phy_rst err %d\n", err); - goto err_reset; + goto err_out; } -err_out: mutex_unlock(&rk_phy->pcie_mutex); return 0; -err_reset: - - clk_disable_unprepare(rk_phy->clk_pciephy_ref); -err_refclk: +err_out: rk_phy->init_cnt--; mutex_unlock(&rk_phy->pcie_mutex); return err; @@ -312,8 +302,6 @@ static int rockchip_pcie_phy_exit(struct phy *phy) if (--rk_phy->init_cnt) goto err_init_cnt; - clk_disable_unprepare(rk_phy->clk_pciephy_ref); - err_init_cnt: mutex_unlock(&rk_phy->pcie_mutex); return 0; @@ -375,11 +363,10 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(rk_phy->phy_rst), "missing phy property for reset controller\n"); - rk_phy->clk_pciephy_ref = devm_clk_get(dev, "refclk"); - if (IS_ERR(rk_phy->clk_pciephy_ref)) { - dev_err(dev, "refclk not found.\n"); - return PTR_ERR(rk_phy->clk_pciephy_ref); - } + rk_phy->clk_pciephy_ref = devm_clk_get_enabled(dev, "refclk"); + if (IS_ERR(rk_phy->clk_pciephy_ref)) + return dev_err_probe(&pdev->dev, PTR_ERR(rk_phy->clk_pciephy_ref), + "failed to get phyclk\n"); /* parse #phy-cells to see if it's legacy PHY model */ if (of_property_read_u32(dev->of_node, "#phy-cells", &phy_num)) From patchwork Sun Sep 1 18:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13786581 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 27C58C54FC6 for ; Sun, 1 Sep 2024 18:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jQ2BXVeXf7pOBw00ZSLN+IV32fxBDMur6q3HV/fbHHQ=; b=Dlle/El8Q6KUSA ZfP4q5XXAAvubkuVN/ukRosFP8Ujd7nQ+CJDRWXZoHqeQczZNYO5/s6LwBiLWUeEx1YllH7uQo9Hc uWjawvrFmiXnxy4LhlyRmcn1QTYjMOqqHT1STSZ63fYjKqCYbHioKIuP67ipe7/wBTVKvXbcnWX8F 9G8Ez+avdZ5y0pJaj3uhwg/Dx1wEtaB1LnyG/Fy6kGdkTkeRiXccF8bkuOwxrMWgHAfeRmYuurvUS 0nWJtYWdBgvY+m17TSM9IwAsDrHK+WIykSQxJJSfy3NPSOA7pzMFOtbIXJcy7ZJz6ZqBmUILubWAp AVG6LfrGAttkwD0kyJ1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skpSs-0000000C96G-3KJq; Sun, 01 Sep 2024 18:38:18 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skpOw-0000000C8MI-3rWR; Sun, 01 Sep 2024 18:34:16 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-20551e2f1f8so7970965ad.2; Sun, 01 Sep 2024 11:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725215654; x=1725820454; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VLCyRC657hgOtTBOAgAwcacwSzgshdziSy5VI8t2Gq0=; b=N+ibu1wqR5m/JbmcN9Mm8LqitngXtOvc4j1NV88X9MhWf2Vl79FrlKjy5aUycrBNwY 250KYXph8wEVGqrI/87eCGxyxw+C3zMlQoULwcmoEtF+robHSlugTMomEzordyKfSozs IAK3bCBtYcDzPELN9o640z529Q0SFggfgn2Xb8M0xfO4s3jrmTlPTULofKO1bjLaAUXt 1hiQt8kc+rnyPQ1orxBB/S0b9ghbT8ViUnctirmCntgaM2a/Tx7QmLaU0pJPF+UdlT6u w2E2PN0ygJoz1yHh5Hq6tSgcJeXhIM9ZhpcHSvtRrNaD//jCICfVJmWWS5fx7ZA+TZdn 1fsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725215654; x=1725820454; h=content-transfer-encoding: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=VLCyRC657hgOtTBOAgAwcacwSzgshdziSy5VI8t2Gq0=; b=Swl65DxCnbsALS2bLAAALM9/ZkcYMaPqG44K45bwCC1Wh0sn6izRV43HpJYBSBGZ5b paZL1Ecupe7VX7047bMtv8stKmY0Nmt9PT9UaN5BP+XetYg5zboLTJYpVmwUnMqyxEkv XmKAtndhvGihgCsUhBVObi3pJ2iihh17AOHn8RmsFdsfpxuD9RLvNQmu/njxHRrmiXpa w9GL8d1vr2WkVmVDWmFuDKE7Twstq2RB8ivzKeDAWIBEf3kUCWgxqcsYDcniZ9kMAq9q PAq8mJGs3m4dEerLXEwOpjDp7qSC3sJfC1j1i0/LDtXlGDPBM9ARy1FLk/VGMBr/KHRn 4JXQ== X-Forwarded-Encrypted: i=1; AJvYcCUEQ1wueve5XaPz2FLPhd05xrqKTt4x8zwHKiIAf9/BSvm6zK2VvVa1TXFcuuPvy/ZgxVQWgjCKx4SXgTlNIp0=@lists.infradead.org, AJvYcCUa/WjrKwJm8aQUfXTR4qbLcEqhjZ6pkdnXPrpMLTkj1PM2+NC0b3hs4a97GMp2m0a5xWHSgkpE66g2eYMP8Ke6@lists.infradead.org, AJvYcCXx64MVvGBWN7HFFhLQOHQucW1G9NzW8qCCAadwP3///wLgQcHgM+P5Bjo6ebzVNetJhQeyPNoK/8dj@lists.infradead.org X-Gm-Message-State: AOJu0YwPv2mwVzxhZs70/dtsKq+6SZWQ5medtLmvUaXPLvX7HdQo1r1N mevlnvdprPKnv2r2DvrNNddyQeEKWrOKmN23qcSI22v/SbpqaDJw X-Google-Smtp-Source: AGHT+IE0DF0h8dNkgogZ/U5Ym66OZuvgg8ZiSDLJNUPCI1HaXLR9hpfBmfxTQjfDGWPLFLoNSdDjfw== X-Received: by 2002:a17:902:ced2:b0:1fd:791d:1437 with SMTP id d9443c01a7336-2058417b1d9mr426515ad.6.1725215653750; Sun, 01 Sep 2024 11:34:13 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.222]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20559b793f8sm16262405ad.15.2024.09.01.11.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Sep 2024 11:34:13 -0700 (PDT) From: Anand Moon To: Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner Cc: Anand Moon , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 6/6] phy: rockchip-pcie: Use regmap_read_poll_timeout for PCIe reference clk PLL status Date: Mon, 2 Sep 2024 00:02:13 +0530 Message-ID: <20240901183221.240361-7-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240901183221.240361-1-linux.amoon@gmail.com> References: <20240901183221.240361-1-linux.amoon@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240901_113415_063796_A717D6BD X-CRM114-Status: GOOD ( 13.12 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Replace open-coded phy PCIe reference clk PLL status polling with regmap_read_poll_timeout API. This change simplifies the code without altering functionality. Signed-off-by: Anand Moon --- v5: New patch in this seriese --- drivers/phy/rockchip/phy-rockchip-pcie.c | 56 +++++++----------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c index a1b4b0323e9d..2c4d6f68f02a 100644 --- a/drivers/phy/rockchip/phy-rockchip-pcie.c +++ b/drivers/phy/rockchip/phy-rockchip-pcie.c @@ -162,7 +162,6 @@ static int rockchip_pcie_phy_power_on(struct phy *phy) struct rockchip_pcie_phy *rk_phy = to_pcie_phy(inst); int err = 0; u32 status; - unsigned long timeout; mutex_lock(&rk_phy->pcie_mutex); @@ -191,21 +190,11 @@ static int rockchip_pcie_phy_power_on(struct phy *phy) * so we make it large enough here. And we use loop-break * method which should not be harmful. */ - timeout = jiffies + msecs_to_jiffies(1000); - - err = -EINVAL; - while (time_before(jiffies, timeout)) { - regmap_read(rk_phy->reg_base, - rk_phy->phy_data->pcie_status, - &status); - if (status & PHY_PLL_LOCKED) { - dev_dbg(&phy->dev, "pll locked!\n"); - err = 0; - break; - } - msleep(20); - } - + err = regmap_read_poll_timeout(rk_phy->reg_base, + rk_phy->phy_data->pcie_status, + status, + status & PHY_PLL_LOCKED, + 200, 100000); if (err) { dev_err(&phy->dev, "pll lock timeout!\n"); goto err_pll_lock; @@ -214,19 +203,11 @@ static int rockchip_pcie_phy_power_on(struct phy *phy) phy_wr_cfg(rk_phy, PHY_CFG_CLK_TEST, PHY_CFG_SEPE_RATE); phy_wr_cfg(rk_phy, PHY_CFG_CLK_SCC, PHY_CFG_PLL_100M); - err = -ETIMEDOUT; - while (time_before(jiffies, timeout)) { - regmap_read(rk_phy->reg_base, - rk_phy->phy_data->pcie_status, - &status); - if (!(status & PHY_PLL_OUTPUT)) { - dev_dbg(&phy->dev, "pll output enable done!\n"); - err = 0; - break; - } - msleep(20); - } - + err = regmap_read_poll_timeout(rk_phy->reg_base, + rk_phy->phy_data->pcie_status, + status, + !(status & PHY_PLL_OUTPUT), + 200, 100000); if (err) { dev_err(&phy->dev, "pll output enable timeout!\n"); goto err_pll_lock; @@ -236,19 +217,12 @@ static int rockchip_pcie_phy_power_on(struct phy *phy) HIWORD_UPDATE(PHY_CFG_PLL_LOCK, PHY_CFG_ADDR_MASK, PHY_CFG_ADDR_SHIFT)); - err = -EINVAL; - while (time_before(jiffies, timeout)) { - regmap_read(rk_phy->reg_base, - rk_phy->phy_data->pcie_status, - &status); - if (status & PHY_PLL_LOCKED) { - dev_dbg(&phy->dev, "pll relocked!\n"); - err = 0; - break; - } - msleep(20); - } + err = regmap_read_poll_timeout(rk_phy->reg_base, + rk_phy->phy_data->pcie_status, + status, + status & PHY_PLL_LOCKED, + 200, 100000); if (err) { dev_err(&phy->dev, "pll relock timeout!\n"); goto err_pll_lock;