diff mbox series

[-next] clk: renesas: r8a77970: Use DEFINE_SPINLOCK() for spinlock

Message ID 20210409095150.2294437-1-yebin10@huawei.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series [-next] clk: renesas: r8a77970: Use DEFINE_SPINLOCK() for spinlock | expand

Commit Message

yebin (H) April 9, 2021, 9:51 a.m. UTC
spinlock can be initialized automatically with DEFINE_SPINLOCK()
rather than explicitly calling spin_lock_init().

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 drivers/clk/renesas/r8a77970-cpg-mssr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Stephen Boyd April 9, 2021, 4:54 p.m. UTC | #1
Quoting Ye Bin (2021-04-09 02:51:50)
> spinlock can be initialized automatically with DEFINE_SPINLOCK()
> rather than explicitly calling spin_lock_init().
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---

Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Geert Uytterhoeven April 12, 2021, 9:24 a.m. UTC | #2
Hi Ye,

On Fri, Apr 9, 2021 at 11:43 AM Ye Bin <yebin10@huawei.com> wrote:
> spinlock can be initialized automatically with DEFINE_SPINLOCK()
> rather than explicitly calling spin_lock_init().
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Ye Bin <yebin10@huawei.com>

Thanks for your patch, which looks correct to me.

> --- a/drivers/clk/renesas/r8a77970-cpg-mssr.c
> +++ b/drivers/clk/renesas/r8a77970-cpg-mssr.c
> @@ -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.

>
>  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
diff mbox series

Patch

diff --git a/drivers/clk/renesas/r8a77970-cpg-mssr.c b/drivers/clk/renesas/r8a77970-cpg-mssr.c
index 0f59c84229a8..7b153c6f299c 100644
--- a/drivers/clk/renesas/r8a77970-cpg-mssr.c
+++ b/drivers/clk/renesas/r8a77970-cpg-mssr.c
@@ -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);