linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 -next] staging: vc04_services: use DEFINE_MUTEX() for mutex lock
@ 2021-01-05  2:05 Zheng Yongjun
  2021-01-05  6:02 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Zheng Yongjun @ 2021-01-05  2:05 UTC (permalink / raw)
  To: nsaenzjulienne, bcm-kernel-feedback-list, devel, linux-kernel
  Cc: gregkh, Zheng Yongjun

mutex lock can be initialized automatically with DEFINE_MUTEX()
rather than explicitly calling mutex_init().

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 .../vc04_services/interface/vchiq_arm/vchiq_connected.c     | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c
index 79b75efa6868..938307f39b9c 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c
@@ -12,15 +12,13 @@ static   int                        g_connected;
 static   int                        g_num_deferred_callbacks;
 static   VCHIQ_CONNECTED_CALLBACK_T g_deferred_callback[MAX_CALLBACKS];
 static   int                        g_once_init;
-static   struct mutex               g_connected_mutex;
+static   DEFINE_MUTEX(g_connected_mutex);
 
 /* Function to initialize our lock */
 static void connected_init(void)
 {
-	if (!g_once_init) {
-		mutex_init(&g_connected_mutex);
+	if (!g_once_init)
 		g_once_init = 1;
-	}
 }
 
 /*
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 -next] staging: vc04_services: use DEFINE_MUTEX() for mutex lock
  2021-01-05  2:05 [PATCH v3 -next] staging: vc04_services: use DEFINE_MUTEX() for mutex lock Zheng Yongjun
@ 2021-01-05  6:02 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-01-05  6:02 UTC (permalink / raw)
  To: Zheng Yongjun
  Cc: nsaenzjulienne, bcm-kernel-feedback-list, devel, linux-kernel

On Tue, Jan 05, 2021 at 10:05:47AM +0800, Zheng Yongjun wrote:
> mutex lock can be initialized automatically with DEFINE_MUTEX()
> rather than explicitly calling mutex_init().
> 
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
>  .../vc04_services/interface/vchiq_arm/vchiq_connected.c     | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c
> index 79b75efa6868..938307f39b9c 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c
> @@ -12,15 +12,13 @@ static   int                        g_connected;
>  static   int                        g_num_deferred_callbacks;
>  static   VCHIQ_CONNECTED_CALLBACK_T g_deferred_callback[MAX_CALLBACKS];
>  static   int                        g_once_init;
> -static   struct mutex               g_connected_mutex;
> +static   DEFINE_MUTEX(g_connected_mutex);
>  
>  /* Function to initialize our lock */
>  static void connected_init(void)
>  {
> -	if (!g_once_init) {
> -		mutex_init(&g_connected_mutex);
> +	if (!g_once_init)
>  		g_once_init = 1;
> -	}

Why do you still need g_once_init now?


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-05  6:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05  2:05 [PATCH v3 -next] staging: vc04_services: use DEFINE_MUTEX() for mutex lock Zheng Yongjun
2021-01-05  6:02 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).