forked from Minki/linux
staging: dgnc: dgnc_mgmt.c: Replace non-standard spinlock's macros
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 <roberta.dobrescu@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
42c4d46e38
commit
9a03d7c8cf
@ -62,25 +62,25 @@ static int dgnc_mgmt_in_use[MAXMGMTDEVICES];
|
|||||||
*/
|
*/
|
||||||
int dgnc_mgmt_open(struct inode *inode, struct file *file)
|
int dgnc_mgmt_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
unsigned long lock_flags;
|
unsigned long flags;
|
||||||
unsigned int minor = iminor(inode);
|
unsigned int minor = iminor(inode);
|
||||||
|
|
||||||
DGNC_LOCK(dgnc_global_lock, lock_flags);
|
spin_lock_irqsave(&dgnc_global_lock, flags);
|
||||||
|
|
||||||
/* mgmt device */
|
/* mgmt device */
|
||||||
if (minor < MAXMGMTDEVICES) {
|
if (minor < MAXMGMTDEVICES) {
|
||||||
/* Only allow 1 open at a time on mgmt device */
|
/* Only allow 1 open at a time on mgmt device */
|
||||||
if (dgnc_mgmt_in_use[minor]) {
|
if (dgnc_mgmt_in_use[minor]) {
|
||||||
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
dgnc_mgmt_in_use[minor]++;
|
dgnc_mgmt_in_use[minor]++;
|
||||||
} else {
|
} else {
|
||||||
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
||||||
|
|
||||||
return 0;
|
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)
|
int dgnc_mgmt_close(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
unsigned long lock_flags;
|
unsigned long flags;
|
||||||
unsigned int minor = iminor(inode);
|
unsigned int minor = iminor(inode);
|
||||||
|
|
||||||
DGNC_LOCK(dgnc_global_lock, lock_flags);
|
spin_lock_irqsave(&dgnc_global_lock, flags);
|
||||||
|
|
||||||
/* mgmt device */
|
/* mgmt device */
|
||||||
if (minor < MAXMGMTDEVICES) {
|
if (minor < MAXMGMTDEVICES) {
|
||||||
if (dgnc_mgmt_in_use[minor])
|
if (dgnc_mgmt_in_use[minor])
|
||||||
dgnc_mgmt_in_use[minor] = 0;
|
dgnc_mgmt_in_use[minor] = 0;
|
||||||
}
|
}
|
||||||
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
||||||
|
|
||||||
return 0;
|
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)
|
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;
|
void __user *uarg = (void __user *) arg;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
@ -131,12 +131,12 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||||||
*/
|
*/
|
||||||
struct digi_dinfo ddi;
|
struct digi_dinfo ddi;
|
||||||
|
|
||||||
DGNC_LOCK(dgnc_global_lock, lock_flags);
|
spin_lock_irqsave(&dgnc_global_lock, flags);
|
||||||
|
|
||||||
ddi.dinfo_nboards = dgnc_NumBoards;
|
ddi.dinfo_nboards = dgnc_NumBoards;
|
||||||
sprintf(ddi.dinfo_version, "%s", DG_PART);
|
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)))
|
if (copy_to_user(uarg, &ddi, sizeof(ddi)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
@ -161,7 +161,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||||||
|
|
||||||
di.info_bdnum = brd;
|
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_bdtype = dgnc_Board[brd]->dpatype;
|
||||||
di.info_bdstate = dgnc_Board[brd]->dpastatus;
|
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
|
else
|
||||||
di.info_nports = 0;
|
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)))
|
if (copy_to_user(uarg, &di, sizeof(di)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
@ -212,7 +212,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||||||
ni.board = board;
|
ni.board = board;
|
||||||
ni.channel = channel;
|
ni.channel = channel;
|
||||||
|
|
||||||
DGNC_LOCK(ch->ch_lock, lock_flags);
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
||||||
|
|
||||||
mstat = (ch->ch_mostat | ch->ch_mistat);
|
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;
|
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)))
|
if (copy_to_user(uarg, &ni, sizeof(ni)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
Loading…
Reference in New Issue
Block a user