diff mbox series

[2/3] clk: qcom: smd-rpm: Drop the use of struct rpm_cc

Message ID 20211031020715.21636-3-shawn.guo@linaro.org (mailing list archive)
State Not Applicable
Headers show
Series A few smd-rpm clock driver cleanups | expand

Commit Message

Shawn Guo Oct. 31, 2021, 2:07 a.m. UTC
Considering that struct rpm_cc is now identical to rpm_smd_clk_desc,
and function qcom_smdrpm_clk_hw_get() uses rpm_cc in a read-only manner,
rpm_cc can be dropped by getting the function use rpm_smd_clk_desc
directly.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/clk/qcom/clk-smd-rpm.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

Comments

Bjorn Andersson Dec. 6, 2021, 3:24 p.m. UTC | #1
On Sat 30 Oct 21:07 CDT 2021, Shawn Guo wrote:

> Considering that struct rpm_cc is now identical to rpm_smd_clk_desc,
> and function qcom_smdrpm_clk_hw_get() uses rpm_cc in a read-only manner,
> rpm_cc can be dropped by getting the function use rpm_smd_clk_desc
> directly.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> ---
>  drivers/clk/qcom/clk-smd-rpm.c | 21 ++++-----------------
>  1 file changed, 4 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
> index a27c0e740ab7..dd3d373a1309 100644
> --- a/drivers/clk/qcom/clk-smd-rpm.c
> +++ b/drivers/clk/qcom/clk-smd-rpm.c
> @@ -150,11 +150,6 @@ struct clk_smd_rpm_req {
>  	__le32 value;
>  };
>  
> -struct rpm_cc {
> -	struct clk_smd_rpm **clks;
> -	size_t num_clks;
> -};
> -
>  struct rpm_smd_clk_desc {
>  	struct clk_smd_rpm **clks;
>  	size_t num_clks;
> @@ -1157,20 +1152,19 @@ MODULE_DEVICE_TABLE(of, rpm_smd_clk_match_table);
>  static struct clk_hw *qcom_smdrpm_clk_hw_get(struct of_phandle_args *clkspec,
>  					     void *data)
>  {
> -	struct rpm_cc *rcc = data;
> +	const struct rpm_smd_clk_desc *desc = data;
>  	unsigned int idx = clkspec->args[0];
>  
> -	if (idx >= rcc->num_clks) {
> +	if (idx >= desc->num_clks) {
>  		pr_err("%s: invalid index %u\n", __func__, idx);
>  		return ERR_PTR(-EINVAL);
>  	}
>  
> -	return rcc->clks[idx] ? &rcc->clks[idx]->hw : ERR_PTR(-ENOENT);
> +	return desc->clks[idx] ? &desc->clks[idx]->hw : ERR_PTR(-ENOENT);
>  }
>  
>  static int rpm_smd_clk_probe(struct platform_device *pdev)
>  {
> -	struct rpm_cc *rcc;
>  	int ret;
>  	size_t num_clks, i;
>  	struct qcom_smd_rpm *rpm;
> @@ -1190,13 +1184,6 @@ static int rpm_smd_clk_probe(struct platform_device *pdev)
>  	rpm_smd_clks = desc->clks;
>  	num_clks = desc->num_clks;
>  
> -	rcc = devm_kzalloc(&pdev->dev, sizeof(*rcc), GFP_KERNEL);
> -	if (!rcc)
> -		return -ENOMEM;
> -
> -	rcc->clks = rpm_smd_clks;
> -	rcc->num_clks = num_clks;
> -
>  	for (i = 0; i < num_clks; i++) {
>  		if (!rpm_smd_clks[i])
>  			continue;
> @@ -1222,7 +1209,7 @@ static int rpm_smd_clk_probe(struct platform_device *pdev)
>  	}
>  
>  	ret = devm_of_clk_add_hw_provider(&pdev->dev, qcom_smdrpm_clk_hw_get,
> -				     rcc);
> +					  (void *)desc);
>  	if (ret)
>  		goto err;
>  
> -- 
> 2.17.1
>
diff mbox series

Patch

diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
index a27c0e740ab7..dd3d373a1309 100644
--- a/drivers/clk/qcom/clk-smd-rpm.c
+++ b/drivers/clk/qcom/clk-smd-rpm.c
@@ -150,11 +150,6 @@  struct clk_smd_rpm_req {
 	__le32 value;
 };
 
-struct rpm_cc {
-	struct clk_smd_rpm **clks;
-	size_t num_clks;
-};
-
 struct rpm_smd_clk_desc {
 	struct clk_smd_rpm **clks;
 	size_t num_clks;
@@ -1157,20 +1152,19 @@  MODULE_DEVICE_TABLE(of, rpm_smd_clk_match_table);
 static struct clk_hw *qcom_smdrpm_clk_hw_get(struct of_phandle_args *clkspec,
 					     void *data)
 {
-	struct rpm_cc *rcc = data;
+	const struct rpm_smd_clk_desc *desc = data;
 	unsigned int idx = clkspec->args[0];
 
-	if (idx >= rcc->num_clks) {
+	if (idx >= desc->num_clks) {
 		pr_err("%s: invalid index %u\n", __func__, idx);
 		return ERR_PTR(-EINVAL);
 	}
 
-	return rcc->clks[idx] ? &rcc->clks[idx]->hw : ERR_PTR(-ENOENT);
+	return desc->clks[idx] ? &desc->clks[idx]->hw : ERR_PTR(-ENOENT);
 }
 
 static int rpm_smd_clk_probe(struct platform_device *pdev)
 {
-	struct rpm_cc *rcc;
 	int ret;
 	size_t num_clks, i;
 	struct qcom_smd_rpm *rpm;
@@ -1190,13 +1184,6 @@  static int rpm_smd_clk_probe(struct platform_device *pdev)
 	rpm_smd_clks = desc->clks;
 	num_clks = desc->num_clks;
 
-	rcc = devm_kzalloc(&pdev->dev, sizeof(*rcc), GFP_KERNEL);
-	if (!rcc)
-		return -ENOMEM;
-
-	rcc->clks = rpm_smd_clks;
-	rcc->num_clks = num_clks;
-
 	for (i = 0; i < num_clks; i++) {
 		if (!rpm_smd_clks[i])
 			continue;
@@ -1222,7 +1209,7 @@  static int rpm_smd_clk_probe(struct platform_device *pdev)
 	}
 
 	ret = devm_of_clk_add_hw_provider(&pdev->dev, qcom_smdrpm_clk_hw_get,
-				     rcc);
+					  (void *)desc);
 	if (ret)
 		goto err;