diff mbox series

clk: imx: scu: Use common error handling code in __imx_clk_gpr_scu()

Message ID 0e906ec6-fe73-4dbd-b555-a2c03b6e1030@web.de (mailing list archive)
State Rejected, archived
Headers show
Series clk: imx: scu: Use common error handling code in __imx_clk_gpr_scu() | expand

Commit Message

Markus Elfring Dec. 22, 2023, 9:23 a.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 22 Dec 2023 10:05:32 +0100

Use another label so that a bit of exception handling can be better reused
at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/imx/clk-scu.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

--
2.43.0

Comments

Abel Vesa Feb. 2, 2024, 6:45 p.m. UTC | #1
On 23-12-22 10:23:13, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 22 Dec 2023 10:05:32 +0100
> 
> Use another label so that a bit of exception handling can be better reused
> at the end of this function.

Please don't send patches as reply to other(s) patches.

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/clk/imx/clk-scu.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
> index e48a904c0013..4ca9dccf3d3b 100644
> --- a/drivers/clk/imx/clk-scu.c
> +++ b/drivers/clk/imx/clk-scu.c
> @@ -882,19 +882,19 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na
>  		return ERR_PTR(-ENOMEM);
> 
>  	if (!imx_scu_clk_is_valid(rsrc_id)) {
> -		kfree(clk_node);
> -		return ERR_PTR(-EINVAL);
> +		ret = -EINVAL;
> +		goto free_clk_node;
>  	}
> 
>  	if (!imx_clk_is_resource_owned(rsrc_id)) {
> -		kfree(clk_node);
> -		return NULL;
> +		ret = 0;
> +		goto free_clk_node;
>  	}
> 
>  	clk = kzalloc(sizeof(*clk), GFP_KERNEL);
>  	if (!clk) {
> -		kfree(clk_node);
> -		return ERR_PTR(-ENOMEM);
> +		ret = -ENOMEM;
> +		goto free_clk_node;
>  	}
> 
>  	clk->rsrc_id = rsrc_id;
> @@ -922,6 +922,7 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na
>  	ret = clk_hw_register(NULL, hw);
>  	if (ret) {
>  		kfree(clk);
> +free_clk_node:
>  		kfree(clk_node);
>  		hw = ERR_PTR(ret);
>  	} else {
> --
> 2.43.0
>
Markus Elfring Feb. 2, 2024, 8:21 p.m. UTC | #2
>> Use another label so that a bit of exception handling can be better reused
>> at the end of this function.
>
> Please don't send patches as reply to other(s) patches.

This is a general possibility to connect an information sources with
a corresponding change idea.
Will the acceptance grow for the presented source code transformation?

Regards,
Markus
Abel Vesa Feb. 26, 2024, 9:08 a.m. UTC | #3
On 24-02-02 21:21:19, Markus Elfring wrote:
> >> Use another label so that a bit of exception handling can be better reused
> >> at the end of this function.
> >
> > Please don't send patches as reply to other(s) patches.
> 
> This is a general possibility to connect an information sources with
> a corresponding change idea.
> Will the acceptance grow for the presented source code transformation?
> 

Nope, please don't do that. The b4 tool will pick up the old patch if
you do this.

> Regards,
> Markus
Markus Elfring Feb. 26, 2024, 2:35 p.m. UTC | #4
>>>> Use another label so that a bit of exception handling can be better reused
>>>> at the end of this function.
>>>
>>> Please don't send patches as reply to other(s) patches.
>>
>> This is a general possibility to connect an information sources with
>> a corresponding change idea.
>> Will the acceptance grow for the presented source code transformation?
>>
>
> Nope, please don't do that.

Do you find the proposed source code transformation reasonable (in principle)?


> The b4 tool will pick up the old patch if you do this.

Are you looking for further improvements for this development tool?

Regards,
Markus
diff mbox series

Patch

diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
index e48a904c0013..4ca9dccf3d3b 100644
--- a/drivers/clk/imx/clk-scu.c
+++ b/drivers/clk/imx/clk-scu.c
@@ -882,19 +882,19 @@  struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na
 		return ERR_PTR(-ENOMEM);

 	if (!imx_scu_clk_is_valid(rsrc_id)) {
-		kfree(clk_node);
-		return ERR_PTR(-EINVAL);
+		ret = -EINVAL;
+		goto free_clk_node;
 	}

 	if (!imx_clk_is_resource_owned(rsrc_id)) {
-		kfree(clk_node);
-		return NULL;
+		ret = 0;
+		goto free_clk_node;
 	}

 	clk = kzalloc(sizeof(*clk), GFP_KERNEL);
 	if (!clk) {
-		kfree(clk_node);
-		return ERR_PTR(-ENOMEM);
+		ret = -ENOMEM;
+		goto free_clk_node;
 	}

 	clk->rsrc_id = rsrc_id;
@@ -922,6 +922,7 @@  struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na
 	ret = clk_hw_register(NULL, hw);
 	if (ret) {
 		kfree(clk);
+free_clk_node:
 		kfree(clk_node);
 		hw = ERR_PTR(ret);
 	} else {