[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210407125358.4135345-1-yukuai3@huawei.com>
Date: Wed, 7 Apr 2021 20:53:58 +0800
From: Yu Kuai <yukuai3@...wei.com>
To: <alexander.shishkin@...ux.intel.com>, <mcoquelin.stm32@...il.com>,
<alexandre.torgue@...s.st.com>
CC: <linux-stm32@...md-mailman.stormreply.com>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <yukuai3@...wei.com>,
<yi.zhang@...wei.com>, <zhangxiaoxu5@...wei.com>
Subject: [PATCH] stm class: initialize static variable in declaration
mutex lock can be initialized automatically with DEFINE_MUTEX()
rather than explicitly calling mutex_init().
list head can be initialized automatically with LIST_HEAD() rather
than explicitly calling INIT_LIST_HEAD().
srcu_struct can be initialized automatically with DEFINE_STATIC_SRCU()
rather than explicitly calling init_srcu_struct().
Reported-by: Hulk Robot <hulkci@...wei.com>
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
drivers/hwtracing/stm/core.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 2712e699ba08..1e13993e7969 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -31,7 +31,7 @@ static unsigned int stm_core_up;
* stm_source_write() caller, which may want to have as little overhead as
* possible.
*/
-static struct srcu_struct stm_source_srcu;
+DEFINE_STATIC_SRCU(stm_source_srcu);
static ssize_t masters_show(struct device *dev,
struct device_attribute *attr,
@@ -366,8 +366,8 @@ static int major_match(struct device *dev, const void *data)
* Modules can implement STM protocol drivers and (un-)register them
* with the STM class framework.
*/
-static struct list_head stm_pdrv_head;
-static struct mutex stm_pdrv_mutex;
+static LIST_HEAD(stm_pdrv_head);
+static DEFINE_MUTEX(stm_pdrv_mutex);
struct stm_pdrv_entry {
struct list_head entry;
@@ -1324,10 +1324,6 @@ static int __init stm_core_init(void)
if (err)
goto err_src;
- init_srcu_struct(&stm_source_srcu);
- INIT_LIST_HEAD(&stm_pdrv_head);
- mutex_init(&stm_pdrv_mutex);
-
/*
* So as to not confuse existing users with a requirement
* to load yet another module, do it here.
--
2.25.4
Powered by blists - more mailing lists