Skip to contentSkip to conversation

usbip: vudc: Make use of the helper macro LIST_HEAD()

PATCH In review Cai Huoqing 2 participants 4 messages Feb 9, 2022 – Feb 10, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usbip: vudc: Make use of the helper macro LIST_HEAD()

Replace "struct list_head head = LIST_HEAD_INIT(head)" with "LIST_HEAD(head)" to simplify the code.

---
 drivers/usb/usbip/vudc_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/usbip/vudc_main.c +1 -1
index 678faa82598c..d43252b77efd 100644
@@ -26,7 +26,7 @@ static struct platform_driver vudc_driver = {
 	},
 };
 
-static struct list_head vudc_devices = LIST_HEAD_INIT(vudc_devices);
+static LIST_HEAD(vudc_devices);
 
 static int __init init(void)
 {
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 14 lines · Cai Huoqing

Replace "struct list_head head = LIST_HEAD_INIT(head)" with "LIST_HEAD(head)" to simplify the code.

---
  drivers/usb/usbip/vudc_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/usbip/vudc_main.c +0 -0
index 678faa82598c..d43252b77efd 100644

drivers/usb/usbip/vudc_main.c static struct platform_driver vudc_driver = { · line 32

Quoted 8 lines
drivers/usb/usbip/vudc_main.c +1 -1
@@ -26,7 +26,7 @@ static struct platform_driver vudc_driver = {
  	},
  };
 
-static struct list_head vudc_devices = LIST_HEAD_INIT(vudc_devices);
+static LIST_HEAD(vudc_devices);
 
  static int __init init(void)
  {

Explain why this change simplifies the code and also add a comment above LIST_HEAD

LIST_HEAD_INIT clearly states what it does, as a result it is easier to understand the code.

thanks,
-- Shuah

#2 lore raw
Quoted 9 lines · Shuah Khan
Quoted 8 lines · Cai Huoqing

Replace "struct list_head head = LIST_HEAD_INIT(head)" with "LIST_HEAD(head)" to simplify the code.

---
  drivers/usb/usbip/vudc_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

drivers/usb/usbip/vudc_main.c static struct platform_driver vudc_driver = { · line 31

Quoted 12 lines
drivers/usb/usbip/vudc_main.c +1 -1
index 678faa82598c..d43252b77efd 100644
@@ -26,7 +26,7 @@ static struct platform_driver vudc_driver = {
  	},
  };
-static struct list_head vudc_devices = LIST_HEAD_INIT(vudc_devices);
+static LIST_HEAD(vudc_devices);
  static int __init init(void)
  {
 

Explain why this change simplifies the code and also add a comment above LIST_HEAD

LIST_HEAD() help to clean up the code "struct list_head vudc_devices = ". we only to care the variable 'vudc_devices',

Quoted 3 lines

LIST_HEAD_INIT clearly states what it does, as a result it is easier to understand the code.

LIST_HEAD() is defined for 17 years, lots of drivers use it directly. It's not about code readability.

Thanks,
Cai

Quoted 3 lines

thanks,
-- Shuah

maintainer
#3 lore raw
Quoted 25 lines · Cai Huoqing
Quoted 9 lines · Shuah Khan
Quoted 8 lines · Cai Huoqing

Replace "struct list_head head = LIST_HEAD_INIT(head)" with "LIST_HEAD(head)" to simplify the code.

---
   drivers/usb/usbip/vudc_main.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

drivers/usb/usbip/vudc_main.c static struct platform_driver vudc_driver = { · line 31

Quoted 12 lines
drivers/usb/usbip/vudc_main.c +1 -1
index 678faa82598c..d43252b77efd 100644
@@ -26,7 +26,7 @@ static struct platform_driver vudc_driver = {
   	},
   };
-static struct list_head vudc_devices = LIST_HEAD_INIT(vudc_devices);
+static LIST_HEAD(vudc_devices);
   static int __init init(void)
   {
 

Explain why this change simplifies the code and also add a comment above LIST_HEAD

Quoted 3 lines

LIST_HEAD() help to clean up the code "struct list_head vudc_devices = ". we only to care the variable 'vudc_devices',

Quoted 1 line

How does LIST_HEAD() make it simpler. It does that I am sure. I am looking for you to explain how it does in the change log.

thanks,
-- Shuah