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.
|
|
|
|
*/
|
|
|
|
|
2016-11-18 23:49:24 +01:00
|
|
|
/*
|
2013-08-01 23:00:20 +02:00
|
|
|
* This file implements the mgmt functionality for the
|
|
|
|
* Neo and ClassicBoard based product lines.
|
|
|
|
*/
|
2016-11-18 23:49:24 +01:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/ctype.h>
|
2017-03-28 01:28:37 +02:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/interrupt.h>
|
2013-08-01 23:00:20 +02:00
|
|
|
#include <linux/serial_reg.h>
|
|
|
|
#include <linux/termios.h>
|
2017-03-28 01:28:37 +02:00
|
|
|
#include <linux/uaccess.h>
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
#include "dgnc_driver.h"
|
|
|
|
#include "dgnc_pci.h"
|
|
|
|
#include "dgnc_mgmt.h"
|
|
|
|
|
|
|
|
/* Our "in use" variables, to enforce 1 open only */
|
|
|
|
static int dgnc_mgmt_in_use[MAXMGMTDEVICES];
|
|
|
|
|
2017-03-28 01:28:37 +02:00
|
|
|
/**
|
|
|
|
* dgnc_mgmt_open() - 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);
|
2017-03-07 10:57:02 +01:00
|
|
|
int rc = 0;
|
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_lock_irqsave(&dgnc_global_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2017-03-07 10:57:02 +01:00
|
|
|
if (minor >= MAXMGMTDEVICES) {
|
|
|
|
rc = -ENXIO;
|
|
|
|
goto out;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
2017-03-07 10:57:02 +01:00
|
|
|
/* Only allow 1 open at a time on mgmt device */
|
|
|
|
if (dgnc_mgmt_in_use[minor]) {
|
|
|
|
rc = -EBUSY;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
dgnc_mgmt_in_use[minor]++;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2017-03-07 10:57:02 +01:00
|
|
|
out:
|
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);
|
2017-03-13 02:37:33 +01:00
|
|
|
|
2017-03-07 10:57:02 +01:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2017-03-28 01:28:37 +02:00
|
|
|
/**
|
|
|
|
* dgnc_mgmt_close() - Close 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);
|
2017-03-07 10:57:02 +01:00
|
|
|
int rc = 0;
|
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_lock_irqsave(&dgnc_global_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2017-03-07 10:57:02 +01:00
|
|
|
if (minor >= MAXMGMTDEVICES) {
|
|
|
|
rc = -ENXIO;
|
|
|
|
goto out;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
2017-03-07 10:57:02 +01:00
|
|
|
dgnc_mgmt_in_use[minor] = 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2017-03-07 10:57:02 +01:00
|
|
|
out:
|
|
|
|
spin_unlock_irqrestore(&dgnc_global_lock, flags);
|
2017-03-13 02:37:33 +01:00
|
|
|
|
2017-03-07 10:57:02 +01:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2017-03-28 01:28:37 +02:00
|
|
|
/**
|
|
|
|
* dgnc_mgmt_ioctl() - Ioctl the mgmt/dpa device.
|
2013-08-21 17:08:05 +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;
|
2015-10-04 16:20:13 +02:00
|
|
|
void __user *uarg = (void __user *)arg;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2015-10-14 17:48:02 +02:00
|
|
|
memset(&ddi, 0, sizeof(ddi));
|
2016-03-23 12:54:36 +01:00
|
|
|
ddi.dinfo_nboards = dgnc_num_boards;
|
2013-08-01 23:00:20 +02:00
|
|
|
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
|
|
|
|
2016-03-23 12:54:36 +01:00
|
|
|
if (brd < 0 || brd >= dgnc_num_boards)
|
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;
|
|
|
|
|
2016-03-23 12:54:36 +01:00
|
|
|
spin_lock_irqsave(&dgnc_board[brd]->bd_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2016-03-23 12:54:36 +01:00
|
|
|
di.info_bdtype = dgnc_board[brd]->dpatype;
|
|
|
|
di.info_bdstate = dgnc_board[brd]->dpastatus;
|
2013-08-01 23:00:20 +02:00
|
|
|
di.info_ioport = 0;
|
2016-03-23 12:54:36 +01:00
|
|
|
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;
|
2013-08-01 23:00:20 +02:00
|
|
|
else
|
|
|
|
di.info_nports = 0;
|
|
|
|
|
2016-03-23 12:54:36 +01: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;
|
2014-10-01 22:04:48 +02:00
|
|
|
unsigned char mstat = 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
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;
|
|
|
|
|
2016-03-23 12:54:36 +01:00
|
|
|
if (board >= dgnc_num_boards)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENODEV;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2016-03-23 12:54:36 +01:00
|
|
|
if (channel >= dgnc_board[board]->nasync)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENODEV;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2016-03-23 12:54:36 +01:00
|
|
|
ch = dgnc_board[board]->channels[channel];
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2017-03-28 01:28:38 +02:00
|
|
|
if (!ch)
|
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
|
|
|
|
2016-02-23 17:34:56 +01:00
|
|
|
mstat = ch->ch_mostat | ch->ch_mistat;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|