2023-12-22 16:34:33

by Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/2] clk: imx: composite-8m: Adjustments for __imx8m_clk_hw_composite()

From: Markus Elfring <[email protected]>
Date: Fri, 22 Dec 2023 17:24:32 +0100

A few update suggestions were taken into account
from source code analysis.

Markus Elfring (2):
Less function calls after error detection
Delete two unnecessary initialisations

drivers/clk/imx/clk-composite-8m.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

--
2.43.0



2023-12-22 16:38:17

by Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/2] clk: imx: composite-8m: Delete two unnecessary initialisations in __imx8m_clk_hw_composite()

From: Markus Elfring <[email protected]>
Date: Fri, 22 Dec 2023 17:11:03 +0100

Two local variables will eventually be set to appropriate pointers
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/clk/imx/clk-composite-8m.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c
index eb5392f7a257..8cc07d056a83 100644
--- a/drivers/clk/imx/clk-composite-8m.c
+++ b/drivers/clk/imx/clk-composite-8m.c
@@ -212,9 +212,9 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
{
struct clk_hw *hw = ERR_PTR(-ENOMEM), *mux_hw;
struct clk_hw *div_hw, *gate_hw = NULL;
- struct clk_divider *div = NULL;
+ struct clk_divider *div;
struct clk_gate *gate = NULL;
- struct clk_mux *mux = NULL;
+ struct clk_mux *mux;
const struct clk_ops *divider_ops;
const struct clk_ops *mux_ops;

--
2.43.0


2023-12-22 16:38:41

by Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/2] clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection

From: Markus Elfring <[email protected]>
Date: Fri, 22 Dec 2023 16:48:24 +0100

The function “kfree” was called in up to three cases
by the function “__imx8m_clk_hw_composite” during error handling
even if the passed variables contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/clk/imx/clk-composite-8m.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c
index 27a08c50ac1d..eb5392f7a257 100644
--- a/drivers/clk/imx/clk-composite-8m.c
+++ b/drivers/clk/imx/clk-composite-8m.c
@@ -220,7 +220,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,

mux = kzalloc(sizeof(*mux), GFP_KERNEL);
if (!mux)
- goto fail;
+ return ERR_CAST(hw);

mux_hw = &mux->hw;
mux->reg = reg;
@@ -230,7 +230,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,

div = kzalloc(sizeof(*div), GFP_KERNEL);
if (!div)
- goto fail;
+ goto free_mux;

div_hw = &div->hw;
div->reg = reg;
@@ -260,7 +260,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
if (!mcore_booted) {
gate = kzalloc(sizeof(*gate), GFP_KERNEL);
if (!gate)
- goto fail;
+ goto free_div;

gate_hw = &gate->hw;
gate->reg = reg;
@@ -272,13 +272,15 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
mux_hw, mux_ops, div_hw,
divider_ops, gate_hw, &clk_gate_ops, flags);
if (IS_ERR(hw))
- goto fail;
+ goto free_gate;

return hw;

-fail:
+free_gate:
kfree(gate);
+free_div:
kfree(div);
+free_mux:
kfree(mux);
return ERR_CAST(hw);
}
--
2.43.0


2023-12-25 03:17:45

by Peng Fan

[permalink] [raw]
Subject: RE: [PATCH 1/2] clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection

> Subject: [PATCH 1/2] clk: imx: composite-8m: Less function calls in
> __imx8m_clk_hw_composite() after error detection
>
> From: Markus Elfring <[email protected]>
> Date: Fri, 22 Dec 2023 16:48:24 +0100
>
> The function “kfree” was called in up to three cases by the function
> “__imx8m_clk_hw_composite” during error handling even if the passed
> variables contained a null pointer.
>
> Adjust jump targets according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <[email protected]>

Reviewed-by: Peng Fan <[email protected]>

2023-12-25 03:19:13

by Peng Fan

[permalink] [raw]
Subject: RE: [PATCH 2/2] clk: imx: composite-8m: Delete two unnecessary initialisations in __imx8m_clk_hw_composite()

> Subject: [PATCH 2/2] clk: imx: composite-8m: Delete two unnecessary
> initialisations in __imx8m_clk_hw_composite()
>
> From: Markus Elfring <[email protected]>
> Date: Fri, 22 Dec 2023 17:11:03 +0100
>
> Two local variables will eventually be set to appropriate pointers a bit later.
> Thus omit the explicit initialisation at the beginning.
>
> Signed-off-by: Markus Elfring <[email protected]>

Reviewed-by: Peng Fan <[email protected]>

2024-02-26 09:51:47

by Abel Vesa

[permalink] [raw]
Subject: Re: [PATCH 0/2] clk: imx: composite-8m: Adjustments for __imx8m_clk_hw_composite()


On Fri, 22 Dec 2023 17:33:19 +0100, Markus Elfring wrote:
> A few update suggestions were taken into account
> from source code analysis.
>
> Markus Elfring (2):
> Less function calls after error detection
> Delete two unnecessary initialisations
>
> [...]

Applied, thanks!

[1/2] clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection
commit: fed6bf52c86df27ad4f39a72cdad8c27da9a50ba
[2/2] clk: imx: composite-8m: Delete two unnecessary initialisations in __imx8m_clk_hw_composite()
commit: e1ed0b0362285981c575f12ae9e8b9dfe56a046c

Best regards,
--
Abel Vesa <[email protected]>