linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] stm class: initialize static variable in declaration
@ 2021-04-07 12:53 Yu Kuai
  2021-04-22  6:34 ` Alexander Shishkin
  0 siblings, 1 reply; 2+ messages in thread
From: Yu Kuai @ 2021-04-07 12:53 UTC (permalink / raw)
  To: alexander.shishkin, mcoquelin.stm32, alexandre.torgue
  Cc: linux-stm32, linux-arm-kernel, linux-kernel, yukuai3, yi.zhang,
	zhangxiaoxu5

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@huawei.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] stm class: initialize static variable in declaration
  2021-04-07 12:53 [PATCH] stm class: initialize static variable in declaration Yu Kuai
@ 2021-04-22  6:34 ` Alexander Shishkin
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Shishkin @ 2021-04-22  6:34 UTC (permalink / raw)
  To: Yu Kuai, mcoquelin.stm32, alexandre.torgue
  Cc: linux-stm32, linux-arm-kernel, linux-kernel, yukuai3, yi.zhang,
	zhangxiaoxu5, alexander.shishkin

Yu Kuai <yukuai3@huawei.com> writes:

> 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().

What's missing is the "why". We can do these or we can keep them as they
are. Each choice has impact on .text/.data, for instance. Why is one
preferred over the other?

Each patch should contain some form of analysis that shows that the
author thought about why they made the patch in the first
place.

And please learn not to spam the STMicro people with patches for System
Trace Module. Sometimes the same acronym can mean multiple different
things. This is another sign that the patch author spent zero time
getting to know the code that they are patching.

Regards,
--
Alex

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-04-22  6:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 12:53 [PATCH] stm class: initialize static variable in declaration Yu Kuai
2021-04-22  6:34 ` Alexander Shishkin

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).