2013-08-01 23:00:20 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2003 Digi International (www.digi.com)
|
|
|
|
* Scott H Kilau <Scott_Kilau at digi dot com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
|
|
|
|
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
*
|
2013-08-21 17:08:05 +02:00
|
|
|
* NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE!
|
2013-08-01 23:00:20 +02:00
|
|
|
*
|
|
|
|
* This is shared code between Digi's CVS archive and the
|
|
|
|
* Linux Kernel sources.
|
|
|
|
* Changing the source just for reformatting needlessly breaks
|
|
|
|
* our CVS diff history.
|
|
|
|
*
|
2013-08-21 17:08:05 +02:00
|
|
|
* Send any bug fixes/changes to: Eng.Linux at digi dot com.
|
|
|
|
* Thank you.
|
2013-08-01 23:00:20 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************************************************************
|
2013-08-21 17:08:05 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
* This file implements the mgmt functionality for the
|
|
|
|
* Neo and ClassicBoard based product lines.
|
2013-08-21 17:08:05 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
************************************************************************
|
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/sched.h> /* For jiffies, task states */
|
|
|
|
#include <linux/interrupt.h> /* For tasklet and interrupt structs/defines */
|
|
|
|
#include <linux/serial_reg.h>
|
|
|
|
#include <linux/termios.h>
|
2014-03-10 23:10:12 +01:00
|
|
|
#include <linux/uaccess.h> /* For copy_from_user/copy_to_user */
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
#include "dgnc_driver.h"
|
|
|
|
#include "dgnc_pci.h"
|
|
|
|
#include "dgnc_kcompat.h" /* Kernel 2.4/2.6 compat includes */
|
|
|
|
#include "dgnc_mgmt.h"
|
|
|
|
#include "dpacompat.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Our "in use" variables, to enforce 1 open only */
|
|
|
|
static int dgnc_mgmt_in_use[MAXMGMTDEVICES];
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2013-08-21 17:08:05 +02:00
|
|
|
* dgnc_mgmt_open()
|
2013-08-01 23:00:20 +02:00
|
|
|
*
|
|
|
|
* Open the mgmt/downld/dpa device
|
2013-08-21 17:08:05 +02:00
|
|
|
*/
|
2013-08-01 23:00:20 +02:00
|
|
|
int dgnc_mgmt_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
unsigned int minor = iminor(inode);
|
|
|
|
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_lock_irqsave(&dgnc_global_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* mgmt device */
|
|
|
|
if (minor < MAXMGMTDEVICES) {
|
|
|
|
/* Only allow 1 open at a time on mgmt device */
|
|
|
|
if (dgnc_mgmt_in_use[minor]) {
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EBUSY;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
dgnc_mgmt_in_use[minor]++;
|
2014-03-10 23:08:06 +01:00
|
|
|
} else {
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENXIO;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_mgmt_close()
|
|
|
|
*
|
|
|
|
* Open the mgmt/dpa device
|
2013-08-21 17:08:05 +02:00
|
|
|
*/
|
2013-08-01 23:00:20 +02:00
|
|
|
int dgnc_mgmt_close(struct inode *inode, struct file *file)
|
|
|
|
{
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
unsigned int minor = iminor(inode);
|
|
|
|
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_lock_irqsave(&dgnc_global_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* mgmt device */
|
|
|
|
if (minor < MAXMGMTDEVICES) {
|
2014-03-10 23:09:11 +01:00
|
|
|
if (dgnc_mgmt_in_use[minor])
|
2013-08-01 23:00:20 +02:00
|
|
|
dgnc_mgmt_in_use[minor] = 0;
|
|
|
|
}
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_mgmt_ioctl()
|
|
|
|
*
|
|
|
|
* ioctl the mgmt/dpa device
|
2013-08-21 17:08:05 +02:00
|
|
|
*/
|
2013-08-20 20:15:36 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|
|
|
{
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
void __user *uarg = (void __user *) arg;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
|
|
|
case DIGI_GETDD:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This returns the total number of boards
|
|
|
|
* in the system, as well as driver version
|
|
|
|
* and has space for a reserved entry
|
|
|
|
*/
|
|
|
|
struct digi_dinfo ddi;
|
|
|
|
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_lock_irqsave(&dgnc_global_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ddi.dinfo_nboards = dgnc_NumBoards;
|
|
|
|
sprintf(ddi.dinfo_version, "%s", DG_PART);
|
|
|
|
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-03-11 07:00:03 +01:00
|
|
|
if (copy_to_user(uarg, &ddi, sizeof(ddi)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DIGI_GETBD:
|
|
|
|
{
|
|
|
|
int brd;
|
|
|
|
|
|
|
|
struct digi_info di;
|
|
|
|
|
2014-03-10 23:09:11 +01:00
|
|
|
if (copy_from_user(&brd, uarg, sizeof(int)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-03-14 00:17:03 +01:00
|
|
|
if ((brd < 0) || (brd > dgnc_NumBoards) ||
|
|
|
|
(dgnc_NumBoards == 0))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENODEV;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
memset(&di, 0, sizeof(di));
|
|
|
|
|
|
|
|
di.info_bdnum = brd;
|
|
|
|
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_lock_irqsave(&dgnc_Board[brd]->bd_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
di.info_bdtype = dgnc_Board[brd]->dpatype;
|
|
|
|
di.info_bdstate = dgnc_Board[brd]->dpastatus;
|
|
|
|
di.info_ioport = 0;
|
|
|
|
di.info_physaddr = (ulong) dgnc_Board[brd]->membase;
|
|
|
|
di.info_physsize = (ulong) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end;
|
|
|
|
if (dgnc_Board[brd]->state != BOARD_FAILED)
|
|
|
|
di.info_nports = dgnc_Board[brd]->nasync;
|
|
|
|
else
|
|
|
|
di.info_nports = 0;
|
|
|
|
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_unlock_irqrestore(&dgnc_Board[brd]->bd_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-03-11 07:00:03 +01:00
|
|
|
if (copy_to_user(uarg, &di, sizeof(di)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DIGI_GET_NI_INFO:
|
|
|
|
{
|
|
|
|
struct channel_t *ch;
|
|
|
|
struct ni_info ni;
|
|
|
|
uchar mstat = 0;
|
|
|
|
uint board = 0;
|
|
|
|
uint channel = 0;
|
|
|
|
|
2014-03-10 23:09:11 +01:00
|
|
|
if (copy_from_user(&ni, uarg, sizeof(ni)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
board = ni.board;
|
|
|
|
channel = ni.channel;
|
|
|
|
|
|
|
|
/* Verify boundaries on board */
|
2013-10-19 09:56:44 +02:00
|
|
|
if ((board > dgnc_NumBoards) || (dgnc_NumBoards == 0))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENODEV;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* Verify boundaries on channel */
|
|
|
|
if ((channel < 0) || (channel > dgnc_Board[board]->nasync))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENODEV;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch = dgnc_Board[board]->channels[channel];
|
|
|
|
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENODEV;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
memset(&ni, 0, sizeof(ni));
|
|
|
|
ni.board = board;
|
|
|
|
ni.channel = channel;
|
|
|
|
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
mstat = (ch->ch_mostat | ch->ch_mistat);
|
|
|
|
|
|
|
|
if (mstat & UART_MCR_DTR) {
|
|
|
|
ni.mstat |= TIOCM_DTR;
|
|
|
|
ni.dtr = TIOCM_DTR;
|
|
|
|
}
|
|
|
|
if (mstat & UART_MCR_RTS) {
|
|
|
|
ni.mstat |= TIOCM_RTS;
|
|
|
|
ni.rts = TIOCM_RTS;
|
|
|
|
}
|
|
|
|
if (mstat & UART_MSR_CTS) {
|
|
|
|
ni.mstat |= TIOCM_CTS;
|
|
|
|
ni.cts = TIOCM_CTS;
|
|
|
|
}
|
|
|
|
if (mstat & UART_MSR_RI) {
|
|
|
|
ni.mstat |= TIOCM_RI;
|
|
|
|
ni.ri = TIOCM_RI;
|
|
|
|
}
|
|
|
|
if (mstat & UART_MSR_DCD) {
|
|
|
|
ni.mstat |= TIOCM_CD;
|
|
|
|
ni.dcd = TIOCM_CD;
|
|
|
|
}
|
|
|
|
if (mstat & UART_MSR_DSR)
|
|
|
|
ni.mstat |= TIOCM_DSR;
|
|
|
|
|
|
|
|
ni.iflag = ch->ch_c_iflag;
|
|
|
|
ni.oflag = ch->ch_c_oflag;
|
|
|
|
ni.cflag = ch->ch_c_cflag;
|
|
|
|
ni.lflag = ch->ch_c_lflag;
|
|
|
|
|
2014-03-14 00:17:03 +01:00
|
|
|
if (ch->ch_digi.digi_flags & CTSPACE ||
|
|
|
|
ch->ch_c_cflag & CRTSCTS)
|
2013-08-01 23:00:20 +02:00
|
|
|
ni.hflow = 1;
|
|
|
|
else
|
|
|
|
ni.hflow = 0;
|
|
|
|
|
2014-03-14 00:17:03 +01:00
|
|
|
if ((ch->ch_flags & CH_STOPI) ||
|
|
|
|
(ch->ch_flags & CH_FORCED_STOPI))
|
2013-08-01 23:00:20 +02:00
|
|
|
ni.recv_stopped = 1;
|
|
|
|
else
|
|
|
|
ni.recv_stopped = 0;
|
|
|
|
|
|
|
|
if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP))
|
|
|
|
ni.xmit_stopped = 1;
|
|
|
|
else
|
|
|
|
ni.xmit_stopped = 0;
|
|
|
|
|
|
|
|
ni.curtx = ch->ch_txcount;
|
|
|
|
ni.currx = ch->ch_rxcount;
|
|
|
|
|
|
|
|
ni.baud = ch->ch_old_baud;
|
|
|
|
|
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>
2014-09-26 22:58:36 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (copy_to_user(uarg, &ni, sizeof(ni)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|