From patchwork Mon Oct 7 03:56:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13824000 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 1793BCFB43C for ; Mon, 7 Oct 2024 04:00: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=9EAvfIBbcCTdQBxhwCGKXwcKnxeHTSGRxlG79wfdik8=; b=27tleID85z9uJf gj6DFQjkrOBknJlxPa0KmgzS4ZM6Mtrj5URg4uIIUY945bMSsPkMmZUqr7kZrOcY4dcFLcc/4mB+8 wGgMf/4qRoln4MtJ7Lb5viYq0RKEcj+GEYhk5aUnabvxY3Y9Vvs9Zbivpv5DE8raJEiAP6wI/f9oj DTj1tTZJY8bAg0efSLgjRKhCW9h/JfGOQRBhoy5HgH1JWpbry2Wt6q3lfcG4sdcTxDktLqA2Df7TR uKPzQdb003vgCaUaVattVvp8BdqYKGEamZVPX9HoeXFNV6wdlm6gje3DlO70+5zrOVBSWsyEhFuZf CZNoZWWLHU1t4PAyrxpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxev8-00000001C3N-1mxY; Mon, 07 Oct 2024 04:00:30 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxerN-00000001BSm-33xP; Mon, 07 Oct 2024 03:56:39 +0000 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-6e7b121be30so2524126a12.1; Sun, 06 Oct 2024 20:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728273397; x=1728878197; 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=8xZ0sSFTRQLD8htIs0XMnH5FhNQDjNg6QCAysEVYUBQ=; b=b3lkhi5ypOtcA2A1ymdCh8ozva8dHpcLDRPY8mzpDE2bbYt+dATA/Zftw/sWUVNbbX 5OGDPzNzHab6oCWO9oZplQL4gZeNy645hCeBbBM7h1pQUBZujA7OXY1KKjs0fwD1TUl4 vD4FPQtDBEEv4cu+nSnkLtVPNrNgcFRE/OCdhwZ6wpouEzYN4iyf+PDSD4dx+LYQ4MUq 03i+OOhdMITAuKl33Idrpow3vK2K3jwDl1rLyCEQ8mRfpD+h5IdrvU8ypjURd85qqLUX zsT2IH1r5NlLukPT3DNpnSzE0WPQN7iPnu+0oY7xC6p8G7f/A3RcnnljQ20pzyMJrZpg Onaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728273397; x=1728878197; 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=8xZ0sSFTRQLD8htIs0XMnH5FhNQDjNg6QCAysEVYUBQ=; b=rLcJ0i0reyDitInjKbpZSevwlz4RI+dAWsEF4dbSOCdS7yE/nNxAS6kKFwblb2rLzO S49r8Upl33D/ysqyF2XA9uuMLauWKirMLzCk4c6omb2QdO7vV+fJ7rK4W90t9fpmGBIj YgA6ApoLTmoT+P2gY/69oO0FXGPZjTtz6Ss3LKvDT3Z/frsP/V6Zrcggt/r5zT+QCx7w bKcJVwF8Iln4TemG8ULxNvzJkjzzXsu0h3LVvcsRAceBStxjGVUpPe5e3HMuy/iESWJb BjjQx3s3csjT8x/XcX5Md1jjClqIarHqbmZaJI7ZpIoa2et1FBIfDxfq0TnKlcAIklAq tFRg== X-Forwarded-Encrypted: i=1; AJvYcCUVB6YihpQYIq1cvpme/b8AvduMj4g2UAvLsXfsvD696jdn+odcRsiRzpYTrpwTnzAB5ODYXkqYo9lV66QSYAY=@lists.infradead.org, AJvYcCWkzl3RPXPxqjhFPXifevAwCZSudkR+gKNB2YnZiRCKBOc+3PpwmoHl8o0GSEUOYU3V/alWWriZH0hq@lists.infradead.org, AJvYcCXrmefzg72R6HoCSjAq2tNUtj29AmlxPR6pzbzHz5IpeZPUf7h6+pYoXcrcfPFfWX2ZM+Xgqv6Tu8Hu/Ua8cSBO@lists.infradead.org X-Gm-Message-State: AOJu0YwsIzRi8kIFCvqAd/6TEPjgEGX8NCvaeKyB9Zblre+9jsAy291o wCDmGtFgR7FCjVCECljXHGJ3BPD7YbNvF1LeMFIGNa7HIutpuYxBqpxdBA== X-Google-Smtp-Source: AGHT+IGRbfQ8Ygsa7B/NPIUIYHPuPbH6Ec8dQH336nVKqtXQ6uAhYhVO9BVtb98LpLQywzEMyD5EiQ== X-Received: by 2002:a05:6a21:27a7:b0:1d6:f623:17ab with SMTP id adf61e73a8af0-1d6f62318a4mr5355559637.12.1728273396761; Sun, 06 Oct 2024 20:56:36 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0cbbac6sm3451322b3a.39.2024.10.06.20.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 20:56:36 -0700 (PDT) From: Anand Moon To: Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner , linux-phy@lists.infradead.org (open list:GENERIC PHY FRAMEWORK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC support), linux-kernel@vger.kernel.org (open list) Cc: Anand Moon Subject: [PATCH v2 1/3] phy: rockchip-pcie: Simplify error handling with dev_err_probe() Date: Mon, 7 Oct 2024 09:26:09 +0530 Message-ID: <20241007035616.2701-2-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241007035616.2701-1-linux.amoon@gmail.com> References: <20241007035616.2701-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-20241006_205637_795765_6B478B80 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=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 --- v2: None v1: None --- 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 Mon Oct 7 03:56:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13824001 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 CCD05CFB440 for ; Mon, 7 Oct 2024 04:01:49 +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=JuZxpaYQATTuOajnsE7+bszP6tvzR0wioLHGgxdv8fA=; b=4TR/3bpcdlcEn5 CjQ74sFBOMzbQvrqSRLITWCxCt2vuqdcN3HfZn0Rn+StwAJtvzJCpoBAd0lNUSRFAVymRLN742cUQ JN/pz5vuqzHDF3rNBoHLqf4SfBpRtvcXLzMT9IaDvjwFIOLHojnvbNTjE1z5PSYht7y7qG/3wk7sW rBPCMzxpEGbNDO5ChUt9jeQfu+KkEBdt4Kf8ENqQYWsCpodJq6GK4Trj3dIVbPx5ygMSUVyqF7BJe 7slhfC8m4GsDIXJJvdNAziy/07oDNleBUeTCG7fRCAK+IBel1YEAfnan5vesabDeOJZrLOYGmIWEp NEvY9FbfYeW+uWz1SqVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxewM-00000001CAz-2X8D; Mon, 07 Oct 2024 04:01:46 +0000 Received: from mail-yb1-xb2c.google.com ([2607:f8b0:4864:20::b2c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxerT-00000001BUD-0RHJ; Mon, 07 Oct 2024 03:56:45 +0000 Received: by mail-yb1-xb2c.google.com with SMTP id 3f1490d57ef6-e288efeb4feso3126389276.3; Sun, 06 Oct 2024 20:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728273402; x=1728878202; 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=G6eSRE8PNh/DxA4RdaK3Wt2RcDD9+iNYAeS9X6qJVfI=; b=XgTBlPLefLGzf0fI0lC/X2PmTgFKDyHEP7LpG8/zdOCtInXAtmPmQvKSfcooUzFdOG WuN/+GprQM3qT7CC1vJTPkt9+oeS0chv2pqbkRUhxH6Iq4d1WGeoQxE3FUs9ASfo7Wa0 TqFqDZ3mbTZ0nyZUVvOBtrL4mAW8k/0ScfrD7PagrYTHGDKQYf4vFqUjT//VzhIiZP9t razOGka9Ogk49l1tl3Ny4X8bOjLM9OpwWklQQs4LeHmFO5XePat4ZbByaMG9tIEGR4/E NcsiTkcViySoDoGbCuE7pAS/yoFEBHl4nA7h7JIuqnFptX3nu37s1qsDmSZSza/XWDAy N40A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728273402; x=1728878202; 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=G6eSRE8PNh/DxA4RdaK3Wt2RcDD9+iNYAeS9X6qJVfI=; b=tirZyvviGWjP34TqBEmZxPvH/fWbXkfkq+70mHBPnIsucAHd5n7Jdcw32lTqACyoJ7 lBmM7yg1MET1fnEXCZ2AFVWr1L9tUF/QxZZFFp8WGgx7uguJ099RIOuds7nO6/+B4GYD uQXjKesHVhMOEZEmRORNNWD1LeDv0BrrW0TWfqkb9MvTh3Dnl4KYgSUzIu7x+RoF9l/R 9UWa0JAmVvg5/48Vuqijtkjtc1tT02NPXcSizumqoP9SFmu6KcOjqxwASKQvMqSxIhRH Hg/CWP32NYqZ5DE+bIjmxaunNzelFWg99wR6FMSvy6CrjZLWwXx9VHCzadFWPj55ecpJ 0Gcw== X-Forwarded-Encrypted: i=1; AJvYcCWdLd8x3ZH0H6Nju1PDHxj3IuXiz2PQW+UHFGnb4GCCD+/lpc/8c09C4iWFw84n282e2b9jKqypqeRU@lists.infradead.org, AJvYcCWdeTvrQZKPnX2rCJxMpbOeHTuOLR+tiRO+u4KHwkOQ+xXx61GMPWZiRGqRI9JF6gBPJWvIcXxAeSgESnAp3mY=@lists.infradead.org, AJvYcCXV646AO081k3qQidmz7O/ISPxNlqUzH2g6qOahQ3/nIwGnHNMd6zenCUBDobBaYiFWy7SRgxxJNLP3FfBS6ZcU@lists.infradead.org X-Gm-Message-State: AOJu0Yx3G69LZB2/y5LtD385UwvBQxqKExVkxIaGIDDqu4QKfRbj2Zqt D5sNaPgtkyFUa2M/Ql5gapCDh2JC7r4gLyfPyNSjxsSfM1uCrMCm X-Google-Smtp-Source: AGHT+IHNeJw7Y38Do9bLCUY+sRwFyUhcdw/O9uY3zyz1MoVfAXMmNmgLF8VUGm8KzFOE0Mg1zPkztg== X-Received: by 2002:a05:6902:2192:b0:e28:68e8:ccc0 with SMTP id 3f1490d57ef6-e28936c62e1mr7534463276.11.1728273401633; Sun, 06 Oct 2024 20:56:41 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0cbbac6sm3451322b3a.39.2024.10.06.20.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 20:56:41 -0700 (PDT) From: Anand Moon To: Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner , linux-phy@lists.infradead.org (open list:GENERIC PHY FRAMEWORK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC support), linux-kernel@vger.kernel.org (open list) Cc: Anand Moon Subject: [PATCH v2 2/3] phy: rockchip-pcie: Use devm_clk_get_enabled() helper Date: Mon, 7 Oct 2024 09:26:10 +0530 Message-ID: <20241007035616.2701-3-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241007035616.2701-1-linux.amoon@gmail.com> References: <20241007035616.2701-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-20241006_205643_174287_9BA1A505 X-CRM114-Status: GOOD ( 15.58 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=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 --- v2: Change the subject drop: Change to use/Use v1: 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 Mon Oct 7 03:56: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: 13824002 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 A1E4BCFB43C for ; Mon, 7 Oct 2024 04:03:06 +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=oq/fe1V5yqrzv6GBgh6QELOg0fblPh46SOjGMEmcMjI=; b=bkXnikTAQfxGKd oTCLC3Wx0MOOaKYRnQoxIL3q0WadvF4532iGVh7zwF/ZsKR0M4kzVWCeq9TFRVA9ft07Zo2pY5xRM dNS6I+JEax6AVFg+n+biM5Cuw1MBFHa3AKCHf3Fb5D5F0DM2ktu7fLGux36JE7FVh1mzpCqc640ml 4zEw/wZawB9ZV7b58M3YJuMOWRbpQGsgmSiEjW5+g7sspc8QoFpKvDvW/iPvaicx4ARs92HerVn3M rzChsM2llkzw7epnVF79o6oylPwahl2d9mEMigd1Mo6kGU0lcAuBBdip+sFZEUh32ssV3GpaA/767 fjtYysQMfHZtVPWUVcCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxexa-00000001CIE-2zvZ; Mon, 07 Oct 2024 04:03:02 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxerX-00000001BWq-1lTs; Mon, 07 Oct 2024 03:56:48 +0000 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-656d8b346d2so2455113a12.2; Sun, 06 Oct 2024 20:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728273406; x=1728878206; 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=/Yl2K4EmUgHgFL47sO4eEWU/jT7JgMHndlEzcZuCb+c=; b=am1KgasQLu0/Ti9pLf8upaMBhvhs+Ymh+/mWknKyBmna15va0Gz9sb2bXVvwr5CRIh hYdziuFRePw3cd9Vl8xEO2gZ8mXkRn1vHvx9RMuOnk9dlqJr/lYmEPEY87e+8tJViGZY FNXBu5hojGBvsPYcX08duPtEVjhr8BadGLGq4YLLnDIFYpDNlYHL/DpwbwwURTGiKfd/ TzM5mB7S0g/bloqThb7SR5Z9+ZPs7203SqWx6D/5E8q5xtkYGGv6Xvx9MZa9O5ib102y JouZUR/Xp0viCbRTaGu1HqnYpBqv55eru8vpLoqLN9VFDX/icB1TLPH+IowAUJCSi4Ed IUhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728273406; x=1728878206; 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=/Yl2K4EmUgHgFL47sO4eEWU/jT7JgMHndlEzcZuCb+c=; b=EfPxUue/wJF5wH7wY4g90FA7Uci7viLG0d0v4cjFinXy3bGys0o5QufXfMLpj8tYlu Jl4q1Y7kXxlvbDBSxJLYLC1C90FPON4FiQtkDzjNwVlu7AzwTZZoNPeD6nB5soy7O0+d trReF/DsxWyEP2lM03MiQ4HiJ/AMgGcGHTFVMYkq8hGzM2kbUkV5LfjLqTH4F0EXh113 mV5pD5/bmO8JnEKg8BZKdxtbUSS/mm0U+gsIQ3pCzeGtZAzp7HIw57SrZjnPDMB74k4g lLo5cjQsmPbC3cKj4UVvYNf5CZjzlJ1jLqKuZ0A7U9cB8kbNc1hXDfWlyuljrYOB0Z9K nvcA== X-Forwarded-Encrypted: i=1; AJvYcCU1F9za3K8roPoOnwaTEBkA+fywt8Y7AyVLPI4YVywbjPe5SGExUq936TWB2zht/rAHGqsocSeJ5sXx@lists.infradead.org, AJvYcCVIKomrL1hf/n7suZLG+/V9aV5qSbaf4Ftxdgf/7hHj5OPA+MoY9p1Zqyqq0njvlxbznMFxOQ7jYaZVqft+AKU=@lists.infradead.org, AJvYcCXD9LnaEcyAGlzrGbOraRq5QGAjpEmUZ82NgEOxpFHUvH2NT+8RIXNcw7EpWqJ5UIQyM3OJqhTBU5UswI84AsS0@lists.infradead.org X-Gm-Message-State: AOJu0YxhD2ja86gx3ayCp8cari6XXdJ1Kb83RhsFmc11/VqZNg+Cd6ia RkaiEb5W2NWorEQAZGSMKbU1q9/6VFHCuzH5wg3VvkSQvR4uq7eK2G/pVw== X-Google-Smtp-Source: AGHT+IG2Zgblg95zfw1iMCpAfHL2xKdST9d36NrXxikTBWWWicgc6zwdWqnGZd9qLMDNR+2EHrmRGQ== X-Received: by 2002:a05:6a21:9cca:b0:1cf:6c64:f924 with SMTP id adf61e73a8af0-1d6dfacacedmr16387346637.38.1728273406386; Sun, 06 Oct 2024 20:56:46 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0cbbac6sm3451322b3a.39.2024.10.06.20.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 20:56:46 -0700 (PDT) From: Anand Moon To: Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner , linux-phy@lists.infradead.org (open list:GENERIC PHY FRAMEWORK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC support), linux-kernel@vger.kernel.org (open list) Cc: Anand Moon Subject: [PATCH v2 3/3] phy: rockchip-pcie: Use regmap_read_poll_timeout() for PCIe reference clk PLL status Date: Mon, 7 Oct 2024 09:26:11 +0530 Message-ID: <20241007035616.2701-4-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241007035616.2701-1-linux.amoon@gmail.com> References: <20241007035616.2701-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-20241006_205647_483199_EC9F5134 X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=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 --- v2: Fix the subject, add the missing () in the function name, Fix the typo reference v1: None. --- 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;