Skip to contentSkip to conversation

clk: renesas: r8a77970: Use DEFINE_SPINLOCK() for spinlock

PATCH In review Ye Bin 3 participants 3 messages Apr 9, 2021 – Apr 12, 2021

Subsystems (3)
lore
Share & tools
lore

Ye Bin

author
#0 lore raw

PATCH 1/1 clk: renesas: r8a77970: Use DEFINE_SPINLOCK() for spinlock

spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

---
 drivers/clk/renesas/r8a77970-cpg-mssr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clk/renesas/r8a77970-cpg-mssr.c +1 -3
index 0f59c84229a8..7b153c6f299c 100644
@@ -47,7 +47,7 @@ enum clk_ids {
 	MOD_CLK_BASE
 };
 
-static spinlock_t cpg_lock;
+static DEFINE_SPINLOCK(cpg_lock);
 
 static const struct clk_div_table cpg_sd0h_div_table[] = {
 	{  0,  2 }, {  1,  3 }, {  2,  4 }, {  3,  6 },
@@ -212,8 +212,6 @@ static int __init r8a77970_cpg_mssr_init(struct device *dev)
 	if (error)
 		return error;
 
-	spin_lock_init(&cpg_lock);
-
 	cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
 
 	return rcar_gen3_cpg_init(cpg_pll_config, CLK_EXTALR, cpg_mode);
#2 lore raw
In reply to Ye Bin

Hi Ye,

Quoted 5 lines · Ye Bin

spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

Thanks for your patch, which looks correct to me.

drivers/clk/renesas/r8a77970-cpg-mssr.c enum clk_ids { · line 50

Quoted 8 lines
drivers/clk/renesas/r8a77970-cpg-mssr.c +1 -1
@@ -47,7 +47,7 @@ enum clk_ids {
        MOD_CLK_BASE
 };
 
-static spinlock_t cpg_lock;
+static DEFINE_SPINLOCK(cpg_lock);

I think a better fix would be to start using the common cpg_lock, by #including rcar-cpg-lib.h.

drivers/clk/renesas/r8a77970-cpg-mssr.c static int __init r8a77970_cpg_mssr_init(struct device *dev) · line 217

Quoted 12 lines
drivers/clk/renesas/r8a77970-cpg-mssr.c +0 -2
 static const struct clk_div_table cpg_sd0h_div_table[] = {
        {  0,  2 }, {  1,  3 }, {  2,  4 }, {  3,  6 },
@@ -212,8 +212,6 @@ static int __init r8a77970_cpg_mssr_init(struct device *dev)
        if (error)
                return error;
 
-       spin_lock_init(&cpg_lock);
-
        cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
 
        return rcar_gen3_cpg_init(cpg_pll_config, CLK_EXTALR, cpg_mode);

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds