From: Harry Austen <hpausten@protonmail.com>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Michal Simek <michal.simek@amd.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>,
Dave Ertman <david.m.ertman@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Harry Austen <hpausten@protonmail.com>
Subject: [PATCH v3 3/9] clk: clocking-wizard: use devres versions of clk_hw API
Date: Mon, 26 Aug 2024 12:38:18 +0000 [thread overview]
Message-ID: <20240826123602.1872-4-hpausten@protonmail.com> (raw)
In-Reply-To: <20240826123602.1872-1-hpausten@protonmail.com>
Use device managed versions of the clk_hw API, entirely removing the
need for the driver's remove() callback and greatly simplifying the
probe() function's error paths.
Signed-off-by: Harry Austen <hpausten@protonmail.com>
---
drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 52 +++++-----------------
1 file changed, 11 insertions(+), 41 deletions(-)
diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
index cd795a4952099..f332e0eee56c8 100644
--- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
+++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
@@ -1082,7 +1082,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
clk_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul", dev_name(&pdev->dev));
if (!clk_name)
return -ENOMEM;
- clk_wzrd->clks_internal[wzrd_clk_mul] = clk_hw_register_fixed_factor
+ clk_wzrd->clks_internal[wzrd_clk_mul] = devm_clk_hw_register_fixed_factor
(&pdev->dev, clk_name,
__clk_get_name(clk_wzrd->clk_in1),
0, mult, div);
@@ -1092,10 +1092,8 @@ static int clk_wzrd_probe(struct platform_device *pdev)
}
clk_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev));
- if (!clk_name) {
- ret = -ENOMEM;
- goto err_rm_int_clk;
- }
+ if (!clk_name)
+ return -ENOMEM;
if (is_versal) {
edged = !!(readl(clk_wzrd->base + WZRD_CLK_CFG_REG(is_versal, 20)) &
@@ -1110,11 +1108,11 @@ static int clk_wzrd_probe(struct platform_device *pdev)
clk_mul_name = clk_hw_get_name(clk_wzrd->clks_internal[wzrd_clk_mul]);
clk_wzrd->clks_internal[wzrd_clk_mul_div] =
- clk_hw_register_fixed_factor(&pdev->dev, clk_name,
- clk_mul_name, 0, 1, div);
+ devm_clk_hw_register_fixed_factor(&pdev->dev, clk_name,
+ clk_mul_name, 0, 1, div);
} else {
ctrl_reg = clk_wzrd->base + WZRD_CLK_CFG_REG(is_versal, 0);
- clk_wzrd->clks_internal[wzrd_clk_mul_div] = clk_hw_register_divider
+ clk_wzrd->clks_internal[wzrd_clk_mul_div] = devm_clk_hw_register_divider
(&pdev->dev, clk_name,
clk_hw_get_name(clk_wzrd->clks_internal[wzrd_clk_mul]),
flags, ctrl_reg, 0, 8, CLK_DIVIDER_ONE_BASED |
@@ -1122,18 +1120,15 @@ static int clk_wzrd_probe(struct platform_device *pdev)
}
if (IS_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div])) {
dev_err(&pdev->dev, "unable to register divider clock\n");
- ret = PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div]);
- goto err_rm_int_clk;
+ return PTR_ERR(clk_wzrd->clks_internal[wzrd_clk_mul_div]);
}
/* register div per output */
for (i = nr_outputs - 1; i >= 0 ; i--) {
clkout_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
"%s_out%d", dev_name(&pdev->dev), i);
- if (!clkout_name) {
- ret = -ENOMEM;
- goto err_rm_int_clk;
- }
+ if (!clkout_name)
+ return -ENOMEM;
if (is_versal) {
clk_wzrd->clk_data.hws[i] = clk_wzrd_ver_register_divider
@@ -1165,20 +1160,15 @@ static int clk_wzrd_probe(struct platform_device *pdev)
DIV_O, &clkwzrd_lock);
}
if (IS_ERR(clk_wzrd->clk_data.hws[i])) {
- int j;
-
- for (j = i + 1; j < nr_outputs; j++)
- clk_hw_unregister(clk_wzrd->clk_data.hws[j]);
dev_err(&pdev->dev,
"unable to register divider clock\n");
- ret = PTR_ERR(clk_wzrd->clk_data.hws[i]);
- goto err_rm_int_clks;
+ return PTR_ERR(clk_wzrd->clk_data.hws[i]);
}
}
out:
clk_wzrd->clk_data.num = nr_outputs;
- ret = of_clk_add_hw_provider(pdev->dev.of_node, of_clk_hw_onecell_get, &clk_wzrd->clk_data);
+ ret = devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_onecell_get, &clk_wzrd->clk_data);
if (ret) {
dev_err(&pdev->dev, "unable to register clock provider\n");
return ret;
@@ -1201,25 +1191,6 @@ static int clk_wzrd_probe(struct platform_device *pdev)
}
return 0;
-
-err_rm_int_clks:
- clk_hw_unregister(clk_wzrd->clks_internal[1]);
-err_rm_int_clk:
- clk_hw_unregister(clk_wzrd->clks_internal[0]);
- return ret;
-}
-
-static void clk_wzrd_remove(struct platform_device *pdev)
-{
- int i;
- struct clk_wzrd *clk_wzrd = platform_get_drvdata(pdev);
-
- of_clk_del_provider(pdev->dev.of_node);
-
- for (i = 0; i < WZRD_NUM_OUTPUTS; i++)
- clk_hw_unregister(clk_wzrd->clk_data.hws[i]);
- for (i = 0; i < wzrd_clk_int_max; i++)
- clk_hw_unregister(clk_wzrd->clks_internal[i]);
}
static const struct of_device_id clk_wzrd_ids[] = {
@@ -1238,7 +1209,6 @@ static struct platform_driver clk_wzrd_driver = {
.pm = &clk_wzrd_dev_pm_ops,
},
.probe = clk_wzrd_probe,
- .remove_new = clk_wzrd_remove,
};
module_platform_driver(clk_wzrd_driver);
--
2.46.0
next prev parent reply other threads:[~2024-08-26 12:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 12:38 [PATCH v3 0/9] clk: clocking-wizard: add user clock monitor support Harry Austen
2024-08-26 12:38 ` [PATCH v3 1/9] clk: clocking-wizard: simplify probe/remove with devres helpers Harry Austen
2024-08-26 12:38 ` [PATCH v3 2/9] clk: clocking-wizard: use newer clk_hw API Harry Austen
2024-08-26 12:38 ` Harry Austen [this message]
2024-08-26 12:38 ` [PATCH v3 4/9] clk: clocking-wizard: move clock registration to separate function Harry Austen
2024-08-26 12:38 ` [PATCH v3 5/9] dt-bindings: clock: xilinx: add description of user monitor interrupt Harry Austen
2024-08-26 12:38 ` [PATCH v3 6/9] clk: clocking-wizard: add user clock monitor support Harry Austen
2024-08-26 12:38 ` [PATCH v3 7/9] uio: add Xilinx " Harry Austen
2024-08-26 13:11 ` Greg Kroah-Hartman
2024-08-27 19:08 ` Harry Austen
2024-08-27 23:40 ` Stephen Boyd
2024-08-28 7:10 ` Greg Kroah-Hartman
2024-08-29 18:17 ` Stephen Boyd
2024-08-30 7:31 ` Harry Austen
2024-08-26 12:38 ` [PATCH v3 8/9] dt-bindings: clock: xilinx: describe whether dynamic reconfig is enabled Harry Austen
2024-08-26 12:38 ` [PATCH v3 9/9] clk: clocking-wizard: move dynamic reconfig setup behind flag Harry Austen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240826123602.1872-4-hpausten@protonmail.com \
--to=hpausten@protonmail.com \
--cc=conor+dt@kernel.org \
--cc=david.m.ertman@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=ira.weiny@intel.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=mturquette@baylibre.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=shubhrajyoti.datta@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.