Skip to contentSkip to conversation

mtip32xx: use DEFINE_SPINLOCK() for spinlock

PATCH Applied Shixin Liu 2 participants 3 messages Mar 29, 2021 Block layer

lore
Share & tools
lore

Shixin Liu

author
#0 lore raw

PATCH 1/2 mtip32xx: use DEFINE_SPINLOCK() for spinlock

spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

---
 drivers/block/mtip32xx/mtip32xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +1 -3
index 3be0dbc674bd..39e3280030d6 100644
@@ -97,7 +97,7 @@ static int instance;
 
 static struct list_head online_list;
 static struct list_head removing_list;
-static spinlock_t dev_lock;
+static DEFINE_SPINLOCK(dev_lock);
 
 /*
  * Global variable used to hold the major block device number
@@ -4363,8 +4363,6 @@ static int __init mtip_init(void)
 
 	pr_info(MTIP_DRV_NAME " Version " MTIP_DRV_VERSION "\n");
 
-	spin_lock_init(&dev_lock);
-
 	INIT_LIST_HEAD(&online_list);
 	INIT_LIST_HEAD(&removing_list);
 
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/2 mtip32xx: use LIST_HEAD() for list_head

There's no need to declare a list and then init it manually, just use the LIST_HEAD() macro.

---
 drivers/block/mtip32xx/mtip32xx.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +2 -5
index 39e3280030d6..07c8b99b88c1 100644
@@ -95,8 +95,8 @@
 /* Device instance number, incremented each time a device is probed. */
 static int instance;
 
-static struct list_head online_list;
-static struct list_head removing_list;
+static LIST_HEAD(online_list);
+static LIST_HEAD(removing_list);
 static DEFINE_SPINLOCK(dev_lock);
 
 /*
@@ -4363,9 +4363,6 @@ static int __init mtip_init(void)
 
 	pr_info(MTIP_DRV_NAME " Version " MTIP_DRV_VERSION "\n");
 
-	INIT_LIST_HEAD(&online_list);
-	INIT_LIST_HEAD(&removing_list);
-
 	/* Allocate a major block device number to use with this driver. */
 	error = register_blkdev(0, MTIP_DRV_NAME);
 	if (error <= 0) {
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw
In reply to Shixin Liu
Quoted 2 lines · Shixin Liu

spinlock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

Applied both, thanks.

Signature · 1 line
Jens Axboe