* [PATCH v2 1/7] clk: at91: sckc: add support to free slow oscillator
2019-06-27 15:53 [PATCH v2 0/7] clk: at91: sckc: improve error path Claudiu Beznea
@ 2019-06-27 15:53 ` Claudiu Beznea
2019-06-27 18:22 ` Stephen Boyd
2019-06-27 15:53 ` [PATCH v2 2/7] clk: at91: sckc: add support to free slow rc oscillator Claudiu Beznea
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Claudiu Beznea @ 2019-06-27 15:53 UTC (permalink / raw)
To: mturquette, sboyd, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: linux-clk, linux-arm-kernel, linux-kernel, Claudiu Beznea
Add support to free slow oscillator resources.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clk/at91/sckc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c
index 2c410f41b413..c1d7edd33416 100644
--- a/drivers/clk/at91/sckc.c
+++ b/drivers/clk/at91/sckc.c
@@ -166,6 +166,14 @@ at91_clk_register_slow_osc(void __iomem *sckcr,
return hw;
}
+static void at91_clk_unregister_slow_osc(struct clk_hw *hw)
+{
+ struct clk_slow_osc *osc = to_clk_slow_osc(hw);
+
+ clk_hw_unregister(hw);
+ kfree(osc);
+}
+
static unsigned long clk_slow_rc_osc_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 2/7] clk: at91: sckc: add support to free slow rc oscillator
2019-06-27 15:53 [PATCH v2 0/7] clk: at91: sckc: improve error path Claudiu Beznea
2019-06-27 15:53 ` [PATCH v2 1/7] clk: at91: sckc: add support to free slow oscillator Claudiu Beznea
@ 2019-06-27 15:53 ` Claudiu Beznea
2019-06-27 18:22 ` Stephen Boyd
2019-06-27 15:53 ` [PATCH v2 3/7] clk: at91: sckc: add support to free slow clock osclillator Claudiu Beznea
` (4 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Claudiu Beznea @ 2019-06-27 15:53 UTC (permalink / raw)
To: mturquette, sboyd, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: linux-clk, linux-arm-kernel, linux-kernel, Claudiu Beznea
Add support to free slow rc oscillator resources.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clk/at91/sckc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c
index c1d7edd33416..492b139a7c15 100644
--- a/drivers/clk/at91/sckc.c
+++ b/drivers/clk/at91/sckc.c
@@ -268,6 +268,14 @@ at91_clk_register_slow_rc_osc(void __iomem *sckcr,
return hw;
}
+static void at91_clk_unregister_slow_rc_osc(struct clk_hw *hw)
+{
+ struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw);
+
+ clk_hw_unregister(hw);
+ kfree(osc);
+}
+
static int clk_sam9x5_slow_set_parent(struct clk_hw *hw, u8 index)
{
struct clk_sam9x5_slow *slowck = to_clk_sam9x5_slow(hw);
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 3/7] clk: at91: sckc: add support to free slow clock osclillator
2019-06-27 15:53 [PATCH v2 0/7] clk: at91: sckc: improve error path Claudiu Beznea
2019-06-27 15:53 ` [PATCH v2 1/7] clk: at91: sckc: add support to free slow oscillator Claudiu Beznea
2019-06-27 15:53 ` [PATCH v2 2/7] clk: at91: sckc: add support to free slow rc oscillator Claudiu Beznea
@ 2019-06-27 15:53 ` Claudiu Beznea
2019-06-27 18:22 ` Stephen Boyd
2019-06-27 15:53 ` [PATCH v2 4/7] clk: at91: sckc: improve error path for sam9x5 sck register Claudiu Beznea
` (3 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Claudiu Beznea @ 2019-06-27 15:53 UTC (permalink / raw)
To: mturquette, sboyd, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: linux-clk, linux-arm-kernel, linux-kernel, Claudiu Beznea
Add support to free slow clock oscillator resources.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clk/at91/sckc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c
index 492b139a7c15..2a677c56f901 100644
--- a/drivers/clk/at91/sckc.c
+++ b/drivers/clk/at91/sckc.c
@@ -355,6 +355,14 @@ at91_clk_register_sam9x5_slow(void __iomem *sckcr,
return hw;
}
+static void at91_clk_unregister_sam9x5_slow(struct clk_hw *hw)
+{
+ struct clk_sam9x5_slow *slowck = to_clk_sam9x5_slow(hw);
+
+ clk_hw_unregister(hw);
+ kfree(slowck);
+}
+
static void __init at91sam9x5_sckc_register(struct device_node *np,
unsigned int rc_osc_startup_us,
const struct clk_slow_bits *bits)
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 4/7] clk: at91: sckc: improve error path for sam9x5 sck register
2019-06-27 15:53 [PATCH v2 0/7] clk: at91: sckc: improve error path Claudiu Beznea
` (2 preceding siblings ...)
2019-06-27 15:53 ` [PATCH v2 3/7] clk: at91: sckc: add support to free slow clock osclillator Claudiu Beznea
@ 2019-06-27 15:53 ` Claudiu Beznea
2019-06-27 18:22 ` Stephen Boyd
2019-06-27 15:53 ` [PATCH v2 5/7] clk: at91: sckc: remove unnecessary line Claudiu Beznea
` (2 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Claudiu Beznea @ 2019-06-27 15:53 UTC (permalink / raw)
To: mturquette, sboyd, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: linux-clk, linux-arm-kernel, linux-kernel, Claudiu Beznea
Improve error path for sam9x5 slow clock registration.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clk/at91/sckc.c | 50 +++++++++++++++++++++++++++++++------------------
1 file changed, 32 insertions(+), 18 deletions(-)
diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c
index 2a677c56f901..a2b905c91085 100644
--- a/drivers/clk/at91/sckc.c
+++ b/drivers/clk/at91/sckc.c
@@ -371,16 +371,17 @@ static void __init at91sam9x5_sckc_register(struct device_node *np,
void __iomem *regbase = of_iomap(np, 0);
struct device_node *child = NULL;
const char *xtal_name;
- struct clk_hw *hw;
+ struct clk_hw *slow_rc, *slow_osc, *slowck;
bool bypass;
+ int ret;
if (!regbase)
return;
- hw = at91_clk_register_slow_rc_osc(regbase, parent_names[0], 32768,
- 50000000, rc_osc_startup_us,
- bits);
- if (IS_ERR(hw))
+ slow_rc = at91_clk_register_slow_rc_osc(regbase, parent_names[0],
+ 32768, 50000000,
+ rc_osc_startup_us, bits);
+ if (IS_ERR(slow_rc))
return;
xtal_name = of_clk_get_parent_name(np, 0);
@@ -388,7 +389,7 @@ static void __init at91sam9x5_sckc_register(struct device_node *np,
/* DT backward compatibility */
child = of_get_compatible_child(np, "atmel,at91sam9x5-clk-slow-osc");
if (!child)
- return;
+ goto unregister_slow_rc;
xtal_name = of_clk_get_parent_name(child, 0);
bypass = of_property_read_bool(child, "atmel,osc-bypass");
@@ -399,23 +400,36 @@ static void __init at91sam9x5_sckc_register(struct device_node *np,
}
if (!xtal_name)
- return;
-
- hw = at91_clk_register_slow_osc(regbase, parent_names[1], xtal_name,
- 1200000, bypass, bits);
- if (IS_ERR(hw))
- return;
+ goto unregister_slow_rc;
- hw = at91_clk_register_sam9x5_slow(regbase, "slowck", parent_names, 2,
- bits);
- if (IS_ERR(hw))
- return;
+ slow_osc = at91_clk_register_slow_osc(regbase, parent_names[1],
+ xtal_name, 1200000, bypass, bits);
+ if (IS_ERR(slow_osc))
+ goto unregister_slow_rc;
- of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
+ slowck = at91_clk_register_sam9x5_slow(regbase, "slowck", parent_names,
+ 2, bits);
+ if (IS_ERR(slowck))
+ goto unregister_slow_osc;
/* DT backward compatibility */
if (child)
- of_clk_add_hw_provider(child, of_clk_hw_simple_get, hw);
+ ret = of_clk_add_hw_provider(child, of_clk_hw_simple_get,
+ slowck);
+ else
+ ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, slowck);
+
+ if (WARN_ON(ret))
+ goto unregister_slowck;
+
+ return;
+
+unregister_slowck:
+ at91_clk_unregister_sam9x5_slow(slowck);
+unregister_slow_osc:
+ at91_clk_unregister_slow_osc(slow_osc);
+unregister_slow_rc:
+ at91_clk_unregister_slow_rc_osc(slow_rc);
}
static const struct clk_slow_bits at91sam9x5_bits = {
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 5/7] clk: at91: sckc: remove unnecessary line
2019-06-27 15:53 [PATCH v2 0/7] clk: at91: sckc: improve error path Claudiu Beznea
` (3 preceding siblings ...)
2019-06-27 15:53 ` [PATCH v2 4/7] clk: at91: sckc: improve error path for sam9x5 sck register Claudiu Beznea
@ 2019-06-27 15:53 ` Claudiu Beznea
2019-06-27 18:22 ` Stephen Boyd
2019-06-27 15:53 ` [PATCH v2 6/7] clk: at91: sckc: improve error path for sama5d4 sck registration Claudiu Beznea
2019-06-27 15:53 ` [PATCH v2 7/7] clk: at91: sckc: use dedicated functions to unregister clock Claudiu Beznea
6 siblings, 1 reply; 15+ messages in thread
From: Claudiu Beznea @ 2019-06-27 15:53 UTC (permalink / raw)
To: mturquette, sboyd, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: linux-clk, linux-arm-kernel, linux-kernel, Claudiu Beznea
Remove unnecessary line.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clk/at91/sckc.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c
index a2b905c91085..c61b6c9ddb94 100644
--- a/drivers/clk/at91/sckc.c
+++ b/drivers/clk/at91/sckc.c
@@ -601,7 +601,6 @@ static void __init of_sama5d4_sckc_setup(struct device_node *np)
osc->startup_usec = 1200000;
osc->bits = &at91sama5d4_bits;
- hw = &osc->hw;
ret = clk_hw_register(NULL, &osc->hw);
if (ret) {
kfree(osc);
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 6/7] clk: at91: sckc: improve error path for sama5d4 sck registration
2019-06-27 15:53 [PATCH v2 0/7] clk: at91: sckc: improve error path Claudiu Beznea
` (4 preceding siblings ...)
2019-06-27 15:53 ` [PATCH v2 5/7] clk: at91: sckc: remove unnecessary line Claudiu Beznea
@ 2019-06-27 15:53 ` Claudiu Beznea
2019-06-27 18:22 ` Stephen Boyd
2019-06-27 15:53 ` [PATCH v2 7/7] clk: at91: sckc: use dedicated functions to unregister clock Claudiu Beznea
6 siblings, 1 reply; 15+ messages in thread
From: Claudiu Beznea @ 2019-06-27 15:53 UTC (permalink / raw)
To: mturquette, sboyd, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: linux-clk, linux-arm-kernel, linux-kernel, Claudiu Beznea
Improve error path for sama5d4 sck registration.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clk/at91/sckc.c | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c
index c61b6c9ddb94..f7ad3e9414dc 100644
--- a/drivers/clk/at91/sckc.c
+++ b/drivers/clk/at91/sckc.c
@@ -568,7 +568,7 @@ static const struct clk_slow_bits at91sama5d4_bits = {
static void __init of_sama5d4_sckc_setup(struct device_node *np)
{
void __iomem *regbase = of_iomap(np, 0);
- struct clk_hw *hw;
+ struct clk_hw *slow_rc, *slowck;
struct clk_sama5d4_slow_osc *osc;
struct clk_init_data init;
const char *xtal_name;
@@ -578,17 +578,18 @@ static void __init of_sama5d4_sckc_setup(struct device_node *np)
if (!regbase)
return;
- hw = clk_hw_register_fixed_rate_with_accuracy(NULL, parent_names[0],
- NULL, 0, 32768,
- 250000000);
- if (IS_ERR(hw))
+ slow_rc = clk_hw_register_fixed_rate_with_accuracy(NULL,
+ parent_names[0],
+ NULL, 0, 32768,
+ 250000000);
+ if (IS_ERR(slow_rc))
return;
xtal_name = of_clk_get_parent_name(np, 0);
osc = kzalloc(sizeof(*osc), GFP_KERNEL);
if (!osc)
- return;
+ goto unregister_slow_rc;
init.name = parent_names[1];
init.ops = &sama5d4_slow_osc_ops;
@@ -602,17 +603,29 @@ static void __init of_sama5d4_sckc_setup(struct device_node *np)
osc->bits = &at91sama5d4_bits;
ret = clk_hw_register(NULL, &osc->hw);
- if (ret) {
- kfree(osc);
- return;
- }
+ if (ret)
+ goto free_slow_osc_data;
- hw = at91_clk_register_sam9x5_slow(regbase, "slowck", parent_names, 2,
- &at91sama5d4_bits);
- if (IS_ERR(hw))
- return;
+ slowck = at91_clk_register_sam9x5_slow(regbase, "slowck",
+ parent_names, 2,
+ &at91sama5d4_bits);
+ if (IS_ERR(slowck))
+ goto unregister_slow_osc;
- of_clk_add_hw_provider(np, of_clk_hw_simple_get, hw);
+ ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, slowck);
+ if (WARN_ON(ret))
+ goto unregister_slowck;
+
+ return;
+
+unregister_slowck:
+ at91_clk_unregister_sam9x5_slow(slowck);
+unregister_slow_osc:
+ clk_hw_unregister(&osc->hw);
+free_slow_osc_data:
+ kfree(osc);
+unregister_slow_rc:
+ clk_hw_unregister(slow_rc);
}
CLK_OF_DECLARE(sama5d4_clk_sckc, "atmel,sama5d4-sckc",
of_sama5d4_sckc_setup);
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 7/7] clk: at91: sckc: use dedicated functions to unregister clock
2019-06-27 15:53 [PATCH v2 0/7] clk: at91: sckc: improve error path Claudiu Beznea
` (5 preceding siblings ...)
2019-06-27 15:53 ` [PATCH v2 6/7] clk: at91: sckc: improve error path for sama5d4 sck registration Claudiu Beznea
@ 2019-06-27 15:53 ` Claudiu Beznea
2019-06-27 18:22 ` Stephen Boyd
6 siblings, 1 reply; 15+ messages in thread
From: Claudiu Beznea @ 2019-06-27 15:53 UTC (permalink / raw)
To: mturquette, sboyd, nicolas.ferre, alexandre.belloni, ludovic.desroches
Cc: linux-clk, linux-arm-kernel, linux-kernel, Claudiu Beznea
Use at91 specific functions to free all resources in case of error.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/clk/at91/sckc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c
index f7ad3e9414dc..42502830a56a 100644
--- a/drivers/clk/at91/sckc.c
+++ b/drivers/clk/at91/sckc.c
@@ -514,13 +514,13 @@ static void __init of_sam9x60_sckc_setup(struct device_node *np)
return;
unregister_td_slck:
- clk_hw_unregister(clk_data->hws[1]);
+ at91_clk_unregister_sam9x5_slow(clk_data->hws[1]);
unregister_md_slck:
clk_hw_unregister(clk_data->hws[0]);
clk_data_free:
kfree(clk_data);
unregister_slow_osc:
- clk_hw_unregister(slow_osc);
+ at91_clk_unregister_slow_osc(slow_osc);
unregister_slow_rc:
clk_hw_unregister(slow_rc);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread