Skip to contentSkip to conversation

HYSDN cards: use spin_lock_init() for spinlock

PATCH In review Matthias Kaehlcke 3 participants 5 messages Apr 11, 2007 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HYSDN cards: use spin_lock_init() for spinlock

HYSDN cards: use spin_lock_init() for spinlock initialization

---

drivers/isdn/hysdn/hysdn_proclog.c +2 -1
index f7e83a8..168fd56 100644
@@ -299,7 +299,8 @@ hysdn_log_close(struct inode *ino, struct file *filep)
 	hysdn_card *card;
 	int retval = 0;
 	unsigned long flags;
-	spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
+	spinlock_t hysdn_lock;
+	spin_lock_init(&hysdn_lock);
 
 	lock_kernel();
 	if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) = FMODE_WRITE) {
Signature · 16 lines
Matthias Kaehlcke
Linux Application Developer
Barcelona


   Usually when people are sad, they don't do anything. They just cry over
     their condition. But when they get angry, they bring about a change
                              (Malcolm X)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
#1 lore raw
Quoted 9 lines · Matthias Kaehlcke

HYSDN cards: use spin_lock_init() for spinlock initialization

---

drivers/isdn/hysdn/hysdn_proclog.c +0 -0
index f7e83a8..168fd56 100644

drivers/isdn/hysdn/hysdn_proclog.c hysdn_log_close(struct inode *ino, struct file *filep) · line 303

Quoted 6 lines
drivers/isdn/hysdn/hysdn_proclog.c +2 -1
@@ -299,7 +299,8 @@ hysdn_log_close(struct inode *ino, struct file *filep)
        hysdn_card *card;
        int retval = 0;
        unsigned long flags;
-       spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
+       spinlock_t hysdn_lock;
+       spin_lock_init(&hysdn_lock);

use DEFINE_SPINLOCK() instead,for static/compile time initialization

spin_lock_init() is for runtime

Signature · 5 lines
Milind Arun Choudhary
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
#2 lore raw
In reply to Matthias Kaehlcke

El Wed, Apr 11, 2007 at 01:37:50PM +0530 Milind Arun Choudhary ha dit:

Quoted 20 lines · Matthias Kaehlcke
Quoted 10 lines

HYSDN cards: use spin_lock_init() for spinlock initialization

---

drivers/isdn/hysdn/hysdn_proclog.c +0 -0
index f7e83a8..168fd56 100644

drivers/isdn/hysdn/hysdn_proclog.c hysdn_log_close(struct inode *ino, struct file *filep) · line 303

Quoted 6 lines
drivers/isdn/hysdn/hysdn_proclog.c +2 -1
@@ -299,7 +299,8 @@ hysdn_log_close(struct inode *ino, struct file *filep)
       hysdn_card *card;
       int retval = 0;
       unsigned long flags;
-       spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
+       spinlock_t hysdn_lock;
+       spin_lock_init(&hysdn_lock);

use DEFINE_SPINLOCK() instead,for static/compile time initialization

Quoted 1 line

spin_lock_init() is for runtime

thanks for your comment, i have corrected this

---

HYSDN cards: use DEFINE_SPINLOCK() for spinlock declaration and initialization instead of declaring the spinlock and assigning it to SPIN_LOCK_UNLOCKED

---

drivers/isdn/hysdn/hysdn_proclog.c +1 -1
index f7e83a8..53e8de6 100644
@@ -299,7 +299,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
 	hysdn_card *card;
 	int retval = 0;
 	unsigned long flags;
-	spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
+	DEFINE_SPINLOCK(hysdn_lock);
 
 	lock_kernel();
 	if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) = FMODE_WRITE) {
Signature · 15 lines
Matthias Kaehlcke
Linux Application Developer
Barcelona


  The salvation of mankind lies only in making everything the concern of all
                         (Alexander Solzhenitsyn)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
#3 lore raw
In reply to Matthias Kaehlcke

drivers/isdn/hysdn/hysdn_proclog.c hysdn_log_close(struct inode *ino, struct file *filep) · line 303

Quoted 11 lines · Matthias Kaehlcke

HYSDN cards: use spin_lock_init() for spinlock initialization

drivers/isdn/hysdn/hysdn_proclog.c +2 -1
@@ -299,7 +299,8 @@ hysdn_log_close(struct inode *ino, struct file *filep)
 	hysdn_card *card;
 	int retval = 0;
 	unsigned long flags;
-	spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
+	spinlock_t hysdn_lock;
+	spin_lock_init(&hysdn_lock);

Wow! Second spinlock on stack I've seen.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#4 lore raw
In reply to Matthias Kaehlcke

El Wed, Apr 11, 2007 at 03:23:07PM +0400 Alexey Dobriyan ha dit:

Quoted 14 lines · Matthias Kaehlcke

drivers/isdn/hysdn/hysdn_proclog.c hysdn_log_close(struct inode *ino, struct file *filep) · line 303

Quoted 11 lines

HYSDN cards: use spin_lock_init() for spinlock initialization

drivers/isdn/hysdn/hysdn_proclog.c +2 -1
@@ -299,7 +299,8 @@ hysdn_log_close(struct inode *ino, struct file *filep)
 	hysdn_card *card;
 	int retval = 0;
 	unsigned long flags;
-	spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
+	spinlock_t hysdn_lock;
+	spin_lock_init(&hysdn_lock);

Wow! Second spinlock on stack I've seen.

now that you say it, it really looks odd. the declaration doesn't make sense and the calls to spin_lock_irqsave() and spin_unlock_irqrestore() should probably receive card->hysdn_lock as parameter instead of the spinlock on stack.

Signature · 15 lines
Matthias Kaehlcke
Linux Application Developer
Barcelona

                If you don't know where you are going,
               you will probably end up somewhere else
                         (Laurence J. Peter)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors