From patchwork Fri Jun 28 06:19:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13715507 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 1F05CC2BBCA for ; Fri, 28 Jun 2024 06:20:18 +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:Content-Transfer-Encoding: Content-Type:MIME-Version: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:In-Reply-To:References:List-Owner; bh=bWv0w8vAo8GiD/pB2lZc+Ffji376dYRZbqdwsEaIfbQ=; b=gCsCNIh2tuZcfXg60NqhqKfnS0 uBSspO3SSaaz1a/VE8B8s0a5cZEgROUZ2L8EeJxUF/wQexxORrVQ+ByW2BIxlsO5cWw1yPSkK1/+b VT4AdcIRRrJ1/LR8G2cddBVVhSThmRWrCTt2HJmLmIp5ZOuAm3GXjdT9gvS4rspfQ8rikkfPBK3vr f4W8Gp1IOglpcTY/kxx6p0cCHvGDN38fu3XNtgXmrkqhP2v0ipP0R+vvGuL0ZOirDlFIExzDwXw4U D4XjhHjOALetRqSy/xENEJOGpNxKcYs5Ei/HNgeHJ7vJD04h1uA4xWUBgfXuy5+367JYZB80vwEu2 NCqMMDSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN4xo-0000000CjTW-0OGk; Fri, 28 Jun 2024 06:20:04 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN4xe-0000000CjSQ-1g9r for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2024 06:19:56 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a6cb130027aso10709566b.2 for ; Thu, 27 Jun 2024 23:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719555592; x=1720160392; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bWv0w8vAo8GiD/pB2lZc+Ffji376dYRZbqdwsEaIfbQ=; b=b0xs6GZVsIiTj7bQKYcGcGMRRmSoFjqLeNwPfleh0WFfpZf9khm/p3vtUwLUcDVLfP 7a40ZlIGQPAtEM74TZ3JRFS0HEjqy9KSECFaUg6niAQrD1BD/D5A1nOCn6tfroy7o735 bUZp1e5VcAD6bH6WTeGOGA8+63+tg4ytP1Lq2MXgl/Gf9epRKJPLAI7ytRgpvKzWo35q x5vIk/cRMewsgT/JEmvKqO0yhTSFv4tUmOYwA26D1y1GfwMGBpz09aScsUAqAAulL6GV jzzP4BDufwJdlBVtNFGVT3iGN2w7mzMZrq2q3vA99gBlxd+FSxMELo4nnq1Ss4idgYZb 7bAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719555592; x=1720160392; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bWv0w8vAo8GiD/pB2lZc+Ffji376dYRZbqdwsEaIfbQ=; b=Uz2zKvR51rNqjOp7PO203DslE3m6g+Yr4co3PwAcquEellExGZzvEH/b2+qkkca7GY dFI15i2Ah/tq0UdY2/b7edJZITrpawkNCt2mmokRSvhY8MMJMQhrIgEqXikUTT/AwCnC jFGId8u24XFzaOhyoC4x/+E1EP4pnrQQGs8wmExv5FUAcsX1m8uTnnnIy/rlUvS1bRYL wDNMreL3BmoR9gguh05TrniDsxHlZgiW8OocN8X6+1T/QfQU/RVjbesSRkRKDrkk2HwK NPEnBBBAy56zIlGgmy9jP/VbvoiGasqHnf/CMUuFtpYcI6xvG4laExx8XV9ItGO7kXrW agjw== X-Forwarded-Encrypted: i=1; AJvYcCU8hklvSNDCqJjypdX11C75jjjEglDeQktBcSNPdRkB2kn07OygYS0AInEFXu3ASii/oI39BvCyKSi5wqsiZ/g6LIgCk5DsIiv3A2opbfDfWJ5ki+E= X-Gm-Message-State: AOJu0YzABMbbwEWlq8Rd72Fk4d8sHjz3LZG/2kK999dKz8JVNzVHTNf2 shBe25KWG1bEXujsPBvrvA8yXcCPnzgBymQYRjSFDyFhwjTMuvp2F9Dc0jIayYI= X-Google-Smtp-Source: AGHT+IHiCX799TPgCKQWgWwES345tt3l93lXFbbCZ3msBgpK/jOavx2uIDkrJ8d5HKBZTDTTLFzd6g== X-Received: by 2002:a05:6402:4305:b0:582:1a24:76d5 with SMTP id 4fb4d7f45d1cf-5821a2478bcmr10314387a12.35.1719555591823; Thu, 27 Jun 2024 23:19:51 -0700 (PDT) Received: from localhost ([2a02:8071:b783:6940:2d35:3c3:59a:94a4]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf62058sm44679866b.56.2024.06.27.23.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 23:19:51 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH] PM / devfreq: sun8i-a33-mbus: Make use of devm_ functions for clks Date: Fri, 28 Jun 2024 08:19:28 +0200 Message-ID: <20240628061929.89273-2-u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3340; i=u.kleine-koenig@baylibre.com; h=from:subject; bh=MuQ95BaMaeZwU8yA90MkErGZw2uB+AK7NPDyeRPhKOY=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBmflXxJBwsIWEFjBvCky8FpNk4ksgkkVuXrEY6w Sy/6dNUy32JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZn5V8QAKCRCPgPtYfRL+ TggBCACHNpfkOq7N2mcNIsiVfnEg4f+B/KE7bjdhsk1mpFcA1jnEzgqhzr93uh4gsLh768Ysnn5 00pbCMbD3QLnZ8uEr4+JtcygyF4iHJ0em7JDRmEzFggPlzZ3iXkqoQ6oCeLzJGl29ZLBq4b7qOA rakWuk/xvXbS8jafWJi0GlR0aY7BeWLr5w4+/puRUIxs7RydEWLtD3yviBKLbg2aNxUBAMhcDAX lVDCL9wwmkSAmha7epVzmEjZkxnnChD+C09xXnRrgvT3Z77YemyoyCGyhcg4rFGtY4C5UYv4DpS YHC49jFWvpKFfgyjKsvbN11/v7dxreXuvNgBRsCVq6BO1OZ2 X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_231954_684704_6DC85B22 X-CRM114-Status: GOOD ( 16.37 ) 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 Using devm_clk_get_enabled() and devm_clk_rate_exclusive_get() allows to simplify the error paths in .probe() and the remove callback. Signed-off-by: Uwe Kleine-König Reviewed-by: Chen-Yu Tsai --- drivers/devfreq/sun8i-a33-mbus.c | 38 +++++++++----------------------- 1 file changed, 10 insertions(+), 28 deletions(-) base-commit: 642a16ca7994a50d7de85715996a8ce171a5bdfb diff --git a/drivers/devfreq/sun8i-a33-mbus.c b/drivers/devfreq/sun8i-a33-mbus.c index bcf654f4ff96..4c179d7ddf0b 100644 --- a/drivers/devfreq/sun8i-a33-mbus.c +++ b/drivers/devfreq/sun8i-a33-mbus.c @@ -360,7 +360,7 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev) if (IS_ERR(priv->reg_mbus)) return PTR_ERR(priv->reg_mbus); - priv->clk_bus = devm_clk_get(dev, "bus"); + priv->clk_bus = devm_clk_get_enabled(dev, "bus"); if (IS_ERR(priv->clk_bus)) return dev_err_probe(dev, PTR_ERR(priv->clk_bus), "failed to get bus clock\n"); @@ -375,24 +375,17 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(priv->clk_mbus), "failed to get mbus clock\n"); - ret = clk_prepare_enable(priv->clk_bus); + /* Lock the DRAM clock rate to keep priv->nominal_bw in sync. */ + ret = devm_clk_rate_exclusive_get(dev, priv->clk_dram); if (ret) return dev_err_probe(dev, ret, - "failed to enable bus clock\n"); - - /* Lock the DRAM clock rate to keep priv->nominal_bw in sync. */ - ret = clk_rate_exclusive_get(priv->clk_dram); - if (ret) { - err = "failed to lock dram clock rate\n"; - goto err_disable_bus; - } + "failed to lock dram clock rate\n"); /* Lock the MBUS clock rate to keep MBUS_TMR_PERIOD in sync. */ - ret = clk_rate_exclusive_get(priv->clk_mbus); - if (ret) { - err = "failed to lock mbus clock rate\n"; - goto err_unlock_dram; - } + ret = devm_clk_rate_exclusive_get(dev, priv->clk_mbus); + if (ret) + return dev_err_probe(dev, ret, + "failed to lock mbus clock rate\n"); priv->gov_data.upthreshold = 10; priv->gov_data.downdifferential = 5; @@ -405,10 +398,8 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev) priv->profile.max_state = max_state; ret = devm_pm_opp_set_clkname(dev, "dram"); - if (ret) { - err = "failed to add OPP table\n"; - goto err_unlock_mbus; - } + if (ret) + return dev_err_probe(dev, ret, "failed to add OPP table\n"); base_freq = clk_get_rate(clk_get_parent(priv->clk_dram)); for (i = 0; i < max_state; ++i) { @@ -448,12 +439,6 @@ static int sun8i_a33_mbus_probe(struct platform_device *pdev) err_remove_opps: dev_pm_opp_remove_all_dynamic(dev); -err_unlock_mbus: - clk_rate_exclusive_put(priv->clk_mbus); -err_unlock_dram: - clk_rate_exclusive_put(priv->clk_dram); -err_disable_bus: - clk_disable_unprepare(priv->clk_bus); return dev_err_probe(dev, ret, err); } @@ -472,9 +457,6 @@ static void sun8i_a33_mbus_remove(struct platform_device *pdev) dev_warn(dev, "failed to restore DRAM frequency: %d\n", ret); dev_pm_opp_remove_all_dynamic(dev); - clk_rate_exclusive_put(priv->clk_mbus); - clk_rate_exclusive_put(priv->clk_dram); - clk_disable_unprepare(priv->clk_bus); } static const struct sun8i_a33_mbus_variant sun50i_a64_mbus = {