From patchwork Mon Oct 19 22:49:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11845433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22B77C43457 for ; Mon, 19 Oct 2020 22:50:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C747E22403 for ; Mon, 19 Oct 2020 22:50:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iXm1sX0Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388700AbgJSWt5 (ORCPT ); Mon, 19 Oct 2020 18:49:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388684AbgJSWty (ORCPT ); Mon, 19 Oct 2020 18:49:54 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35EC9C0613D0 for ; Mon, 19 Oct 2020 15:49:53 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id y14so836631pfp.13 for ; Mon, 19 Oct 2020 15:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=efUrOwTRA3BqBF2FggcKJlwY1p4PVpP44S+k5JyEkE0=; b=iXm1sX0YLiS63r393oCcXhZBNWg3vSTU8jq7EdqNmtHhgllUjEWsZofY4ien3gc1W3 XWyZui8wbPrrx+taXZekwGCAKfob1taYeYpEbiDrdupEHgoTB4ZwXb0szNrmGwSNSMqs OLe7DqgNuL2riAFeLud7G5TH2bd5SrDOtuQ7g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=efUrOwTRA3BqBF2FggcKJlwY1p4PVpP44S+k5JyEkE0=; b=UdojmA1IPexTOLYKJqBcH+oSGkkycOSfT2CdTClvB1lsJbOXNJi6Vg0YVbFb9vXRAl 8bT3J/zCxDn53jWJonU0K2OLJ7yCCu9QvUYM02XVQwlrgxPsWicnXk0GKmIoSwMMhIjl JV2blKgyzBEQc3xbg9wVjNAVMl0dp0aGNiIV0WrNizjQFstOI0gRUvAO+aOTc45QD4Mf Pbrl7AH8nEmZBTSYCw708nf3bajVEb74c0nFbx9fqDjsGhXzTZMnRpV3GRh+03kXp1+i G7eK33RQ50LLSmgOdn6mPWeZjHY41ExhgbEafarhFCOfgXfaigZgUPPt5o/goJhfh15E pqHg== X-Gm-Message-State: AOAM5300SFLGTcaK0TtUKGUbDTLfvSV2Nb+nw9XA6XXWwrBBnRbmbq+p 3D57wYVVTt/A+9NKEydfV1nsGg== X-Google-Smtp-Source: ABdhPJyB+/FQD7MGSEJBOYV2Uf7DvE6YPL0wWYb8MoYQmkPANysW3PyUNzYkmJc/hbJ4kOCr+omy5A== X-Received: by 2002:a63:3d8b:: with SMTP id k133mr62633pga.413.1603147792743; Mon, 19 Oct 2020 15:49:52 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id in6sm19912pjb.42.2020.10.19.15.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 15:49:52 -0700 (PDT) From: Douglas Anderson To: Stephen Boyd Cc: Taniya Das , David Brown , Rajendra Nayak , linux-soc@vger.kernel.org, Douglas Anderson , Andy Gross , Bjorn Andersson , Michael Turquette , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/2] clk: qcom: lpasscc-sc7810: Use devm in probe Date: Mon, 19 Oct 2020 15:49:34 -0700 Message-Id: <20201019154857.v5.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org Let's convert the lpass clock control driver to use devm. This is a few more lines of code, but it will be useful in a later patch which disentangles the two devices handled by this driver. Signed-off-by: Douglas Anderson Reviewed-by: Taniya Das --- (no changes since v4) Changes in v4: - Fixed typo lapss => lpass - Moved lpass_pm_runtime_disable() lpass_pm_clk_destroy() in file. Changes in v3: - ("clk: qcom: lpasscc-sc7810: Use devm in probe") new for v3. drivers/clk/qcom/lpasscorecc-sc7180.c | 38 +++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index 228d08f5d26f..2d15e33ec837 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -356,6 +356,16 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = { .num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs), }; +static void lpass_pm_runtime_disable(void *data) +{ + pm_runtime_disable(data); +} + +static void lpass_pm_clk_destroy(void *data) +{ + pm_clk_destroy(data); +} + static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) { const struct qcom_cc_desc *desc; @@ -418,34 +428,28 @@ static int lpass_core_sc7180_probe(struct platform_device *pdev) int ret; pm_runtime_enable(&pdev->dev); + ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_runtime_disable, &pdev->dev); + if (ret) + return ret; + ret = pm_clk_create(&pdev->dev); if (ret) - goto disable_pm_runtime; + return ret; + ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_clk_destroy, &pdev->dev); + if (ret) + return ret; ret = pm_clk_add(&pdev->dev, "iface"); if (ret < 0) { dev_err(&pdev->dev, "failed to acquire iface clock\n"); - goto destroy_pm_clk; + return ret; } - ret = -EINVAL; clk_probe = of_device_get_match_data(&pdev->dev); if (!clk_probe) - goto destroy_pm_clk; - - ret = clk_probe(pdev); - if (ret) - goto destroy_pm_clk; - - return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); + return -EINVAL; - return ret; + return clk_probe(pdev); } static const struct dev_pm_ops lpass_core_cc_pm_ops = { From patchwork Mon Oct 19 22:49:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11845435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9D50C43467 for ; Mon, 19 Oct 2020 22:49:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58E2A22403 for ; Mon, 19 Oct 2020 22:49:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="bG1yEuj6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388690AbgJSWt4 (ORCPT ); Mon, 19 Oct 2020 18:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388691AbgJSWtz (ORCPT ); Mon, 19 Oct 2020 18:49:55 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7B57C0613D5 for ; Mon, 19 Oct 2020 15:49:54 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id h7so877116pfn.2 for ; Mon, 19 Oct 2020 15:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JTx26RZgAqCsKfzwkiSZg5rClbsyn6MYzPRoe0bjgYQ=; b=bG1yEuj6ghwmVfgv4MprES7oMN1eTrdoAa6hRRtlZrIKE2b9AAw4dS2w1tCdfSVBMe DH83hZotlFPjhstXf691gZLmx5T8J5CepQnw5UrsAO8dwVJoPOrkEhPgI15Rusfgj/B4 BjekasqRLpJw3cw7NjM+LY7RVixma4lBCUGJo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JTx26RZgAqCsKfzwkiSZg5rClbsyn6MYzPRoe0bjgYQ=; b=K6+FSu7ce/AHVes7SFDcy5Qs2rd8XpdZ80gIoF3CU5Bq7wqv/EmK+YOorDHZnQbCcS 0Nq3hCihLRU4o7LwXJ1gPAV9tUK2nuJkq3HRP1RuFJjcZq/hDPGC05WWY9hB4ZpIKPZn aQVivHiORIfxLiwcmhOkilWu4KddmBs0SkbHmlNCgQz4cKMSxhH/+L8sENqojeETSiLE ZW9FdGHWY5yZZ7GlitM3Iz4JSFl9AWtbllPAXeXMQPoSGjRjjOk9fLo/rX5c6EpqgZDg hwihZ23qmwgH/5WPHpD2d7luX0sNwKVAxoBhJMGKzmhFQQ8CuELWjDhOJyx69sd3ykj6 82nQ== X-Gm-Message-State: AOAM5322oWUAroVfGzFVZg9Hyw/ns7S04gFo4VByVsAapPOkwyMnUavK 8gPxdcQvLgBELSOa5r9LXUmJ/Q== X-Google-Smtp-Source: ABdhPJwpVO7kPW23Ns/kgYxg64vbaC4B0ZONbTL6lPXWH3KM7BvUqrwp8hN8gIjiXfBRDuM8wscfRg== X-Received: by 2002:a62:6044:0:b029:151:1a04:895 with SMTP id u65-20020a6260440000b02901511a040895mr1873256pfb.34.1603147794230; Mon, 19 Oct 2020 15:49:54 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id in6sm19912pjb.42.2020.10.19.15.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 15:49:53 -0700 (PDT) From: Douglas Anderson To: Stephen Boyd Cc: Taniya Das , David Brown , Rajendra Nayak , linux-soc@vger.kernel.org, Douglas Anderson , Andy Gross , Bjorn Andersson , Michael Turquette , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/2] clk: qcom: lpass-sc7180: Disentangle the two clock devices Date: Mon, 19 Oct 2020 15:49:35 -0700 Message-Id: <20201019154857.v5.2.I75c409497d4dea9daefa53ec5f93824081c4ecbe@changeid> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201019154857.v5.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> References: <20201019154857.v5.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org The sc7180 lpass clock driver manages two different devices. These two devices were tangled together, using one probe and a lookup to figure out the real probe. I think it's cleaner to really separate the probe for these two devices since they're really different things, just both managed by the same driver. Signed-off-by: Douglas Anderson Reviewed-by: Taniya Das --- Note: this is now a 2-patch cleanup series with no actual bugfixes since the problem solved by patch #3 was better solved with: https://lore.kernel.org/r/20201017020137.1251319-1-sboyd@kernel.org Changes in v5: - Two blank lines inserted before "return" statements. Changes in v3: - ("clk: qcom: lpass-sc7180: Disentangle the two clock devices") new for v3. drivers/clk/qcom/lpasscorecc-sc7180.c | 103 ++++++++++++++++---------- 1 file changed, 64 insertions(+), 39 deletions(-) diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index 2d15e33ec837..1a3925badd7c 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -366,12 +366,39 @@ static void lpass_pm_clk_destroy(void *data) pm_clk_destroy(data); } +static int lpass_create_pm_clks(struct platform_device *pdev) +{ + int ret; + + pm_runtime_enable(&pdev->dev); + ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_runtime_disable, &pdev->dev); + if (ret) + return ret; + + ret = pm_clk_create(&pdev->dev); + if (ret) + return ret; + ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_clk_destroy, &pdev->dev); + if (ret) + return ret; + + ret = pm_clk_add(&pdev->dev, "iface"); + if (ret < 0) + dev_err(&pdev->dev, "failed to acquire iface clock\n"); + + return ret; +} + static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) { const struct qcom_cc_desc *desc; struct regmap *regmap; int ret; + ret = lpass_create_pm_clks(pdev); + if (ret) + return ret; + lpass_core_cc_sc7180_regmap_config.name = "lpass_audio_cc"; desc = &lpass_audio_hm_sc7180_desc; ret = qcom_cc_probe_by_index(pdev, 1, desc); @@ -402,6 +429,11 @@ static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) static int lpass_hm_core_probe(struct platform_device *pdev) { const struct qcom_cc_desc *desc; + int ret; + + ret = lpass_create_pm_clks(pdev); + if (ret) + return ret; lpass_core_cc_sc7180_regmap_config.name = "lpass_hm_core"; desc = &lpass_core_hm_sc7180_desc; @@ -409,55 +441,28 @@ static int lpass_hm_core_probe(struct platform_device *pdev) return qcom_cc_probe_by_index(pdev, 0, desc); } -static const struct of_device_id lpass_core_cc_sc7180_match_table[] = { +static const struct of_device_id lpass_hm_sc7180_match_table[] = { { .compatible = "qcom,sc7180-lpasshm", - .data = lpass_hm_core_probe, }, + { } +}; +MODULE_DEVICE_TABLE(of, lpass_hm_sc7180_match_table); + +static const struct of_device_id lpass_core_cc_sc7180_match_table[] = { { .compatible = "qcom,sc7180-lpasscorecc", - .data = lpass_core_cc_sc7180_probe, }, { } }; MODULE_DEVICE_TABLE(of, lpass_core_cc_sc7180_match_table); -static int lpass_core_sc7180_probe(struct platform_device *pdev) -{ - int (*clk_probe)(struct platform_device *p); - int ret; - - pm_runtime_enable(&pdev->dev); - ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_runtime_disable, &pdev->dev); - if (ret) - return ret; - - ret = pm_clk_create(&pdev->dev); - if (ret) - return ret; - ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_clk_destroy, &pdev->dev); - if (ret) - return ret; - - ret = pm_clk_add(&pdev->dev, "iface"); - if (ret < 0) { - dev_err(&pdev->dev, "failed to acquire iface clock\n"); - return ret; - } - - clk_probe = of_device_get_match_data(&pdev->dev); - if (!clk_probe) - return -EINVAL; - - return clk_probe(pdev); -} - static const struct dev_pm_ops lpass_core_cc_pm_ops = { SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL) }; static struct platform_driver lpass_core_cc_sc7180_driver = { - .probe = lpass_core_sc7180_probe, + .probe = lpass_core_cc_sc7180_probe, .driver = { .name = "lpass_core_cc-sc7180", .of_match_table = lpass_core_cc_sc7180_match_table, @@ -465,17 +470,37 @@ static struct platform_driver lpass_core_cc_sc7180_driver = { }, }; -static int __init lpass_core_cc_sc7180_init(void) +static const struct dev_pm_ops lpass_hm_pm_ops = { + SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL) +}; + +static struct platform_driver lpass_hm_sc7180_driver = { + .probe = lpass_hm_core_probe, + .driver = { + .name = "lpass_hm-sc7180", + .of_match_table = lpass_hm_sc7180_match_table, + .pm = &lpass_hm_pm_ops, + }, +}; + +static int __init lpass_sc7180_init(void) { - return platform_driver_register(&lpass_core_cc_sc7180_driver); + int ret; + + ret = platform_driver_register(&lpass_core_cc_sc7180_driver); + if (ret) + return ret; + + return platform_driver_register(&lpass_hm_sc7180_driver); } -subsys_initcall(lpass_core_cc_sc7180_init); +subsys_initcall(lpass_sc7180_init); -static void __exit lpass_core_cc_sc7180_exit(void) +static void __exit lpass_sc7180_exit(void) { + platform_driver_unregister(&lpass_hm_sc7180_driver); platform_driver_unregister(&lpass_core_cc_sc7180_driver); } -module_exit(lpass_core_cc_sc7180_exit); +module_exit(lpass_sc7180_exit); MODULE_DESCRIPTION("QTI LPASS_CORE_CC SC7180 Driver"); MODULE_LICENSE("GPL v2");