staging: dgnc: dgnc_mgmt.c: Replace non-standard spinlock’s macros

Author: Roberta Dobrescu <roberta.dobrescu@gmail.com>

This patch replaces non-standard spinlock's macros.
It is done using coccinelle and the following semantic patch:

@@
expression x;
@@

- DGNC_SPINLOCK_INIT(x)
+ spin_lock_init(&x)

@@
expression x, y;
@@

- DGNC_LOCK(x, y)
+ spin_lock_irqsave(&x, y)

@@
expression x, y;
@@

- DGNC_UNLOCK(x, y)
+ spin_unlock_irqrestore(&x, y)

@used_by_lock exists@
typedef ulong;
symbol lock_flags;
position p1, p2;
@@

(
 ulong lock_flags@p1;
|
 unsigned long lock_flags@p2;
)
...
(
 spin_lock_irqsave(..., lock_flags)
|
 spin_unlock_irqrestore(..., lock_flags)
)

@@
position used_by_lock.p1, used_by_lock.p2;
@@

(
- ulong lock_flags@p1;
+ unsigned long flags;
|
- unsigned long lock_flags@p2;
+ unsigned long flags;
)
<...
- lock_flags
+ flags
...>

Signed-off-by: Roberta Dobrescu 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/dgnc/dgnc_mgmt.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
 
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index 31e9f45..9e45b85 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -62,25 +62,25 @@ static int dgnc_mgmt_in_use[MAXMGMTDEVICES];
  */
 int dgnc_mgmt_open(struct inode *inode, struct file *file)
 {
-	unsigned long lock_flags;
+	unsigned long flags;
 	unsigned int minor = iminor(inode);
 
-	DGNC_LOCK(dgnc_global_lock, lock_flags);
+	spin_lock_irqsave(&dgnc_global_lock, flags);
 
 	/* mgmt device */
 	if (minor < MAXMGMTDEVICES) {
 		/* Only allow 1 open at a time on mgmt device */
 		if (dgnc_mgmt_in_use[minor]) {
-			DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+			spin_unlock_irqrestore(&dgnc_global_lock, flags);
 			return -EBUSY;
 		}
 		dgnc_mgmt_in_use[minor]++;
 	} else {
-		DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+		spin_unlock_irqrestore(&dgnc_global_lock, flags);
 		return -ENXIO;
 	}
 
-	DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+	spin_unlock_irqrestore(&dgnc_global_lock, flags);
 
 	return 0;
 }
@@ -93,17 +93,17 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file)
  */
 int dgnc_mgmt_close(struct inode *inode, struct file *file)
 {
-	unsigned long lock_flags;
+	unsigned long flags;
 	unsigned int minor = iminor(inode);
 
-	DGNC_LOCK(dgnc_global_lock, lock_flags);
+	spin_lock_irqsave(&dgnc_global_lock, flags);
 
 	/* mgmt device */
 	if (minor < MAXMGMTDEVICES) {
 		if (dgnc_mgmt_in_use[minor])
 			dgnc_mgmt_in_use[minor] = 0;
 	}
-	DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+	spin_unlock_irqrestore(&dgnc_global_lock, flags);
 
 	return 0;
 }
@@ -117,7 +117,7 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file)
 
 long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-	unsigned long lock_flags;
+	unsigned long flags;
 	void __user *uarg = (void __user *) arg;
 
 	switch (cmd) {
@@ -131,12 +131,12 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		 */
 		struct digi_dinfo ddi;
 
-		DGNC_LOCK(dgnc_global_lock, lock_flags);
+		spin_lock_irqsave(&dgnc_global_lock, flags);
 
 		ddi.dinfo_nboards = dgnc_NumBoards;
 		sprintf(ddi.dinfo_version, "%s", DG_PART);
 
-		DGNC_UNLOCK(dgnc_global_lock, lock_flags);
+		spin_unlock_irqrestore(&dgnc_global_lock, flags);
 
 		if (copy_to_user(uarg, &ddi, sizeof(ddi)))
 			return -EFAULT;
@@ -161,7 +161,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 		di.info_bdnum = brd;
 
-		DGNC_LOCK(dgnc_Board[brd]->bd_lock, lock_flags);
+		spin_lock_irqsave(&dgnc_Board[brd]->bd_lock, flags);
 
 		di.info_bdtype = dgnc_Board[brd]->dpatype;
 		di.info_bdstate = dgnc_Board[brd]->dpastatus;
@@ -173,7 +173,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		else
 			di.info_nports = 0;
 
-		DGNC_UNLOCK(dgnc_Board[brd]->bd_lock, lock_flags);
+		spin_unlock_irqrestore(&dgnc_Board[brd]->bd_lock, flags);
 
 		if (copy_to_user(uarg, &di, sizeof(di)))
 			return -EFAULT;
@@ -212,7 +212,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		ni.board = board;
 		ni.channel = channel;
 
-		DGNC_LOCK(ch->ch_lock, lock_flags);
+		spin_lock_irqsave(&ch->ch_lock, flags);
 
 		mstat = (ch->ch_mostat | ch->ch_mistat);
 
@@ -266,7 +266,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 		ni.baud = ch->ch_old_baud;
 
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		spin_unlock_irqrestore(&ch->ch_lock, flags);
 
 		if (copy_to_user(uarg, &ni, sizeof(ni)))
 			return -EFAULT;
BtrLinux
Résumé de la politique de confidentialité

Ce site utilise des cookies afin que nous puissions vous fournir la meilleure expérience utilisateur possible. Les informations sur les cookies sont stockées dans votre navigateur et remplissent des fonctions telles que vous reconnaître lorsque vous revenez sur notre site Web et aider notre équipe à comprendre les sections du site que vous trouvez les plus intéressantes et utiles.