Skip to contentSkip to conversation

mISDN: Use DEFINE_SPINLOCK() for spinlock

PATCH Applied Shixin Liu 2 participants 3 messages Mar 30, 2021

Subsystems (2)
lore
Share & tools
lore

Shixin Liu

author
#0 lore raw

PATCH v2 1/2 mISDN: Use DEFINE_SPINLOCK() for spinlock

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

Changelog:
From v1:
1. fix the mistake reported by kernel test robot.

---
 drivers/isdn/hardware/mISDN/hfcmulti.c | 7 ++-----
 drivers/isdn/mISDN/dsp_core.c          | 3 +--
 drivers/isdn/mISDN/l1oip_core.c        | 3 +--
 3 files changed, 4 insertions(+), 9 deletions(-)
drivers/isdn/hardware/mISDN/hfcmulti.c +2 -5
index 14092152b786..4f7eaa17fb27 100644
@@ -173,13 +173,13 @@
 #define	MAX_FRAGS	(32 * MAX_CARDS)
 
 static LIST_HEAD(HFClist);
-static spinlock_t HFClock; /* global hfc list lock */
+static DEFINE_SPINLOCK(HFClock); /* global hfc list lock */
 
 static void ph_state_change(struct dchannel *);
 
 static struct hfc_multi *syncmaster;
 static int plxsd_master; /* if we have a master card (yet) */
-static spinlock_t plx_lock; /* may not acquire other lock inside */
+static DEFINE_SPINLOCK(plx_lock); /* may not acquire other lock inside */
 
 #define	TYP_E1		1
 #define	TYP_4S		4
@@ -5480,9 +5480,6 @@ HFCmulti_init(void)
 	printk(KERN_DEBUG "%s: IRQ_DEBUG IS ENABLED!\n", __func__);
 #endif
 
-	spin_lock_init(&HFClock);
-	spin_lock_init(&plx_lock);
-
 	if (debug & DEBUG_HFCMULTI_INIT)
 		printk(KERN_DEBUG "%s: init entered\n", __func__);
 
drivers/isdn/mISDN/dsp_core.c +1 -2
index 4946ea14bf74..8766095cd6e7 100644
@@ -176,7 +176,7 @@ MODULE_LICENSE("GPL");
 
 /*int spinnest = 0;*/
 
-spinlock_t dsp_lock; /* global dsp lock */
+DEFINE_SPINLOCK(dsp_lock); /* global dsp lock */
 struct list_head dsp_ilist;
 struct list_head conf_ilist;
 int dsp_debug;
@@ -1169,7 +1169,6 @@ static int __init dsp_init(void)
 	printk(KERN_INFO "mISDN_dsp: DSP clocks every %d samples. This equals "
 	       "%d jiffies.\n", dsp_poll, dsp_tics);
 
-	spin_lock_init(&dsp_lock);
 	INIT_LIST_HEAD(&dsp_ilist);
 	INIT_LIST_HEAD(&conf_ilist);
 
drivers/isdn/mISDN/l1oip_core.c +1 -2
index facbd886ee1c..62fad8f1fc42 100644
@@ -229,7 +229,7 @@
 static const char *l1oip_revision = "2.00";
 
 static int l1oip_cnt;
-static spinlock_t l1oip_lock;
+static DEFINE_SPINLOCK(l1oip_lock);
 static struct list_head l1oip_ilist;
 
 #define MAX_CARDS	16
@@ -1441,7 +1441,6 @@ l1oip_init(void)
 	       l1oip_revision);
 
 	INIT_LIST_HEAD(&l1oip_ilist);
-	spin_lock_init(&l1oip_lock);
 
 	if (l1oip_4bit_alloc(ulaw))
 		return -ENOMEM;
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 2/2 mISDN: 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/isdn/mISDN/dsp_core.c   | 7 ++-----
 drivers/isdn/mISDN/l1oip_core.c | 4 +---
 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/isdn/mISDN/dsp_core.c +2 -5
index 8766095cd6e7..386084530c2f 100644
@@ -177,8 +177,8 @@ MODULE_LICENSE("GPL");
 /*int spinnest = 0;*/
 
 DEFINE_SPINLOCK(dsp_lock); /* global dsp lock */
-struct list_head dsp_ilist;
-struct list_head conf_ilist;
+LIST_HEAD(dsp_ilist);
+LIST_HEAD(conf_ilist);
 int dsp_debug;
 int dsp_options;
 int dsp_poll, dsp_tics;
@@ -1169,9 +1169,6 @@ static int __init dsp_init(void)
 	printk(KERN_INFO "mISDN_dsp: DSP clocks every %d samples. This equals "
 	       "%d jiffies.\n", dsp_poll, dsp_tics);
 
-	INIT_LIST_HEAD(&dsp_ilist);
-	INIT_LIST_HEAD(&conf_ilist);
-
 	/* init conversion tables */
 	dsp_audio_generate_law_tables();
 	dsp_silence = (dsp_options & DSP_OPT_ULAW) ? 0xff : 0x2a;
drivers/isdn/mISDN/l1oip_core.c +1 -3
index 62fad8f1fc42..2c40412466e6 100644
@@ -230,7 +230,7 @@ static const char *l1oip_revision = "2.00";
 
 static int l1oip_cnt;
 static DEFINE_SPINLOCK(l1oip_lock);
-static struct list_head l1oip_ilist;
+static LIST_HEAD(l1oip_ilist);
 
 #define MAX_CARDS	16
 static u_int type[MAX_CARDS];
@@ -1440,8 +1440,6 @@ l1oip_init(void)
 	printk(KERN_INFO "mISDN: Layer-1-over-IP driver Rev. %s\n",
 	       l1oip_revision);
 
-	INIT_LIST_HEAD(&l1oip_ilist);
-
 	if (l1oip_4bit_alloc(ulaw))
 		return -ENOMEM;
 
Signature · 1 line
2.25.1
#2 lore raw
In reply to Shixin Liu
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Tue, 30 Mar 2021 10:24:14 +0800 you wrote:

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

Changelog:
From v1:
1. fix the mistake reported by kernel test robot.

[...]

Here is the summary with links:
- [-next,v2,1/2] mISDN: Use DEFINE_SPINLOCK() for spinlock

    https://git.kernel.org/netdev/net-next/c/77053fb7b428
  - [-next,v2,2/2] mISDN: Use LIST_HEAD() for list_head
    https://git.kernel.org/netdev/net-next/c/5979415d00d4

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html