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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************************************************************
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
* This file implements the tty driver functionality for the
|
|
|
|
* Neo and ClassicBoard PCI based product lines.
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
************************************************************************
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h> /* For jiffies, task states */
|
|
|
|
#include <linux/interrupt.h> /* For tasklet and interrupt structs/defines */
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/tty_flip.h>
|
2015-03-13 14:56:32 +01:00
|
|
|
#include <linux/types.h>
|
2013-08-01 23:00:20 +02:00
|
|
|
#include <linux/serial_reg.h>
|
|
|
|
#include <linux/slab.h>
|
2013-08-21 19:30:11 +02:00
|
|
|
#include <linux/delay.h> /* For udelay */
|
2014-08-20 23:21:31 +02:00
|
|
|
#include <linux/uaccess.h> /* For copy_from_user/copy_to_user */
|
2013-08-01 23:00:20 +02:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include "dgnc_driver.h"
|
|
|
|
#include "dgnc_tty.h"
|
|
|
|
#include "dgnc_neo.h"
|
|
|
|
#include "dgnc_cls.h"
|
|
|
|
#include "dgnc_sysfs.h"
|
2014-08-06 14:21:23 +02:00
|
|
|
#include "dgnc_utils.h"
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* internal variables
|
|
|
|
*/
|
2013-09-09 21:01:22 +02:00
|
|
|
static struct dgnc_board *dgnc_BoardsByMajor[256];
|
2014-10-01 22:04:48 +02:00
|
|
|
static unsigned char *dgnc_TmpWriteBuf;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Default transparent print information.
|
|
|
|
*/
|
|
|
|
static struct digi_t dgnc_digi_init = {
|
|
|
|
.digi_flags = DIGI_COOK, /* Flags */
|
|
|
|
.digi_maxcps = 100, /* Max CPS */
|
|
|
|
.digi_maxchar = 50, /* Max chars in print queue */
|
|
|
|
.digi_bufsize = 100, /* Printer buffer size */
|
|
|
|
.digi_onlen = 4, /* size of printer on string */
|
|
|
|
.digi_offlen = 4, /* size of printer off string */
|
|
|
|
.digi_onstr = "\033[5i", /* ANSI printer on string ] */
|
|
|
|
.digi_offstr = "\033[4i", /* ANSI printer off string ] */
|
|
|
|
.digi_term = "ansi" /* default terminal type */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define a local default termios struct. All ports will be created
|
|
|
|
* with this termios initially.
|
|
|
|
*
|
|
|
|
* This defines a raw port at 9600 baud, 8 data bits, no parity,
|
|
|
|
* 1 stop bit.
|
|
|
|
*/
|
2014-09-18 20:38:04 +02:00
|
|
|
static struct ktermios DgncDefaultTermios = {
|
2013-08-01 23:00:20 +02:00
|
|
|
.c_iflag = (DEFAULT_IFLAGS), /* iflags */
|
|
|
|
.c_oflag = (DEFAULT_OFLAGS), /* oflags */
|
|
|
|
.c_cflag = (DEFAULT_CFLAGS), /* cflags */
|
|
|
|
.c_lflag = (DEFAULT_LFLAGS), /* lflags */
|
|
|
|
.c_cc = INIT_C_CC,
|
|
|
|
.c_line = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Our function prototypes */
|
|
|
|
static int dgnc_tty_open(struct tty_struct *tty, struct file *file);
|
|
|
|
static void dgnc_tty_close(struct tty_struct *tty, struct file *file);
|
2015-10-02 19:15:55 +02:00
|
|
|
static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file,
|
|
|
|
struct channel_t *ch);
|
|
|
|
static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
|
|
|
|
unsigned long arg);
|
|
|
|
static int dgnc_tty_digigeta(struct tty_struct *tty,
|
|
|
|
struct digi_t __user *retinfo);
|
|
|
|
static int dgnc_tty_digiseta(struct tty_struct *tty,
|
|
|
|
struct digi_t __user *new_info);
|
2013-08-21 19:27:15 +02:00
|
|
|
static int dgnc_tty_write_room(struct tty_struct *tty);
|
2013-08-01 23:00:20 +02:00
|
|
|
static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c);
|
2013-08-21 19:27:15 +02:00
|
|
|
static int dgnc_tty_chars_in_buffer(struct tty_struct *tty);
|
2013-08-01 23:00:20 +02:00
|
|
|
static void dgnc_tty_start(struct tty_struct *tty);
|
|
|
|
static void dgnc_tty_stop(struct tty_struct *tty);
|
|
|
|
static void dgnc_tty_throttle(struct tty_struct *tty);
|
|
|
|
static void dgnc_tty_unthrottle(struct tty_struct *tty);
|
|
|
|
static void dgnc_tty_flush_chars(struct tty_struct *tty);
|
|
|
|
static void dgnc_tty_flush_buffer(struct tty_struct *tty);
|
|
|
|
static void dgnc_tty_hangup(struct tty_struct *tty);
|
2015-10-02 19:15:55 +02:00
|
|
|
static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command,
|
|
|
|
unsigned int __user *value);
|
|
|
|
static int dgnc_get_modem_info(struct channel_t *ch,
|
|
|
|
unsigned int __user *value);
|
2013-08-01 23:00:20 +02:00
|
|
|
static int dgnc_tty_tiocmget(struct tty_struct *tty);
|
2015-10-02 19:15:55 +02:00
|
|
|
static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set,
|
|
|
|
unsigned int clear);
|
2013-08-01 23:00:20 +02:00
|
|
|
static int dgnc_tty_send_break(struct tty_struct *tty, int msec);
|
|
|
|
static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout);
|
2015-10-02 19:15:55 +02:00
|
|
|
static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf,
|
|
|
|
int count);
|
|
|
|
static void dgnc_tty_set_termios(struct tty_struct *tty,
|
|
|
|
struct ktermios *old_termios);
|
2013-08-01 23:00:20 +02:00
|
|
|
static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch);
|
|
|
|
|
|
|
|
static const struct tty_operations dgnc_tty_ops = {
|
|
|
|
.open = dgnc_tty_open,
|
|
|
|
.close = dgnc_tty_close,
|
|
|
|
.write = dgnc_tty_write,
|
|
|
|
.write_room = dgnc_tty_write_room,
|
|
|
|
.flush_buffer = dgnc_tty_flush_buffer,
|
|
|
|
.chars_in_buffer = dgnc_tty_chars_in_buffer,
|
|
|
|
.flush_chars = dgnc_tty_flush_chars,
|
|
|
|
.ioctl = dgnc_tty_ioctl,
|
|
|
|
.set_termios = dgnc_tty_set_termios,
|
|
|
|
.stop = dgnc_tty_stop,
|
|
|
|
.start = dgnc_tty_start,
|
|
|
|
.throttle = dgnc_tty_throttle,
|
|
|
|
.unthrottle = dgnc_tty_unthrottle,
|
|
|
|
.hangup = dgnc_tty_hangup,
|
|
|
|
.put_char = dgnc_tty_put_char,
|
|
|
|
.tiocmget = dgnc_tty_tiocmget,
|
|
|
|
.tiocmset = dgnc_tty_tiocmset,
|
|
|
|
.break_ctl = dgnc_tty_send_break,
|
|
|
|
.wait_until_sent = dgnc_tty_wait_until_sent,
|
|
|
|
.send_xchar = dgnc_tty_send_xchar
|
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
* TTY Initialization/Cleanup Functions
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
************************************************************************/
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
/*
|
|
|
|
* dgnc_tty_preinit()
|
|
|
|
*
|
|
|
|
* Initialize any global tty related data before we download any boards.
|
|
|
|
*/
|
|
|
|
int dgnc_tty_preinit(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Allocate a buffer for doing the copy from user space to
|
|
|
|
* kernel space in dgnc_write(). We only use one buffer and
|
|
|
|
* control access to it with a semaphore. If we are paging, we
|
|
|
|
* are already in trouble so one buffer won't hurt much anyway.
|
|
|
|
*
|
|
|
|
* We are okay to sleep in the malloc, as this routine
|
|
|
|
* is only called during module load, (not in interrupt context),
|
|
|
|
* and with no locks held.
|
|
|
|
*/
|
|
|
|
dgnc_TmpWriteBuf = kmalloc(WRITEBUFLEN, GFP_KERNEL);
|
|
|
|
|
2014-08-19 17:30:23 +02:00
|
|
|
if (!dgnc_TmpWriteBuf)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOMEM;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_register()
|
|
|
|
*
|
|
|
|
* Init the tty subsystem for this board.
|
|
|
|
*/
|
2013-09-09 21:01:22 +02:00
|
|
|
int dgnc_tty_register(struct dgnc_board *brd)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
brd->SerialDriver.magic = TTY_DRIVER_MAGIC;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum);
|
|
|
|
|
|
|
|
brd->SerialDriver.name = brd->SerialName;
|
|
|
|
brd->SerialDriver.name_base = 0;
|
|
|
|
brd->SerialDriver.major = 0;
|
|
|
|
brd->SerialDriver.minor_start = 0;
|
|
|
|
brd->SerialDriver.num = brd->maxports;
|
2013-08-21 17:08:11 +02:00
|
|
|
brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL;
|
|
|
|
brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL;
|
2013-08-01 23:00:20 +02:00
|
|
|
brd->SerialDriver.init_termios = DgncDefaultTermios;
|
|
|
|
brd->SerialDriver.driver_name = DRVSTR;
|
2015-10-02 19:15:55 +02:00
|
|
|
brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW |
|
|
|
|
TTY_DRIVER_DYNAMIC_DEV |
|
|
|
|
TTY_DRIVER_HARDWARE_BREAK);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
/*
|
2013-08-01 23:00:20 +02:00
|
|
|
* The kernel wants space to store pointers to
|
2013-08-21 17:08:11 +02:00
|
|
|
* tty_struct's and termios's.
|
2013-08-01 23:00:20 +02:00
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
brd->SerialDriver.ttys = kcalloc(brd->maxports,
|
|
|
|
sizeof(*brd->SerialDriver.ttys),
|
|
|
|
GFP_KERNEL);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (!brd->SerialDriver.ttys)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOMEM;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-21 19:30:11 +02:00
|
|
|
kref_init(&brd->SerialDriver.kref);
|
2015-10-02 19:15:55 +02:00
|
|
|
brd->SerialDriver.termios = kcalloc(brd->maxports,
|
|
|
|
sizeof(*brd->SerialDriver.termios),
|
|
|
|
GFP_KERNEL);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (!brd->SerialDriver.termios)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOMEM;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Entry points for driver. Called by the kernel from
|
|
|
|
* tty_io.c and n_tty.c.
|
|
|
|
*/
|
|
|
|
tty_set_operations(&brd->SerialDriver, &dgnc_tty_ops);
|
|
|
|
|
|
|
|
if (!brd->dgnc_Major_Serial_Registered) {
|
|
|
|
/* Register tty devices */
|
|
|
|
rc = tty_register_driver(&brd->SerialDriver);
|
|
|
|
if (rc < 0) {
|
2014-10-07 12:08:12 +02:00
|
|
|
dev_dbg(&brd->pdev->dev,
|
|
|
|
"Can't register tty device (%d)\n", rc);
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
2015-03-13 14:56:32 +01:00
|
|
|
brd->dgnc_Major_Serial_Registered = true;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're doing transparent print, we have to do all of the above
|
2013-09-13 17:46:31 +02:00
|
|
|
* again, separately so we don't get the LD confused about what major
|
2013-08-01 23:00:20 +02:00
|
|
|
* we are when we get into the dgnc_tty_open() routine.
|
|
|
|
*/
|
|
|
|
brd->PrintDriver.magic = TTY_DRIVER_MAGIC;
|
|
|
|
snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum);
|
|
|
|
|
|
|
|
brd->PrintDriver.name = brd->PrintName;
|
|
|
|
brd->PrintDriver.name_base = 0;
|
|
|
|
brd->PrintDriver.major = brd->SerialDriver.major;
|
|
|
|
brd->PrintDriver.minor_start = 0x80;
|
|
|
|
brd->PrintDriver.num = brd->maxports;
|
2013-08-21 17:08:11 +02:00
|
|
|
brd->PrintDriver.type = TTY_DRIVER_TYPE_SERIAL;
|
2013-08-01 23:00:20 +02:00
|
|
|
brd->PrintDriver.subtype = SERIAL_TYPE_NORMAL;
|
|
|
|
brd->PrintDriver.init_termios = DgncDefaultTermios;
|
|
|
|
brd->PrintDriver.driver_name = DRVSTR;
|
2015-10-02 19:15:55 +02:00
|
|
|
brd->PrintDriver.flags = (TTY_DRIVER_REAL_RAW |
|
|
|
|
TTY_DRIVER_DYNAMIC_DEV |
|
|
|
|
TTY_DRIVER_HARDWARE_BREAK);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The kernel wants space to store pointers to
|
2013-09-13 17:46:31 +02:00
|
|
|
* tty_struct's and termios's. Must be separated from
|
2013-08-01 23:00:20 +02:00
|
|
|
* the Serial Driver so we don't get confused
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
brd->PrintDriver.ttys = kcalloc(brd->maxports,
|
|
|
|
sizeof(*brd->PrintDriver.ttys),
|
|
|
|
GFP_KERNEL);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (!brd->PrintDriver.ttys)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOMEM;
|
2013-08-21 19:30:11 +02:00
|
|
|
kref_init(&brd->PrintDriver.kref);
|
2015-10-02 19:15:55 +02:00
|
|
|
brd->PrintDriver.termios = kcalloc(brd->maxports,
|
|
|
|
sizeof(*brd->PrintDriver.termios),
|
|
|
|
GFP_KERNEL);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (!brd->PrintDriver.termios)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOMEM;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Entry points for driver. Called by the kernel from
|
|
|
|
* tty_io.c and n_tty.c.
|
|
|
|
*/
|
|
|
|
tty_set_operations(&brd->PrintDriver, &dgnc_tty_ops);
|
|
|
|
|
|
|
|
if (!brd->dgnc_Major_TransparentPrint_Registered) {
|
|
|
|
/* Register Transparent Print devices */
|
2013-08-21 19:30:11 +02:00
|
|
|
rc = tty_register_driver(&brd->PrintDriver);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (rc < 0) {
|
2014-10-07 12:08:12 +02:00
|
|
|
dev_dbg(&brd->pdev->dev,
|
|
|
|
"Can't register Transparent Print device(%d)\n",
|
|
|
|
rc);
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
2015-03-13 14:56:32 +01:00
|
|
|
brd->dgnc_Major_TransparentPrint_Registered = true;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dgnc_BoardsByMajor[brd->SerialDriver.major] = brd;
|
|
|
|
brd->dgnc_Serial_Major = brd->SerialDriver.major;
|
|
|
|
brd->dgnc_TransparentPrint_Major = brd->PrintDriver.major;
|
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_init()
|
|
|
|
*
|
|
|
|
* Init the tty subsystem. Called once per board after board has been
|
|
|
|
* downloaded and init'ed.
|
|
|
|
*/
|
2013-09-09 21:01:22 +02:00
|
|
|
int dgnc_tty_init(struct dgnc_board *brd)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
|
|
|
int i;
|
2013-08-28 04:13:26 +02:00
|
|
|
void __iomem *vaddr;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
|
|
|
|
if (!brd)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENXIO;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize board structure elements.
|
|
|
|
*/
|
|
|
|
|
|
|
|
vaddr = brd->re_map_membase;
|
|
|
|
|
|
|
|
brd->nasync = brd->maxports;
|
|
|
|
|
|
|
|
for (i = 0; i < brd->nasync; i++) {
|
2015-04-10 01:42:29 +02:00
|
|
|
/*
|
|
|
|
* Okay to malloc with GFP_KERNEL, we are not at
|
|
|
|
* interrupt context, and there are no locks held.
|
|
|
|
*/
|
|
|
|
brd->channels[i] = kzalloc(sizeof(*brd->channels[i]),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!brd->channels[i])
|
|
|
|
goto err_free_channels;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ch = brd->channels[0];
|
|
|
|
vaddr = brd->re_map_membase;
|
|
|
|
|
|
|
|
/* Set up channel variables */
|
|
|
|
for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_init(&ch->ch_lock);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* Store all our magic numbers */
|
|
|
|
ch->magic = DGNC_CHANNEL_MAGIC;
|
|
|
|
ch->ch_tun.magic = DGNC_UNIT_MAGIC;
|
|
|
|
ch->ch_tun.un_ch = ch;
|
|
|
|
ch->ch_tun.un_type = DGNC_SERIAL;
|
|
|
|
ch->ch_tun.un_dev = i;
|
|
|
|
|
|
|
|
ch->ch_pun.magic = DGNC_UNIT_MAGIC;
|
|
|
|
ch->ch_pun.un_ch = ch;
|
|
|
|
ch->ch_pun.un_type = DGNC_PRINT;
|
|
|
|
ch->ch_pun.un_dev = i + 128;
|
|
|
|
|
|
|
|
if (brd->bd_uart_offset == 0x200)
|
2013-08-28 04:13:26 +02:00
|
|
|
ch->ch_neo_uart = vaddr + (brd->bd_uart_offset * i);
|
2013-08-01 23:00:20 +02:00
|
|
|
else
|
2013-08-28 04:13:26 +02:00
|
|
|
ch->ch_cls_uart = vaddr + (brd->bd_uart_offset * i);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_bd = brd;
|
|
|
|
ch->ch_portnum = i;
|
|
|
|
ch->ch_digi = dgnc_digi_init;
|
|
|
|
|
|
|
|
/* .25 second delay */
|
|
|
|
ch->ch_close_delay = 250;
|
|
|
|
|
|
|
|
init_waitqueue_head(&ch->ch_flags_wait);
|
|
|
|
init_waitqueue_head(&ch->ch_tun.un_flags_wait);
|
|
|
|
init_waitqueue_head(&ch->ch_pun.un_flags_wait);
|
|
|
|
|
|
|
|
{
|
|
|
|
struct device *classp;
|
2014-09-29 10:42:28 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
classp = tty_register_device(&brd->SerialDriver, i,
|
2015-10-04 16:20:15 +02:00
|
|
|
&ch->ch_bd->pdev->dev);
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_tun.un_sysfs = classp;
|
|
|
|
dgnc_create_tty_sysfs(&ch->ch_tun, classp);
|
|
|
|
|
|
|
|
classp = tty_register_device(&brd->PrintDriver, i,
|
2015-10-04 16:20:15 +02:00
|
|
|
&ch->ch_bd->pdev->dev);
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_pun.un_sysfs = classp;
|
|
|
|
dgnc_create_tty_sysfs(&ch->ch_pun, classp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2015-04-10 01:42:29 +02:00
|
|
|
|
|
|
|
err_free_channels:
|
|
|
|
for (i = i - 1; i >= 0; --i) {
|
|
|
|
kfree(brd->channels[i]);
|
|
|
|
brd->channels[i] = NULL;
|
|
|
|
}
|
|
|
|
return -ENOMEM;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_post_uninit()
|
|
|
|
*
|
|
|
|
* UnInitialize any global tty related data.
|
|
|
|
*/
|
|
|
|
void dgnc_tty_post_uninit(void)
|
|
|
|
{
|
2014-07-03 12:12:01 +02:00
|
|
|
kfree(dgnc_TmpWriteBuf);
|
|
|
|
dgnc_TmpWriteBuf = NULL;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_uninit()
|
|
|
|
*
|
|
|
|
* Uninitialize the TTY portion of this driver. Free all memory and
|
2013-08-21 17:08:11 +02:00
|
|
|
* resources.
|
2013-08-01 23:00:20 +02:00
|
|
|
*/
|
2013-09-09 21:01:22 +02:00
|
|
|
void dgnc_tty_uninit(struct dgnc_board *brd)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if (brd->dgnc_Major_Serial_Registered) {
|
|
|
|
dgnc_BoardsByMajor[brd->SerialDriver.major] = NULL;
|
|
|
|
brd->dgnc_Serial_Major = 0;
|
|
|
|
for (i = 0; i < brd->nasync; i++) {
|
2015-04-10 01:42:30 +02:00
|
|
|
if (brd->channels[i])
|
|
|
|
dgnc_remove_tty_sysfs(brd->channels[i]->
|
|
|
|
ch_tun.un_sysfs);
|
2013-08-01 23:00:20 +02:00
|
|
|
tty_unregister_device(&brd->SerialDriver, i);
|
|
|
|
}
|
|
|
|
tty_unregister_driver(&brd->SerialDriver);
|
2015-03-13 14:56:32 +01:00
|
|
|
brd->dgnc_Major_Serial_Registered = false;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (brd->dgnc_Major_TransparentPrint_Registered) {
|
|
|
|
dgnc_BoardsByMajor[brd->PrintDriver.major] = NULL;
|
|
|
|
brd->dgnc_TransparentPrint_Major = 0;
|
|
|
|
for (i = 0; i < brd->nasync; i++) {
|
2015-04-10 01:42:30 +02:00
|
|
|
if (brd->channels[i])
|
|
|
|
dgnc_remove_tty_sysfs(brd->channels[i]->
|
|
|
|
ch_pun.un_sysfs);
|
2013-08-01 23:00:20 +02:00
|
|
|
tty_unregister_device(&brd->PrintDriver, i);
|
|
|
|
}
|
|
|
|
tty_unregister_driver(&brd->PrintDriver);
|
2015-03-13 14:56:32 +01:00
|
|
|
brd->dgnc_Major_TransparentPrint_Registered = false;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2014-07-03 12:12:01 +02:00
|
|
|
kfree(brd->SerialDriver.ttys);
|
|
|
|
brd->SerialDriver.ttys = NULL;
|
2015-06-18 15:27:28 +02:00
|
|
|
kfree(brd->SerialDriver.termios);
|
|
|
|
brd->SerialDriver.termios = NULL;
|
2014-07-03 12:12:01 +02:00
|
|
|
kfree(brd->PrintDriver.ttys);
|
|
|
|
brd->PrintDriver.ttys = NULL;
|
2015-06-18 15:27:28 +02:00
|
|
|
kfree(brd->PrintDriver.termios);
|
|
|
|
brd->PrintDriver.termios = NULL;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*=======================================================================
|
|
|
|
*
|
|
|
|
* dgnc_wmove - Write data to transmit queue.
|
|
|
|
*
|
|
|
|
* ch - Pointer to channel structure.
|
2015-11-14 15:40:46 +01:00
|
|
|
* buf - Pointer to characters to be moved.
|
2013-08-01 23:00:20 +02:00
|
|
|
* n - Number of characters to move.
|
|
|
|
*
|
|
|
|
*=======================================================================*/
|
|
|
|
static void dgnc_wmove(struct channel_t *ch, char *buf, uint n)
|
|
|
|
{
|
|
|
|
int remain;
|
|
|
|
uint head;
|
|
|
|
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
head = ch->ch_w_head & WQUEUEMASK;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the write wraps over the top of the circular buffer,
|
|
|
|
* move the portion up to the wrap point, and reset the
|
|
|
|
* pointers to the bottom.
|
|
|
|
*/
|
|
|
|
remain = WQUEUESIZE - head;
|
|
|
|
|
|
|
|
if (n >= remain) {
|
2013-08-21 17:08:11 +02:00
|
|
|
n -= remain;
|
2013-08-01 23:00:20 +02:00
|
|
|
memcpy(ch->ch_wqueue + head, buf, remain);
|
|
|
|
head = 0;
|
|
|
|
buf += remain;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n > 0) {
|
|
|
|
/*
|
|
|
|
* Move rest of data.
|
|
|
|
*/
|
|
|
|
remain = n;
|
|
|
|
memcpy(ch->ch_wqueue + head, buf, remain);
|
|
|
|
head += remain;
|
|
|
|
}
|
|
|
|
|
|
|
|
head &= WQUEUEMASK;
|
|
|
|
ch->ch_w_head = head;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*=======================================================================
|
|
|
|
*
|
|
|
|
* dgnc_input - Process received data.
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-21 19:30:11 +02:00
|
|
|
* ch - Pointer to channel structure.
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
*=======================================================================*/
|
|
|
|
void dgnc_input(struct channel_t *ch)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct tty_struct *tp;
|
2015-03-11 15:22:01 +01:00
|
|
|
struct tty_ldisc *ld = NULL;
|
2013-08-01 23:00:20 +02:00
|
|
|
uint rmask;
|
|
|
|
ushort head;
|
|
|
|
ushort tail;
|
|
|
|
int data_len;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
int flip_len;
|
|
|
|
int len = 0;
|
|
|
|
int n = 0;
|
|
|
|
int s = 0;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tp = ch->ch_tun.un_tty;
|
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
2014-05-17 02:17:07 +02:00
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
2013-08-01 23:00:20 +02:00
|
|
|
return;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
/*
|
|
|
|
* Figure the number of characters in the buffer.
|
2013-08-01 23:00:20 +02:00
|
|
|
* Exit immediately if none.
|
|
|
|
*/
|
|
|
|
rmask = RQUEUEMASK;
|
|
|
|
head = ch->ch_r_head & rmask;
|
|
|
|
tail = ch->ch_r_tail & rmask;
|
|
|
|
data_len = (head - tail) & rmask;
|
|
|
|
|
2015-03-11 15:22:01 +01:00
|
|
|
if (data_len == 0)
|
|
|
|
goto exit_unlock;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the device is not open, or CREAD is off,
|
2013-08-21 19:30:11 +02:00
|
|
|
* flush input data and return immediately.
|
2013-08-01 23:00:20 +02:00
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
if (!tp || (tp->magic != TTY_MAGIC) ||
|
|
|
|
!(ch->ch_tun.un_flags & UN_ISOPEN) ||
|
|
|
|
!(tp->termios.c_cflag & CREAD) ||
|
|
|
|
(ch->ch_tun.un_flags & UN_CLOSING)) {
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_r_head = tail;
|
|
|
|
|
|
|
|
/* Force queue flow control to be released, if needed */
|
|
|
|
dgnc_check_queue_flow_control(ch);
|
|
|
|
|
2015-03-11 15:22:01 +01:00
|
|
|
goto exit_unlock;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we are throttled, simply don't read any data.
|
|
|
|
*/
|
2015-03-11 15:22:01 +01:00
|
|
|
if (ch->ch_flags & CH_FORCED_STOPI)
|
|
|
|
goto exit_unlock;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-13 21:49:58 +02:00
|
|
|
flip_len = TTY_FLIPBUF_SIZE;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* Chop down the length, if needed */
|
|
|
|
len = min(data_len, flip_len);
|
2013-08-13 21:49:58 +02:00
|
|
|
len = min(len, (N_TTY_BUF_SIZE - 1));
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ld = tty_ldisc_ref(tp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we were unable to get a reference to the ld,
|
|
|
|
* don't flush our buffer, and act like the ld doesn't
|
|
|
|
* have any space to put the data right now.
|
|
|
|
*/
|
|
|
|
if (!ld) {
|
|
|
|
len = 0;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If ld doesn't have a pointer to a receive_buf function,
|
|
|
|
* flush the data, then act like the ld doesn't have any
|
|
|
|
* space to put the data right now.
|
|
|
|
*/
|
|
|
|
if (!ld->ops->receive_buf) {
|
|
|
|
ch->ch_r_head = ch->ch_r_tail;
|
|
|
|
len = 0;
|
2013-08-21 17:08:11 +02:00
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2015-03-11 15:22:01 +01:00
|
|
|
if (len <= 0)
|
|
|
|
goto exit_unlock;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The tty layer in the kernel has changed in 2.6.16+.
|
|
|
|
*
|
|
|
|
* The flip buffers in the tty structure are no longer exposed,
|
|
|
|
* and probably will be going away eventually.
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
* If we are completely raw, we don't need to go through a lot
|
|
|
|
* of the tty layers that exist.
|
|
|
|
* In this case, we take the shortest and fastest route we
|
|
|
|
* can to relay the data to the user.
|
|
|
|
*
|
|
|
|
* On the other hand, if we are not raw, we need to go through
|
|
|
|
* the new 2.6.16+ tty layer, which has its API more well defined.
|
|
|
|
*/
|
2013-08-13 21:49:58 +02:00
|
|
|
len = tty_buffer_request_room(tp->port, len);
|
|
|
|
n = len;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-13 21:49:58 +02:00
|
|
|
/*
|
|
|
|
* n now contains the most amount of data we can copy,
|
|
|
|
* bounded either by how much the Linux tty layer can handle,
|
|
|
|
* or the amount of data the card actually has pending...
|
|
|
|
*/
|
|
|
|
while (n) {
|
|
|
|
s = ((head >= tail) ? head : RQUEUESIZE) - tail;
|
|
|
|
s = min(s, n);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-13 21:49:58 +02:00
|
|
|
if (s <= 0)
|
|
|
|
break;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
2013-08-21 17:08:11 +02:00
|
|
|
* If conditions are such that ld needs to see all
|
2013-08-13 21:49:58 +02:00
|
|
|
* UART errors, we will have to walk each character
|
|
|
|
* and error byte and send them to the buffer one at
|
|
|
|
* a time.
|
2013-08-01 23:00:20 +02:00
|
|
|
*/
|
2013-08-13 21:49:58 +02:00
|
|
|
if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) {
|
|
|
|
for (i = 0; i < s; i++) {
|
|
|
|
if (*(ch->ch_equeue + tail + i) & UART_LSR_BI)
|
2015-10-02 19:15:55 +02:00
|
|
|
tty_insert_flip_char(tp->port,
|
|
|
|
*(ch->ch_rqueue + tail + i),
|
|
|
|
TTY_BREAK);
|
|
|
|
else if (*(ch->ch_equeue + tail + i) &
|
|
|
|
UART_LSR_PE)
|
|
|
|
tty_insert_flip_char(tp->port,
|
|
|
|
*(ch->ch_rqueue + tail + i),
|
|
|
|
TTY_PARITY);
|
|
|
|
else if (*(ch->ch_equeue + tail + i) &
|
|
|
|
UART_LSR_FE)
|
|
|
|
tty_insert_flip_char(tp->port,
|
|
|
|
*(ch->ch_rqueue + tail + i),
|
|
|
|
TTY_FRAME);
|
2013-08-13 21:49:58 +02:00
|
|
|
else
|
2015-10-02 19:15:55 +02:00
|
|
|
tty_insert_flip_char(tp->port,
|
|
|
|
*(ch->ch_rqueue + tail + i),
|
|
|
|
TTY_NORMAL);
|
2013-08-13 21:49:58 +02:00
|
|
|
}
|
2014-05-18 01:54:29 +02:00
|
|
|
} else {
|
2015-10-02 19:15:55 +02:00
|
|
|
tty_insert_flip_string(tp->port,
|
|
|
|
ch->ch_rqueue + tail,
|
|
|
|
s);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2013-08-13 21:49:58 +02:00
|
|
|
tail += s;
|
|
|
|
n -= s;
|
|
|
|
/* Flip queue if needed */
|
|
|
|
tail &= rmask;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2013-08-13 21:49:58 +02:00
|
|
|
ch->ch_r_tail = tail & rmask;
|
|
|
|
ch->ch_e_tail = tail & rmask;
|
|
|
|
dgnc_check_queue_flow_control(ch);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-13 21:49:58 +02:00
|
|
|
/* Tell the tty layer its okay to "eat" the data now */
|
|
|
|
tty_flip_buffer_push(tp->port);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (ld)
|
|
|
|
tty_ldisc_deref(ld);
|
2015-03-11 15:22:01 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
exit_unlock:
|
2015-03-18 14:21:08 +01:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2015-03-11 15:22:01 +01:00
|
|
|
if (ld)
|
|
|
|
tty_ldisc_deref(ld);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
/************************************************************************
|
2013-08-01 23:00:20 +02:00
|
|
|
* Determines when CARRIER changes state and takes appropriate
|
2013-08-21 17:08:11 +02:00
|
|
|
* action.
|
2013-08-01 23:00:20 +02:00
|
|
|
************************************************************************/
|
|
|
|
void dgnc_carrier(struct channel_t *ch)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-21 19:30:11 +02:00
|
|
|
int virt_carrier = 0;
|
|
|
|
int phys_carrier = 0;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return;
|
|
|
|
|
2014-08-19 17:30:23 +02:00
|
|
|
if (ch->ch_mistat & UART_MSR_DCD)
|
2013-08-01 23:00:20 +02:00
|
|
|
phys_carrier = 1;
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (ch->ch_digi.digi_flags & DIGI_FORCEDCD)
|
2013-08-01 23:00:20 +02:00
|
|
|
virt_carrier = 1;
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (ch->ch_c_cflag & CLOCAL)
|
2013-08-01 23:00:20 +02:00
|
|
|
virt_carrier = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test for a VIRTUAL carrier transition to HIGH.
|
|
|
|
*/
|
|
|
|
if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) {
|
|
|
|
/*
|
|
|
|
* When carrier rises, wake any threads waiting
|
|
|
|
* for carrier in the open routine.
|
|
|
|
*/
|
|
|
|
|
2015-10-04 16:20:15 +02:00
|
|
|
if (waitqueue_active(&ch->ch_flags_wait))
|
2013-08-01 23:00:20 +02:00
|
|
|
wake_up_interruptible(&ch->ch_flags_wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test for a PHYSICAL carrier transition to HIGH.
|
|
|
|
*/
|
|
|
|
if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) {
|
|
|
|
/*
|
|
|
|
* When carrier rises, wake any threads waiting
|
|
|
|
* for carrier in the open routine.
|
|
|
|
*/
|
|
|
|
|
2015-10-04 16:20:15 +02:00
|
|
|
if (waitqueue_active(&ch->ch_flags_wait))
|
2013-08-01 23:00:20 +02:00
|
|
|
wake_up_interruptible(&ch->ch_flags_wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test for a PHYSICAL transition to low, so long as we aren't
|
|
|
|
* currently ignoring physical transitions (which is what "virtual
|
|
|
|
* carrier" indicates).
|
|
|
|
*
|
|
|
|
* The transition of the virtual carrier to low really doesn't
|
|
|
|
* matter... it really only means "ignore carrier state", not
|
|
|
|
* "make pretend that carrier is there".
|
|
|
|
*/
|
|
|
|
if ((virt_carrier == 0) && ((ch->ch_flags & CH_CD) != 0) &&
|
2014-09-18 20:38:04 +02:00
|
|
|
(phys_carrier == 0)) {
|
2013-08-01 23:00:20 +02:00
|
|
|
/*
|
|
|
|
* When carrier drops:
|
|
|
|
*
|
|
|
|
* Drop carrier on all open units.
|
|
|
|
*
|
|
|
|
* Flush queues, waking up any task waiting in the
|
|
|
|
* line discipline.
|
|
|
|
*
|
|
|
|
* Send a hangup to the control terminal.
|
|
|
|
*
|
|
|
|
* Enable all select calls.
|
|
|
|
*/
|
2015-10-04 16:20:15 +02:00
|
|
|
if (waitqueue_active(&ch->ch_flags_wait))
|
2013-08-01 23:00:20 +02:00
|
|
|
wake_up_interruptible(&ch->ch_flags_wait);
|
|
|
|
|
2014-08-19 17:30:23 +02:00
|
|
|
if (ch->ch_tun.un_open_count > 0)
|
2013-08-01 23:00:20 +02:00
|
|
|
tty_hangup(ch->ch_tun.un_tty);
|
|
|
|
|
2014-08-19 17:30:23 +02:00
|
|
|
if (ch->ch_pun.un_open_count > 0)
|
2013-08-01 23:00:20 +02:00
|
|
|
tty_hangup(ch->ch_pun.un_tty);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure that our cached values reflect the current reality.
|
|
|
|
*/
|
|
|
|
if (virt_carrier == 1)
|
|
|
|
ch->ch_flags |= CH_FCAR;
|
2013-08-21 17:08:11 +02:00
|
|
|
else
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_flags &= ~CH_FCAR;
|
|
|
|
|
|
|
|
if (phys_carrier == 1)
|
|
|
|
ch->ch_flags |= CH_CD;
|
|
|
|
else
|
|
|
|
ch->ch_flags &= ~CH_CD;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assign the custom baud rate to the channel structure
|
|
|
|
*/
|
|
|
|
static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate)
|
|
|
|
{
|
|
|
|
int testdiv;
|
|
|
|
int testrate_high;
|
2013-08-21 17:08:11 +02:00
|
|
|
int testrate_low;
|
2013-08-01 23:00:20 +02:00
|
|
|
int deltahigh;
|
|
|
|
int deltalow;
|
|
|
|
|
2014-03-11 04:19:06 +01:00
|
|
|
if (newrate <= 0) {
|
|
|
|
ch->ch_custom_speed = 0;
|
|
|
|
return;
|
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Since the divisor is stored in a 16-bit integer, we make sure
|
|
|
|
* we don't allow any rates smaller than a 16-bit integer would allow.
|
|
|
|
* And of course, rates above the dividend won't fly.
|
|
|
|
*/
|
|
|
|
if (newrate && newrate < ((ch->ch_bd->bd_dividend / 0xFFFF) + 1))
|
|
|
|
newrate = ((ch->ch_bd->bd_dividend / 0xFFFF) + 1);
|
|
|
|
|
|
|
|
if (newrate && newrate > ch->ch_bd->bd_dividend)
|
2013-08-21 19:30:11 +02:00
|
|
|
newrate = ch->ch_bd->bd_dividend;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-03-11 04:19:06 +01:00
|
|
|
if (newrate > 0) {
|
2013-08-01 23:00:20 +02:00
|
|
|
testdiv = ch->ch_bd->bd_dividend / newrate;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we try to figure out what rate the board would use
|
|
|
|
* with the test divisor, it will be either equal or higher
|
|
|
|
* than the requested baud rate. If we then determine the
|
2013-08-21 17:08:11 +02:00
|
|
|
* rate with a divisor one higher, we will get the next lower
|
2013-08-01 23:00:20 +02:00
|
|
|
* supported rate below the requested.
|
|
|
|
*/
|
|
|
|
testrate_high = ch->ch_bd->bd_dividend / testdiv;
|
|
|
|
testrate_low = ch->ch_bd->bd_dividend / (testdiv + 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the rate for the requested divisor is correct, just
|
|
|
|
* use it and be done.
|
|
|
|
*/
|
2014-03-11 04:19:06 +01:00
|
|
|
if (testrate_high != newrate) {
|
|
|
|
/*
|
2015-10-02 19:15:55 +02:00
|
|
|
* Otherwise, pick the rate that is closer
|
|
|
|
* (i.e. whichever rate has a smaller delta).
|
2014-03-11 04:19:06 +01:00
|
|
|
*/
|
|
|
|
deltahigh = testrate_high - newrate;
|
|
|
|
deltalow = newrate - testrate_low;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (deltahigh < deltalow)
|
2014-03-11 04:19:06 +01:00
|
|
|
newrate = testrate_high;
|
2014-05-18 01:54:31 +02:00
|
|
|
else
|
2014-03-11 04:19:06 +01:00
|
|
|
newrate = testrate_low;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
}
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_custom_speed = newrate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dgnc_check_queue_flow_control(struct channel_t *ch)
|
|
|
|
{
|
2015-10-15 10:25:45 +02:00
|
|
|
int qleft;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* Store how much space we have left in the queue */
|
staging:dgnc: Removed assignments from if statements.
Coccinelle was used for this patch. The script is not complete (semantically) and might raise some checkpatch warnings in terms of indentation depending on existing code.
*** IFASSIGNMENT.COCCI START ***
/* Coccinelle script to handle assignments in if statements
* For compound statements, can so far only handle statements with the
* assignment on either extreme */
/* This rule is for simple cases
* e.g. just an assignment in if, possibly with unary operator */
@simple@
expression E1, E2;
statement S1, S2;
@@
+ E1 = E2;
if (
- (E1 = E2)
+ E1
)
S1 else S2
/* This rule is for compound statements where the assignment is on the right.*/
@right@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ } else S2
|
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1
+ }
/* or */
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ }
+ else S1
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1) S1
+ } else
S1
/* not equal */
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1 else S2
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1
/* equal */
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1 else S2
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1
/* greater than */
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1 else S2
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1
/* less than */
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1 else S2
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1
/* lesser than or equal to */
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1 else S2
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1
/* greater than or equal to */
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1 else S2
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1
)
/* This rule is for compound statements where the assignment is on the left.*/
@left@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1 else S2
|
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1
|
/* or */
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1
|
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1 else S2
|
/* not equal */
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1
|
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1 else S2
|
/* equal */
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1
|
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1 else S2
|
/* greater */
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1
|
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1 else S2
|
/* less */
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1
|
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1 else S2
/* lesser than or equal to */
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1
|
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1 else S2
/* greater than or equal to */
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1
|
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1 else S2
)
*** IFASSIGNMENT.COCCI END ***
Signed-off-by: Chi Pham <fempsci@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-09 10:39:04 +01:00
|
|
|
qleft = ch->ch_r_tail - ch->ch_r_head - 1;
|
|
|
|
if (qleft < 0)
|
2013-08-01 23:00:20 +02:00
|
|
|
qleft += RQUEUEMASK + 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check to see if we should enforce flow control on our queue because
|
|
|
|
* the ld (or user) isn't reading data out of our queue fast enuf.
|
|
|
|
*
|
|
|
|
* NOTE: This is done based on what the current flow control of the
|
|
|
|
* port is set for.
|
|
|
|
*
|
|
|
|
* 1) HWFLOW (RTS) - Turn off the UART's Receive interrupt.
|
|
|
|
* This will cause the UART's FIFO to back up, and force
|
|
|
|
* the RTS signal to be dropped.
|
|
|
|
* 2) SWFLOW (IXOFF) - Keep trying to send a stop character to
|
|
|
|
* the other side, in hopes it will stop sending data to us.
|
|
|
|
* 3) NONE - Nothing we can do. We will simply drop any extra data
|
|
|
|
* that gets sent into us when the queue fills up.
|
|
|
|
*/
|
|
|
|
if (qleft < 256) {
|
|
|
|
/* HWFLOW */
|
2015-10-02 19:15:55 +02:00
|
|
|
if (ch->ch_digi.digi_flags & CTSPACE ||
|
|
|
|
ch->ch_c_cflag & CRTSCTS) {
|
2014-05-17 02:17:07 +02:00
|
|
|
if (!(ch->ch_flags & CH_RECEIVER_OFF)) {
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_bd->bd_ops->disable_receiver(ch);
|
|
|
|
ch->ch_flags |= (CH_RECEIVER_OFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* SWFLOW */
|
|
|
|
else if (ch->ch_c_iflag & IXOFF) {
|
|
|
|
if (ch->ch_stops_sent <= MAX_STOPS_SENT) {
|
|
|
|
ch->ch_bd->bd_ops->send_stop_character(ch);
|
|
|
|
ch->ch_stops_sent++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check to see if we should unenforce flow control because
|
|
|
|
* ld (or user) finally read enuf data out of our queue.
|
|
|
|
*
|
|
|
|
* NOTE: This is done based on what the current flow control of the
|
|
|
|
* port is set for.
|
|
|
|
*
|
|
|
|
* 1) HWFLOW (RTS) - Turn back on the UART's Receive interrupt.
|
|
|
|
* This will cause the UART's FIFO to raise RTS back up,
|
|
|
|
* which will allow the other side to start sending data again.
|
|
|
|
* 2) SWFLOW (IXOFF) - Send a start character to
|
|
|
|
* the other side, so it will start sending data to us again.
|
|
|
|
* 3) NONE - Do nothing. Since we didn't do anything to turn off the
|
|
|
|
* other side, we don't need to do anything now.
|
|
|
|
*/
|
|
|
|
if (qleft > (RQUEUESIZE / 2)) {
|
|
|
|
/* HWFLOW */
|
2015-10-02 19:15:55 +02:00
|
|
|
if (ch->ch_digi.digi_flags & RTSPACE ||
|
|
|
|
ch->ch_c_cflag & CRTSCTS) {
|
2013-08-01 23:00:20 +02:00
|
|
|
if (ch->ch_flags & CH_RECEIVER_OFF) {
|
|
|
|
ch->ch_bd->bd_ops->enable_receiver(ch);
|
|
|
|
ch->ch_flags &= ~(CH_RECEIVER_OFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* SWFLOW */
|
|
|
|
else if (ch->ch_c_iflag & IXOFF && ch->ch_stops_sent) {
|
|
|
|
ch->ch_stops_sent = 0;
|
|
|
|
ch->ch_bd->bd_ops->send_start_character(ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void dgnc_wakeup_writes(struct channel_t *ch)
|
|
|
|
{
|
|
|
|
int qlen = 0;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If channel now has space, wake up anyone waiting on the condition.
|
|
|
|
*/
|
staging:dgnc: Removed assignments from if statements.
Coccinelle was used for this patch. The script is not complete (semantically) and might raise some checkpatch warnings in terms of indentation depending on existing code.
*** IFASSIGNMENT.COCCI START ***
/* Coccinelle script to handle assignments in if statements
* For compound statements, can so far only handle statements with the
* assignment on either extreme */
/* This rule is for simple cases
* e.g. just an assignment in if, possibly with unary operator */
@simple@
expression E1, E2;
statement S1, S2;
@@
+ E1 = E2;
if (
- (E1 = E2)
+ E1
)
S1 else S2
/* This rule is for compound statements where the assignment is on the right.*/
@right@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ } else S2
|
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1
+ }
/* or */
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ }
+ else S1
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1) S1
+ } else
S1
/* not equal */
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1 else S2
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1
/* equal */
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1 else S2
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1
/* greater than */
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1 else S2
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1
/* less than */
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1 else S2
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1
/* lesser than or equal to */
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1 else S2
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1
/* greater than or equal to */
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1 else S2
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1
)
/* This rule is for compound statements where the assignment is on the left.*/
@left@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1 else S2
|
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1
|
/* or */
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1
|
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1 else S2
|
/* not equal */
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1
|
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1 else S2
|
/* equal */
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1
|
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1 else S2
|
/* greater */
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1
|
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1 else S2
|
/* less */
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1
|
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1 else S2
/* lesser than or equal to */
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1
|
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1 else S2
/* greater than or equal to */
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1
|
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1 else S2
)
*** IFASSIGNMENT.COCCI END ***
Signed-off-by: Chi Pham <fempsci@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-09 10:39:04 +01:00
|
|
|
qlen = ch->ch_w_head - ch->ch_w_tail;
|
|
|
|
if (qlen < 0)
|
2013-08-21 19:30:11 +02:00
|
|
|
qlen += WQUEUESIZE;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (qlen >= (WQUEUESIZE - 256)) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch->ch_tun.un_flags & UN_ISOPEN) {
|
2013-08-21 19:30:11 +02:00
|
|
|
if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
|
2015-10-04 16:20:14 +02:00
|
|
|
ch->ch_tun.un_tty->ldisc->ops->write_wakeup) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2015-10-04 16:20:15 +02:00
|
|
|
ch->ch_tun.un_tty->ldisc->ops->write_wakeup(ch->ch_tun.un_tty);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-21 19:30:11 +02:00
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If unit is set to wait until empty, check to make sure
|
|
|
|
* the queue AND FIFO are both empty.
|
|
|
|
*/
|
|
|
|
if (ch->ch_tun.un_flags & UN_EMPTY) {
|
2015-10-02 19:15:55 +02:00
|
|
|
if ((qlen == 0) &&
|
2015-10-04 16:20:14 +02:00
|
|
|
(ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) {
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_tun.un_flags &= ~(UN_EMPTY);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If RTS Toggle mode is on, whenever
|
|
|
|
* the queue and UART is empty, keep RTS low.
|
|
|
|
*/
|
|
|
|
if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) {
|
|
|
|
ch->ch_mostat &= ~(UART_MCR_RTS);
|
|
|
|
ch->ch_bd->bd_ops->assert_modem_signals(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If DTR Toggle mode is on, whenever
|
|
|
|
* the queue and UART is empty, keep DTR low.
|
|
|
|
*/
|
|
|
|
if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) {
|
|
|
|
ch->ch_mostat &= ~(UART_MCR_DTR);
|
|
|
|
ch->ch_bd->bd_ops->assert_modem_signals(ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wake_up_interruptible(&ch->ch_tun.un_flags_wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch->ch_pun.un_flags & UN_ISOPEN) {
|
2013-08-21 19:30:11 +02:00
|
|
|
if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
|
2015-10-04 16:20:14 +02:00
|
|
|
ch->ch_pun.un_tty->ldisc->ops->write_wakeup) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2015-10-04 16:20:15 +02:00
|
|
|
ch->ch_pun.un_tty->ldisc->ops->write_wakeup(ch->ch_pun.un_tty);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-21 19:30:11 +02:00
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
wake_up_interruptible(&ch->ch_pun.un_tty->write_wait);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If unit is set to wait until empty, check to make sure
|
|
|
|
* the queue AND FIFO are both empty.
|
|
|
|
*/
|
|
|
|
if (ch->ch_pun.un_flags & UN_EMPTY) {
|
2015-10-02 19:15:55 +02:00
|
|
|
if ((qlen == 0) &&
|
|
|
|
(ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0))
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_pun.un_flags &= ~(UN_EMPTY);
|
|
|
|
}
|
|
|
|
|
|
|
|
wake_up_interruptible(&ch->ch_pun.un_flags_wait);
|
|
|
|
}
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
* TTY Entry points and helper functions
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_open()
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *brd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
|
|
|
uint major = 0;
|
|
|
|
uint minor = 0;
|
|
|
|
int rc = 0;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
major = MAJOR(tty_devnum(tty));
|
|
|
|
minor = MINOR(tty_devnum(tty));
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (major > 255)
|
2013-08-01 23:00:20 +02:00
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
/* Get board pointer from our array of majors we have allocated */
|
|
|
|
brd = dgnc_BoardsByMajor[major];
|
2014-05-18 01:54:31 +02:00
|
|
|
if (!brd)
|
2013-08-01 23:00:20 +02:00
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If board is not yet up to a state of READY, go to
|
|
|
|
* sleep waiting for it to happen or they cancel the open.
|
|
|
|
*/
|
|
|
|
rc = wait_event_interruptible(brd->state_wait,
|
2015-10-04 16:20:14 +02:00
|
|
|
(brd->state & BOARD_READY));
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (rc)
|
2013-08-01 23:00:20 +02:00
|
|
|
return rc;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&brd->bd_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* If opened device is greater than our number of ports, bail. */
|
2015-03-12 18:24:31 +01:00
|
|
|
if (PORT_NUM(minor) >= brd->nasync) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&brd->bd_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
ch = brd->channels[PORT_NUM(minor)];
|
|
|
|
if (!ch) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&brd->bd_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Drop board lock */
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&brd->bd_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* Grab channel lock */
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* Figure out our type */
|
|
|
|
if (!IS_PRINT(minor)) {
|
|
|
|
un = &brd->channels[PORT_NUM(minor)]->ch_tun;
|
|
|
|
un->un_type = DGNC_SERIAL;
|
2014-05-18 01:54:29 +02:00
|
|
|
} else if (IS_PRINT(minor)) {
|
2013-08-01 23:00:20 +02:00
|
|
|
un = &brd->channels[PORT_NUM(minor)]->ch_pun;
|
|
|
|
un->un_type = DGNC_PRINT;
|
2014-05-18 01:54:29 +02:00
|
|
|
} else {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the port is still in a previous open, and in a state
|
|
|
|
* where we simply cannot safely keep going, wait until the
|
|
|
|
* state clears.
|
|
|
|
*/
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2015-10-02 19:15:55 +02:00
|
|
|
rc = wait_event_interruptible(ch->ch_flags_wait,
|
|
|
|
((ch->ch_flags & CH_OPENING) == 0));
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* If ret is non-zero, user ctrl-c'ed us */
|
2014-08-19 17:30:23 +02:00
|
|
|
if (rc)
|
2013-08-01 23:00:20 +02:00
|
|
|
return -EINTR;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If either unit is in the middle of the fragile part of close,
|
|
|
|
* we just cannot touch the channel safely.
|
|
|
|
* Go to sleep, knowing that when the channel can be
|
|
|
|
* touched safely, the close routine will signal the
|
|
|
|
* ch_flags_wait to wake us back up.
|
|
|
|
*/
|
|
|
|
rc = wait_event_interruptible(ch->ch_flags_wait,
|
2015-10-02 19:15:55 +02:00
|
|
|
(((ch->ch_tun.un_flags | ch->ch_pun.un_flags) &
|
|
|
|
UN_CLOSING) == 0));
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* If ret is non-zero, user ctrl-c'ed us */
|
2014-08-19 17:30:23 +02:00
|
|
|
if (rc)
|
2013-08-01 23:00:20 +02:00
|
|
|
return -EINTR;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* Store our unit into driver_data, so we always have it available. */
|
|
|
|
tty->driver_data = un;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize tty's
|
|
|
|
*/
|
|
|
|
if (!(un->un_flags & UN_ISOPEN)) {
|
|
|
|
/* Store important variables. */
|
|
|
|
un->un_tty = tty;
|
|
|
|
|
|
|
|
/* Maybe do something here to the TTY struct as well? */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate channel buffers for read/write/error.
|
|
|
|
* Set flag, so we don't get trounced on.
|
|
|
|
*/
|
|
|
|
ch->ch_flags |= (CH_OPENING);
|
|
|
|
|
|
|
|
/* Drop locks, as malloc with GFP_KERNEL can sleep */
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!ch->ch_rqueue)
|
2013-08-28 04:13:27 +02:00
|
|
|
ch->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (!ch->ch_equeue)
|
2013-08-28 04:13:27 +02:00
|
|
|
ch->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (!ch->ch_wqueue)
|
2013-08-28 04:13:27 +02:00
|
|
|
ch->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_flags &= ~(CH_OPENING);
|
|
|
|
wake_up_interruptible(&ch->ch_flags_wait);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize if neither terminal or printer is open.
|
|
|
|
*/
|
|
|
|
if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) {
|
|
|
|
/*
|
|
|
|
* Flush input queues.
|
|
|
|
*/
|
2014-09-01 15:46:59 +02:00
|
|
|
ch->ch_r_head = 0;
|
|
|
|
ch->ch_r_tail = 0;
|
|
|
|
ch->ch_e_head = 0;
|
|
|
|
ch->ch_e_tail = 0;
|
|
|
|
ch->ch_w_head = 0;
|
|
|
|
ch->ch_w_tail = 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
brd->bd_ops->flush_uart_write(ch);
|
|
|
|
brd->bd_ops->flush_uart_read(ch);
|
|
|
|
|
|
|
|
ch->ch_flags = 0;
|
|
|
|
ch->ch_cached_lsr = 0;
|
|
|
|
ch->ch_stop_sending_break = 0;
|
|
|
|
ch->ch_stops_sent = 0;
|
|
|
|
|
2013-08-13 21:49:53 +02:00
|
|
|
ch->ch_c_cflag = tty->termios.c_cflag;
|
|
|
|
ch->ch_c_iflag = tty->termios.c_iflag;
|
|
|
|
ch->ch_c_oflag = tty->termios.c_oflag;
|
|
|
|
ch->ch_c_lflag = tty->termios.c_lflag;
|
|
|
|
ch->ch_startc = tty->termios.c_cc[VSTART];
|
|
|
|
ch->ch_stopc = tty->termios.c_cc[VSTOP];
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Bring up RTS and DTR...
|
|
|
|
* Also handle RTS or DTR toggle if set.
|
|
|
|
*/
|
|
|
|
if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE))
|
|
|
|
ch->ch_mostat |= (UART_MCR_RTS);
|
|
|
|
if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE))
|
|
|
|
ch->ch_mostat |= (UART_MCR_DTR);
|
|
|
|
|
|
|
|
/* Tell UART to init itself */
|
|
|
|
brd->bd_ops->uart_init(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Run param in case we changed anything
|
|
|
|
*/
|
|
|
|
brd->bd_ops->param(tty);
|
|
|
|
|
|
|
|
dgnc_carrier(ch);
|
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
/*
|
2013-08-01 23:00:20 +02:00
|
|
|
* follow protocol for opening port
|
|
|
|
*/
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
rc = dgnc_block_til_ready(tty, file, ch);
|
|
|
|
|
|
|
|
/* No going back now, increment our unit and channel counters */
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_open_count++;
|
|
|
|
un->un_open_count++;
|
|
|
|
un->un_flags |= (UN_ISOPEN);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
/*
|
2013-08-01 23:00:20 +02:00
|
|
|
* dgnc_block_til_ready()
|
|
|
|
*
|
|
|
|
* Wait for DCD, if needed.
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
static int dgnc_block_til_ready(struct tty_struct *tty,
|
|
|
|
struct file *file,
|
|
|
|
struct channel_t *ch)
|
2013-08-21 17:08:11 +02:00
|
|
|
{
|
2013-08-01 23:00:20 +02:00
|
|
|
int retval = 0;
|
|
|
|
struct un_t *un = NULL;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
uint old_flags = 0;
|
|
|
|
int sleep_on_un_flags = 0;
|
|
|
|
|
2015-10-02 19:15:55 +02:00
|
|
|
if (!tty || tty->magic != TTY_MAGIC || !file || !ch ||
|
|
|
|
ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENXIO;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
un = tty->driver_data;
|
2014-05-18 01:54:31 +02:00
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENXIO;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_wopen++;
|
|
|
|
|
|
|
|
/* Loop forever */
|
|
|
|
while (1) {
|
|
|
|
sleep_on_un_flags = 0;
|
|
|
|
|
|
|
|
/*
|
2015-10-02 19:15:55 +02:00
|
|
|
* If board has failed somehow during our sleep,
|
|
|
|
* bail with error.
|
2013-08-01 23:00:20 +02:00
|
|
|
*/
|
|
|
|
if (ch->ch_bd->state == BOARD_FAILED) {
|
|
|
|
retval = -ENXIO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If tty was hung up, break out of loop and set error. */
|
|
|
|
if (tty_hung_up_p(file)) {
|
|
|
|
retval = -EAGAIN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If either unit is in the middle of the fragile part of close,
|
|
|
|
* we just cannot touch the channel safely.
|
|
|
|
* Go back to sleep, knowing that when the channel can be
|
2013-08-21 17:08:11 +02:00
|
|
|
* touched safely, the close routine will signal the
|
2013-08-01 23:00:20 +02:00
|
|
|
* ch_wait_flags to wake us back up.
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
if (!((ch->ch_tun.un_flags |
|
|
|
|
ch->ch_pun.un_flags) &
|
|
|
|
UN_CLOSING)) {
|
2013-08-01 23:00:20 +02:00
|
|
|
/*
|
|
|
|
* Our conditions to leave cleanly and happily:
|
|
|
|
* 1) NONBLOCKING on the tty is set.
|
|
|
|
* 2) CLOCAL is set.
|
|
|
|
* 3) DCD (fake or real) is active.
|
|
|
|
*/
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (file->f_flags & O_NONBLOCK)
|
2013-08-01 23:00:20 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (tty->flags & (1 << TTY_IO_ERROR)) {
|
|
|
|
retval = -EIO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-19 17:30:23 +02:00
|
|
|
if (ch->ch_flags & CH_CD)
|
2013-08-01 23:00:20 +02:00
|
|
|
break;
|
|
|
|
|
2014-08-19 17:30:23 +02:00
|
|
|
if (ch->ch_flags & CH_FCAR)
|
2013-08-01 23:00:20 +02:00
|
|
|
break;
|
2014-05-18 01:54:29 +02:00
|
|
|
} else {
|
2013-08-01 23:00:20 +02:00
|
|
|
sleep_on_un_flags = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there is a signal pending, the user probably
|
|
|
|
* interrupted (ctrl-c) us.
|
|
|
|
* Leave loop with error set.
|
|
|
|
*/
|
|
|
|
if (signal_pending(current)) {
|
|
|
|
retval = -ERESTARTSYS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Store the flags before we let go of channel lock
|
|
|
|
*/
|
|
|
|
if (sleep_on_un_flags)
|
|
|
|
old_flags = ch->ch_tun.un_flags | ch->ch_pun.un_flags;
|
|
|
|
else
|
|
|
|
old_flags = ch->ch_flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Let go of channel lock before calling schedule.
|
|
|
|
* Our poller will get any FEP events and wake us up when DCD
|
|
|
|
* eventually goes active.
|
|
|
|
*/
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
2015-10-02 19:15:55 +02:00
|
|
|
* Wait for something in the flags to change
|
|
|
|
* from the current value.
|
2013-08-01 23:00:20 +02:00
|
|
|
*/
|
2014-05-18 01:54:31 +02:00
|
|
|
if (sleep_on_un_flags)
|
2013-08-01 23:00:20 +02:00
|
|
|
retval = wait_event_interruptible(un->un_flags_wait,
|
2015-10-02 19:15:55 +02:00
|
|
|
(old_flags != (ch->ch_tun.un_flags |
|
|
|
|
ch->ch_pun.un_flags)));
|
2014-05-18 01:54:31 +02:00
|
|
|
else
|
2013-08-01 23:00:20 +02:00
|
|
|
retval = wait_event_interruptible(ch->ch_flags_wait,
|
|
|
|
(old_flags != ch->ch_flags));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We got woken up for some reason.
|
|
|
|
* Before looping around, grab our channel lock.
|
|
|
|
*/
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ch->ch_wopen--;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2015-10-11 01:06:44 +02:00
|
|
|
return retval;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_hangup()
|
|
|
|
*
|
|
|
|
* Hangup the port. Like a close, but don't wait for output to drain.
|
2013-08-21 17:08:11 +02:00
|
|
|
*/
|
2013-08-01 23:00:20 +02:00
|
|
|
static void dgnc_tty_hangup(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct un_t *un;
|
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* flush the transmit queues */
|
|
|
|
dgnc_tty_flush_buffer(tty);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_close()
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine if this is the last close or not - and if we agree about
|
|
|
|
* which type of close it is with the Line Discipline
|
|
|
|
*/
|
|
|
|
if ((tty->count == 1) && (un->un_open_count != 1)) {
|
|
|
|
/*
|
|
|
|
* Uh, oh. tty->count is 1, which means that the tty
|
|
|
|
* structure will be freed. un_open_count should always
|
|
|
|
* be one in these conditions. If it's greater than
|
|
|
|
* one, we've got real problems, since it means the
|
|
|
|
* serial port won't be shutdown.
|
|
|
|
*/
|
2014-10-07 12:08:12 +02:00
|
|
|
dev_dbg(tty->dev,
|
|
|
|
"tty->count is 1, un open count is %d\n",
|
|
|
|
un->un_open_count);
|
2013-08-01 23:00:20 +02:00
|
|
|
un->un_open_count = 1;
|
2013-08-21 17:08:11 +02:00
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-07-03 12:12:31 +02:00
|
|
|
if (un->un_open_count)
|
|
|
|
un->un_open_count--;
|
|
|
|
else
|
2014-10-07 12:08:12 +02:00
|
|
|
dev_dbg(tty->dev,
|
|
|
|
"bad serial port open count of %d\n",
|
|
|
|
un->un_open_count);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_open_count--;
|
|
|
|
|
|
|
|
if (ch->ch_open_count && un->un_open_count) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-21 19:30:11 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* OK, its the last close on the unit */
|
|
|
|
un->un_flags |= UN_CLOSING;
|
|
|
|
|
|
|
|
tty->closing = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only officially close channel if count is 0 and
|
2013-08-21 19:30:11 +02:00
|
|
|
* DIGI_PRINTER bit is not set.
|
2013-08-01 23:00:20 +02:00
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
if ((ch->ch_open_count == 0) &&
|
|
|
|
!(ch->ch_digi.digi_flags & DIGI_PRINTER)) {
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_flags &= ~(CH_STOPI | CH_FORCED_STOPI);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* turn off print device when closing print device.
|
|
|
|
*/
|
2014-05-17 03:04:10 +02:00
|
|
|
if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) {
|
2013-08-01 23:00:20 +02:00
|
|
|
dgnc_wmove(ch, ch->ch_digi.digi_offstr,
|
2015-10-04 16:20:14 +02:00
|
|
|
(int)ch->ch_digi.digi_offlen);
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_flags &= ~CH_PRON;
|
|
|
|
}
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
/* wait for output to drain */
|
|
|
|
/* This will also return if we take an interrupt */
|
|
|
|
|
2015-10-03 17:22:39 +02:00
|
|
|
bd->bd_ops->drain(tty, 0);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
dgnc_tty_flush_buffer(tty);
|
|
|
|
tty_ldisc_flush(tty);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
tty->closing = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have HUPCL set, lower DTR and RTS
|
|
|
|
*/
|
|
|
|
if (ch->ch_c_cflag & HUPCL) {
|
|
|
|
/* Drop RTS/DTR */
|
|
|
|
ch->ch_mostat &= ~(UART_MCR_DTR | UART_MCR_RTS);
|
|
|
|
bd->bd_ops->assert_modem_signals(ch);
|
|
|
|
|
|
|
|
/*
|
2013-08-21 17:08:11 +02:00
|
|
|
* Go to sleep to ensure RTS/DTR
|
2013-08-01 23:00:20 +02:00
|
|
|
* have been dropped for modems to see it.
|
|
|
|
*/
|
|
|
|
if (ch->ch_close_delay) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock,
|
|
|
|
flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
dgnc_ms_sleep(ch->ch_close_delay);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ch->ch_old_baud = 0;
|
|
|
|
|
|
|
|
/* Turn off UART interrupts for this port */
|
|
|
|
ch->ch_bd->bd_ops->uart_off(ch);
|
2014-05-18 01:54:29 +02:00
|
|
|
} else {
|
2013-08-01 23:00:20 +02:00
|
|
|
/*
|
|
|
|
* turn off print device when closing print device.
|
|
|
|
*/
|
2014-05-17 03:04:10 +02:00
|
|
|
if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) {
|
2013-08-01 23:00:20 +02:00
|
|
|
dgnc_wmove(ch, ch->ch_digi.digi_offstr,
|
2015-10-04 16:20:14 +02:00
|
|
|
(int)ch->ch_digi.digi_offlen);
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_flags &= ~CH_PRON;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
un->un_tty = NULL;
|
|
|
|
un->un_flags &= ~(UN_ISOPEN | UN_CLOSING);
|
|
|
|
|
|
|
|
wake_up_interruptible(&ch->ch_flags_wait);
|
|
|
|
wake_up_interruptible(&un->un_flags_wait);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_chars_in_buffer()
|
|
|
|
*
|
|
|
|
* Return number of characters that have not been transmitted yet.
|
|
|
|
*
|
|
|
|
* This routine is used by the line discipline to determine if there
|
|
|
|
* is data waiting to be transmitted/drained/flushed or not.
|
|
|
|
*/
|
|
|
|
static int dgnc_tty_chars_in_buffer(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct channel_t *ch = NULL;
|
|
|
|
struct un_t *un = NULL;
|
|
|
|
ushort thead;
|
|
|
|
ushort ttail;
|
|
|
|
uint tmask;
|
|
|
|
uint chars = 0;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2015-10-03 17:22:44 +02:00
|
|
|
if (!tty)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
tmask = WQUEUEMASK;
|
|
|
|
thead = ch->ch_w_head & tmask;
|
|
|
|
ttail = ch->ch_w_tail & tmask;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (ttail == thead) {
|
|
|
|
chars = 0;
|
|
|
|
} else {
|
|
|
|
if (thead >= ttail)
|
|
|
|
chars = thead - ttail;
|
|
|
|
else
|
|
|
|
chars = thead - ttail + WQUEUESIZE;
|
|
|
|
}
|
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return chars;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
/*
|
2013-08-01 23:00:20 +02:00
|
|
|
* dgnc_maxcps_room
|
|
|
|
*
|
|
|
|
* Reduces bytes_available to the max number of characters
|
|
|
|
* that can be sent currently given the maxcps value, and
|
|
|
|
* returns the new bytes_available. This only affects printer
|
|
|
|
* output.
|
2013-08-21 17:08:11 +02:00
|
|
|
*/
|
2013-08-01 23:00:20 +02:00
|
|
|
static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available)
|
|
|
|
{
|
|
|
|
struct channel_t *ch = NULL;
|
|
|
|
struct un_t *un = NULL;
|
|
|
|
|
|
|
|
if (!tty)
|
2013-09-09 21:01:23 +02:00
|
|
|
return bytes_available;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return bytes_available;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return bytes_available;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If its not the Transparent print device, return
|
|
|
|
* the full data amount.
|
|
|
|
*/
|
|
|
|
if (un->un_type != DGNC_PRINT)
|
2013-09-09 21:01:23 +02:00
|
|
|
return bytes_available;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-05-17 03:04:10 +02:00
|
|
|
if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0) {
|
2013-08-01 23:00:20 +02:00
|
|
|
int cps_limit = 0;
|
|
|
|
unsigned long current_time = jiffies;
|
|
|
|
unsigned long buffer_time = current_time +
|
2015-10-02 19:15:55 +02:00
|
|
|
(HZ * ch->ch_digi.digi_bufsize) /
|
|
|
|
ch->ch_digi.digi_maxcps;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (ch->ch_cpstime < current_time) {
|
|
|
|
/* buffer is empty */
|
2015-10-02 19:15:55 +02:00
|
|
|
ch->ch_cpstime = current_time; /* reset ch_cpstime */
|
2013-08-01 23:00:20 +02:00
|
|
|
cps_limit = ch->ch_digi.digi_bufsize;
|
2014-05-18 01:54:29 +02:00
|
|
|
} else if (ch->ch_cpstime < buffer_time) {
|
2013-08-01 23:00:20 +02:00
|
|
|
/* still room in the buffer */
|
2015-10-02 19:15:55 +02:00
|
|
|
cps_limit = ((buffer_time - ch->ch_cpstime) *
|
|
|
|
ch->ch_digi.digi_maxcps) / HZ;
|
2014-05-18 01:54:29 +02:00
|
|
|
} else {
|
2013-08-01 23:00:20 +02:00
|
|
|
/* no room in the buffer */
|
2013-08-21 17:08:11 +02:00
|
|
|
cps_limit = 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bytes_available = min(cps_limit, bytes_available);
|
|
|
|
}
|
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return bytes_available;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_write_room()
|
|
|
|
*
|
|
|
|
* Return space available in Tx buffer
|
2013-08-21 17:08:11 +02:00
|
|
|
*/
|
2013-08-01 23:00:20 +02:00
|
|
|
static int dgnc_tty_write_room(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct channel_t *ch = NULL;
|
|
|
|
struct un_t *un = NULL;
|
|
|
|
ushort head;
|
|
|
|
ushort tail;
|
|
|
|
ushort tmask;
|
|
|
|
int ret = 0;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2015-10-03 17:22:44 +02:00
|
|
|
if (!tty || !dgnc_TmpWriteBuf)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
tmask = WQUEUEMASK;
|
|
|
|
head = (ch->ch_w_head) & tmask;
|
|
|
|
tail = (ch->ch_w_tail) & tmask;
|
|
|
|
|
staging:dgnc: Removed assignments from if statements.
Coccinelle was used for this patch. The script is not complete (semantically) and might raise some checkpatch warnings in terms of indentation depending on existing code.
*** IFASSIGNMENT.COCCI START ***
/* Coccinelle script to handle assignments in if statements
* For compound statements, can so far only handle statements with the
* assignment on either extreme */
/* This rule is for simple cases
* e.g. just an assignment in if, possibly with unary operator */
@simple@
expression E1, E2;
statement S1, S2;
@@
+ E1 = E2;
if (
- (E1 = E2)
+ E1
)
S1 else S2
/* This rule is for compound statements where the assignment is on the right.*/
@right@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ } else S2
|
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1
+ }
/* or */
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ }
+ else S1
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1) S1
+ } else
S1
/* not equal */
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1 else S2
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1
/* equal */
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1 else S2
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1
/* greater than */
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1 else S2
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1
/* less than */
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1 else S2
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1
/* lesser than or equal to */
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1 else S2
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1
/* greater than or equal to */
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1 else S2
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1
)
/* This rule is for compound statements where the assignment is on the left.*/
@left@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1 else S2
|
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1
|
/* or */
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1
|
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1 else S2
|
/* not equal */
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1
|
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1 else S2
|
/* equal */
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1
|
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1 else S2
|
/* greater */
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1
|
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1 else S2
|
/* less */
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1
|
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1 else S2
/* lesser than or equal to */
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1
|
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1 else S2
/* greater than or equal to */
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1
|
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1 else S2
)
*** IFASSIGNMENT.COCCI END ***
Signed-off-by: Chi Pham <fempsci@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-09 10:39:04 +01:00
|
|
|
ret = tail - head - 1;
|
|
|
|
if (ret < 0)
|
2013-08-01 23:00:20 +02:00
|
|
|
ret += WQUEUESIZE;
|
|
|
|
|
|
|
|
/* Limit printer to maxcps */
|
|
|
|
ret = dgnc_maxcps_room(tty, ret);
|
|
|
|
|
|
|
|
/*
|
2013-08-21 17:08:11 +02:00
|
|
|
* If we are printer device, leave space for
|
2013-08-01 23:00:20 +02:00
|
|
|
* possibly both the on and off strings.
|
|
|
|
*/
|
|
|
|
if (un->un_type == DGNC_PRINT) {
|
|
|
|
if (!(ch->ch_flags & CH_PRON))
|
|
|
|
ret -= ch->ch_digi.digi_onlen;
|
|
|
|
ret -= ch->ch_digi.digi_offlen;
|
2014-05-18 01:54:29 +02:00
|
|
|
} else {
|
2013-08-01 23:00:20 +02:00
|
|
|
if (ch->ch_flags & CH_PRON)
|
|
|
|
ret -= ch->ch_digi.digi_offlen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
ret = 0;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return ret;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_put_char()
|
|
|
|
*
|
|
|
|
* Put a character into ch->ch_buf
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
* - used by the line discipline for OPOST processing
|
|
|
|
*/
|
|
|
|
static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Simply call tty_write.
|
|
|
|
*/
|
|
|
|
dgnc_tty_write(tty, &c, 1);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_write()
|
|
|
|
*
|
|
|
|
* Take data from the user or kernel and send it out to the FEP.
|
|
|
|
* In here exists all the Transparent Print magic as well.
|
|
|
|
*/
|
|
|
|
static int dgnc_tty_write(struct tty_struct *tty,
|
2015-10-04 16:20:14 +02:00
|
|
|
const unsigned char *buf, int count)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
|
|
|
struct channel_t *ch = NULL;
|
|
|
|
struct un_t *un = NULL;
|
|
|
|
int bufcount = 0, n = 0;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
ushort head;
|
|
|
|
ushort tail;
|
|
|
|
ushort tmask;
|
|
|
|
uint remain;
|
|
|
|
|
2015-10-03 17:22:44 +02:00
|
|
|
if (!tty || !dgnc_TmpWriteBuf)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!count)
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Store original amount of characters passed in.
|
|
|
|
* This helps to figure out if we should ask the FEP
|
|
|
|
* to send us an event when it has more space available.
|
|
|
|
*/
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* Get our space available for the channel from the board */
|
|
|
|
tmask = WQUEUEMASK;
|
|
|
|
head = (ch->ch_w_head) & tmask;
|
|
|
|
tail = (ch->ch_w_tail) & tmask;
|
|
|
|
|
staging:dgnc: Removed assignments from if statements.
Coccinelle was used for this patch. The script is not complete (semantically) and might raise some checkpatch warnings in terms of indentation depending on existing code.
*** IFASSIGNMENT.COCCI START ***
/* Coccinelle script to handle assignments in if statements
* For compound statements, can so far only handle statements with the
* assignment on either extreme */
/* This rule is for simple cases
* e.g. just an assignment in if, possibly with unary operator */
@simple@
expression E1, E2;
statement S1, S2;
@@
+ E1 = E2;
if (
- (E1 = E2)
+ E1
)
S1 else S2
/* This rule is for compound statements where the assignment is on the right.*/
@right@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ } else S2
|
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1
+ }
/* or */
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ }
+ else S1
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1) S1
+ } else
S1
/* not equal */
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1 else S2
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1
/* equal */
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1 else S2
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1
/* greater than */
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1 else S2
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1
/* less than */
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1 else S2
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1
/* lesser than or equal to */
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1 else S2
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1
/* greater than or equal to */
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1 else S2
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1
)
/* This rule is for compound statements where the assignment is on the left.*/
@left@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1 else S2
|
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1
|
/* or */
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1
|
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1 else S2
|
/* not equal */
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1
|
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1 else S2
|
/* equal */
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1
|
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1 else S2
|
/* greater */
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1
|
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1 else S2
|
/* less */
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1
|
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1 else S2
/* lesser than or equal to */
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1
|
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1 else S2
/* greater than or equal to */
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1
|
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1 else S2
)
*** IFASSIGNMENT.COCCI END ***
Signed-off-by: Chi Pham <fempsci@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-09 10:39:04 +01:00
|
|
|
bufcount = tail - head - 1;
|
|
|
|
if (bufcount < 0)
|
2013-08-01 23:00:20 +02:00
|
|
|
bufcount += WQUEUESIZE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Limit printer output to maxcps overall, with bursts allowed
|
|
|
|
* up to bufsize characters.
|
|
|
|
*/
|
|
|
|
bufcount = dgnc_maxcps_room(tty, bufcount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Take minimum of what the user wants to send, and the
|
|
|
|
* space available in the FEP buffer.
|
|
|
|
*/
|
|
|
|
count = min(count, bufcount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bail if no space left.
|
|
|
|
*/
|
2015-03-11 15:22:01 +01:00
|
|
|
if (count <= 0)
|
|
|
|
goto exit_retry;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Output the printer ON string, if we are in terminal mode, but
|
|
|
|
* need to be in printer mode.
|
|
|
|
*/
|
|
|
|
if ((un->un_type == DGNC_PRINT) && !(ch->ch_flags & CH_PRON)) {
|
|
|
|
dgnc_wmove(ch, ch->ch_digi.digi_onstr,
|
2015-10-04 16:20:14 +02:00
|
|
|
(int)ch->ch_digi.digi_onlen);
|
2013-08-01 23:00:20 +02:00
|
|
|
head = (ch->ch_w_head) & tmask;
|
|
|
|
ch->ch_flags |= CH_PRON;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On the other hand, output the printer OFF string, if we are
|
|
|
|
* currently in printer mode, but need to output to the terminal.
|
|
|
|
*/
|
|
|
|
if ((un->un_type != DGNC_PRINT) && (ch->ch_flags & CH_PRON)) {
|
|
|
|
dgnc_wmove(ch, ch->ch_digi.digi_offstr,
|
2015-10-04 16:20:14 +02:00
|
|
|
(int)ch->ch_digi.digi_offlen);
|
2013-08-01 23:00:20 +02:00
|
|
|
head = (ch->ch_w_head) & tmask;
|
|
|
|
ch->ch_flags &= ~CH_PRON;
|
|
|
|
}
|
|
|
|
|
|
|
|
n = count;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the write wraps over the top of the circular buffer,
|
|
|
|
* move the portion up to the wrap point, and reset the
|
|
|
|
* pointers to the bottom.
|
|
|
|
*/
|
|
|
|
remain = WQUEUESIZE - head;
|
|
|
|
|
|
|
|
if (n >= remain) {
|
|
|
|
n -= remain;
|
|
|
|
memcpy(ch->ch_wqueue + head, buf, remain);
|
|
|
|
head = 0;
|
|
|
|
buf += remain;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n > 0) {
|
|
|
|
/*
|
|
|
|
* Move rest of data.
|
|
|
|
*/
|
|
|
|
remain = n;
|
|
|
|
memcpy(ch->ch_wqueue + head, buf, remain);
|
|
|
|
head += remain;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count) {
|
|
|
|
head &= tmask;
|
|
|
|
ch->ch_w_head = head;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update printer buffer empty time. */
|
|
|
|
if ((un->un_type == DGNC_PRINT) && (ch->ch_digi.digi_maxcps > 0)
|
|
|
|
&& (ch->ch_digi.digi_bufsize > 0)) {
|
2013-08-21 19:30:11 +02:00
|
|
|
ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2015-04-10 16:48:54 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (count) {
|
|
|
|
/*
|
|
|
|
* Channel lock is grabbed and then released
|
|
|
|
* inside this routine.
|
|
|
|
*/
|
|
|
|
ch->ch_bd->bd_ops->copy_data_from_queue_to_uart(ch);
|
|
|
|
}
|
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return count;
|
2015-03-11 15:22:01 +01:00
|
|
|
|
|
|
|
exit_retry:
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return modem signals to ld.
|
|
|
|
*/
|
2013-09-09 21:01:26 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
static int dgnc_tty_tiocmget(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
|
|
|
int result = -EIO;
|
2014-10-01 22:04:48 +02:00
|
|
|
unsigned char mstat = 0;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return result;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
mstat = (ch->ch_mostat | ch->ch_mistat);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
|
|
|
if (mstat & UART_MCR_DTR)
|
|
|
|
result |= TIOCM_DTR;
|
|
|
|
if (mstat & UART_MCR_RTS)
|
|
|
|
result |= TIOCM_RTS;
|
|
|
|
if (mstat & UART_MSR_CTS)
|
|
|
|
result |= TIOCM_CTS;
|
|
|
|
if (mstat & UART_MSR_DSR)
|
|
|
|
result |= TIOCM_DSR;
|
|
|
|
if (mstat & UART_MSR_RI)
|
|
|
|
result |= TIOCM_RI;
|
|
|
|
if (mstat & UART_MSR_DCD)
|
|
|
|
result |= TIOCM_CD;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_tiocmset()
|
|
|
|
*
|
|
|
|
* Set modem signals, called by ld.
|
|
|
|
*/
|
2013-09-09 21:01:26 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
static int dgnc_tty_tiocmset(struct tty_struct *tty,
|
2015-10-04 16:20:14 +02:00
|
|
|
unsigned int set, unsigned int clear)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
|
|
|
int ret = -EIO;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (set & TIOCM_RTS)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat |= UART_MCR_RTS;
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (set & TIOCM_DTR)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat |= UART_MCR_DTR;
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (clear & TIOCM_RTS)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat &= ~(UART_MCR_RTS);
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (clear & TIOCM_DTR)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat &= ~(UART_MCR_DTR);
|
|
|
|
|
|
|
|
ch->ch_bd->bd_ops->assert_modem_signals(ch);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_send_break()
|
|
|
|
*
|
|
|
|
* Send a Break, called by ld.
|
|
|
|
*/
|
|
|
|
static int dgnc_tty_send_break(struct tty_struct *tty, int msec)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
|
|
|
int ret = -EIO;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
switch (msec) {
|
|
|
|
case -1:
|
|
|
|
msec = 0xFFFF;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
msec = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_bd->bd_ops->send_break(ch, msec);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_wait_until_sent()
|
|
|
|
*
|
|
|
|
* wait until data has been transmitted, called by ld.
|
|
|
|
*/
|
|
|
|
static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return;
|
|
|
|
|
2015-10-03 17:22:39 +02:00
|
|
|
bd->bd_ops->drain(tty, 0);
|
2013-08-21 17:08:11 +02:00
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_send_xchar()
|
|
|
|
*
|
|
|
|
* send a high priority character, called by ld.
|
|
|
|
*/
|
|
|
|
static void dgnc_tty_send_xchar(struct tty_struct *tty, char c)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return;
|
|
|
|
|
2014-09-14 22:13:20 +02:00
|
|
|
dev_dbg(tty->dev, "dgnc_tty_send_xchar start\n");
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
bd->bd_ops->send_immediate_char(ch, c);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-09-14 22:13:20 +02:00
|
|
|
dev_dbg(tty->dev, "dgnc_tty_send_xchar finish\n");
|
2013-08-21 17:08:11 +02:00
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return modem signals to ld.
|
|
|
|
*/
|
|
|
|
static inline int dgnc_get_mstat(struct channel_t *ch)
|
|
|
|
{
|
|
|
|
unsigned char mstat;
|
|
|
|
int result = -EIO;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENXIO;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
mstat = (ch->ch_mostat | ch->ch_mistat);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
|
|
|
if (mstat & UART_MCR_DTR)
|
|
|
|
result |= TIOCM_DTR;
|
|
|
|
if (mstat & UART_MCR_RTS)
|
|
|
|
result |= TIOCM_RTS;
|
|
|
|
if (mstat & UART_MSR_CTS)
|
|
|
|
result |= TIOCM_CTS;
|
|
|
|
if (mstat & UART_MSR_DSR)
|
|
|
|
result |= TIOCM_DSR;
|
|
|
|
if (mstat & UART_MSR_RI)
|
|
|
|
result |= TIOCM_RI;
|
|
|
|
if (mstat & UART_MSR_DCD)
|
|
|
|
result |= TIOCM_CD;
|
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return result;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return modem signals to ld.
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
static int dgnc_get_modem_info(struct channel_t *ch,
|
|
|
|
unsigned int __user *value)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENXIO;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
result = dgnc_get_mstat(ch);
|
|
|
|
|
|
|
|
if (result < 0)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENXIO;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-09-19 07:00:59 +02:00
|
|
|
return put_user(result, value);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_set_modem_info()
|
|
|
|
*
|
|
|
|
* Set modem signals, called by ld.
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
static int dgnc_set_modem_info(struct tty_struct *tty,
|
|
|
|
unsigned int command,
|
|
|
|
unsigned int __user *value)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
|
|
|
int ret = -ENXIO;
|
|
|
|
unsigned int arg = 0;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = get_user(arg, value);
|
|
|
|
if (ret)
|
2013-09-09 21:01:23 +02:00
|
|
|
return ret;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
switch (command) {
|
|
|
|
case TIOCMBIS:
|
2014-05-18 01:54:31 +02:00
|
|
|
if (arg & TIOCM_RTS)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat |= UART_MCR_RTS;
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (arg & TIOCM_DTR)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat |= UART_MCR_DTR;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCMBIC:
|
2014-05-18 01:54:31 +02:00
|
|
|
if (arg & TIOCM_RTS)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat &= ~(UART_MCR_RTS);
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (arg & TIOCM_DTR)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat &= ~(UART_MCR_DTR);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2013-08-21 19:30:11 +02:00
|
|
|
case TIOCMSET:
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (arg & TIOCM_RTS)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat |= UART_MCR_RTS;
|
2014-05-18 01:54:31 +02:00
|
|
|
else
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat &= ~(UART_MCR_RTS);
|
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (arg & TIOCM_DTR)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat |= UART_MCR_DTR;
|
2014-05-18 01:54:31 +02:00
|
|
|
else
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat &= ~(UART_MCR_DTR);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EINVAL;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_bd->bd_ops->assert_modem_signals(ch);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-08-21 17:08:11 +02:00
|
|
|
* dgnc_tty_digigeta()
|
2013-08-01 23:00:20 +02:00
|
|
|
*
|
|
|
|
* Ioctl to get the information for ditty.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
static int dgnc_tty_digigeta(struct tty_struct *tty,
|
|
|
|
struct digi_t __user *retinfo)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
|
|
|
struct digi_t tmp;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!retinfo)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
memset(&tmp, 0, sizeof(tmp));
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
memcpy(&tmp, &ch->ch_digi, sizeof(tmp));
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-08-21 17:08:11 +02:00
|
|
|
* dgnc_tty_digiseta()
|
2013-08-01 23:00:20 +02:00
|
|
|
*
|
|
|
|
* Ioctl to set the information for ditty.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
static int dgnc_tty_digiseta(struct tty_struct *tty,
|
|
|
|
struct digi_t __user *new_info)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
|
|
|
struct digi_t new_digi;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-08-19 17:30:23 +02:00
|
|
|
if (copy_from_user(&new_digi, new_info, sizeof(new_digi)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle transistions to and from RTS Toggle.
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) &&
|
|
|
|
(new_digi.digi_flags & DIGI_RTS_TOGGLE))
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat &= ~(UART_MCR_RTS);
|
2015-10-02 19:15:55 +02:00
|
|
|
if ((ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) &&
|
|
|
|
!(new_digi.digi_flags & DIGI_RTS_TOGGLE))
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat |= (UART_MCR_RTS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle transistions to and from DTR Toggle.
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) &&
|
|
|
|
(new_digi.digi_flags & DIGI_DTR_TOGGLE))
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat &= ~(UART_MCR_DTR);
|
2015-10-02 19:15:55 +02:00
|
|
|
if ((ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) &&
|
|
|
|
!(new_digi.digi_flags & DIGI_DTR_TOGGLE))
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_mostat |= (UART_MCR_DTR);
|
|
|
|
|
2013-10-04 18:18:30 +02:00
|
|
|
memcpy(&ch->ch_digi, &new_digi, sizeof(new_digi));
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
if (ch->ch_digi.digi_maxcps < 1)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_digi.digi_maxcps = 1;
|
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
if (ch->ch_digi.digi_maxcps > 10000)
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_digi.digi_maxcps = 10000;
|
|
|
|
|
|
|
|
if (ch->ch_digi.digi_bufsize < 10)
|
|
|
|
ch->ch_digi.digi_bufsize = 10;
|
|
|
|
|
|
|
|
if (ch->ch_digi.digi_maxchar < 1)
|
|
|
|
ch->ch_digi.digi_maxchar = 1;
|
|
|
|
|
|
|
|
if (ch->ch_digi.digi_maxchar > ch->ch_digi.digi_bufsize)
|
|
|
|
ch->ch_digi.digi_maxchar = ch->ch_digi.digi_bufsize;
|
|
|
|
|
|
|
|
if (ch->ch_digi.digi_onlen > DIGI_PLEN)
|
|
|
|
ch->ch_digi.digi_onlen = DIGI_PLEN;
|
|
|
|
|
|
|
|
if (ch->ch_digi.digi_offlen > DIGI_PLEN)
|
|
|
|
ch->ch_digi.digi_offlen = DIGI_PLEN;
|
|
|
|
|
|
|
|
ch->ch_bd->bd_ops->param(tty);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_set_termios()
|
|
|
|
*/
|
2015-10-02 19:15:55 +02:00
|
|
|
static void dgnc_tty_set_termios(struct tty_struct *tty,
|
|
|
|
struct ktermios *old_termios)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-13 21:49:53 +02:00
|
|
|
ch->ch_c_cflag = tty->termios.c_cflag;
|
|
|
|
ch->ch_c_iflag = tty->termios.c_iflag;
|
|
|
|
ch->ch_c_oflag = tty->termios.c_oflag;
|
|
|
|
ch->ch_c_lflag = tty->termios.c_lflag;
|
|
|
|
ch->ch_startc = tty->termios.c_cc[VSTART];
|
|
|
|
ch->ch_stopc = tty->termios.c_cc[VSTOP];
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_bd->bd_ops->param(tty);
|
|
|
|
dgnc_carrier(ch);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dgnc_tty_throttle(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-21 19:30:11 +02:00
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_flags |= (CH_FORCED_STOPI);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dgnc_tty_unthrottle(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-21 19:30:11 +02:00
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_flags &= ~(CH_FORCED_STOPI);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dgnc_tty_start(struct tty_struct *tty)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-21 19:30:11 +02:00
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_flags &= ~(CH_FORCED_STOP);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dgnc_tty_stop(struct tty_struct *tty)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-21 19:30:11 +02:00
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_flags |= (CH_FORCED_STOP);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
/*
|
2013-08-01 23:00:20 +02:00
|
|
|
* dgnc_tty_flush_chars()
|
|
|
|
*
|
|
|
|
* Flush the cook buffer
|
|
|
|
*
|
|
|
|
* Note to self, and any other poor souls who venture here:
|
|
|
|
*
|
|
|
|
* flush in this case DOES NOT mean dispose of the data.
|
|
|
|
* instead, it means "stop buffering and send it if you
|
|
|
|
* haven't already." Just guess how I figured that out... SRW 2-Jun-98
|
|
|
|
*
|
|
|
|
* It is also always called in interrupt context - JAR 8-Sept-99
|
|
|
|
*/
|
|
|
|
static void dgnc_tty_flush_chars(struct tty_struct *tty)
|
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-21 19:30:11 +02:00
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
|
|
|
return;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* Do something maybe here */
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dgnc_tty_flush_buffer()
|
2013-08-21 17:08:11 +02:00
|
|
|
*
|
2013-08-01 23:00:20 +02:00
|
|
|
* Flush Tx buffer (make in == out)
|
|
|
|
*/
|
|
|
|
static void dgnc_tty_flush_buffer(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
unsigned long flags;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
|
|
|
return;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-21 19:30:11 +02:00
|
|
|
ch = un->un_ch;
|
|
|
|
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
|
|
|
|
return;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_flags &= ~CH_STOP;
|
|
|
|
|
|
|
|
/* Flush our write queue */
|
|
|
|
ch->ch_w_head = ch->ch_w_tail;
|
|
|
|
|
|
|
|
/* Flush UARTs transmit FIFO */
|
|
|
|
ch->ch_bd->bd_ops->flush_uart_write(ch);
|
|
|
|
|
|
|
|
if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) {
|
|
|
|
ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY);
|
|
|
|
wake_up_interruptible(&ch->ch_tun.un_flags_wait);
|
|
|
|
}
|
|
|
|
if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) {
|
|
|
|
ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY);
|
|
|
|
wake_up_interruptible(&ch->ch_pun.un_flags_wait);
|
|
|
|
}
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* The IOCTL function and all of its helpers
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
/*
|
|
|
|
* dgnc_tty_ioctl()
|
|
|
|
*
|
|
|
|
* The usual assortment of ioctl's
|
|
|
|
*/
|
2013-08-13 21:49:57 +02:00
|
|
|
static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
|
2015-10-04 16:20:14 +02:00
|
|
|
unsigned long arg)
|
2013-08-01 23:00:20 +02:00
|
|
|
{
|
2013-09-09 21:01:22 +02:00
|
|
|
struct dgnc_board *bd;
|
2013-08-01 23:00:20 +02:00
|
|
|
struct channel_t *ch;
|
|
|
|
struct un_t *un;
|
|
|
|
int rc;
|
staging: dgnc: dgnc_tty.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:37 +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
|
|
|
|
|
|
|
if (!tty || tty->magic != TTY_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENODEV;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
un = tty->driver_data;
|
|
|
|
if (!un || un->magic != DGNC_UNIT_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENODEV;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch = un->un_ch;
|
|
|
|
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
|
|
|
|
|
|
|
bd = ch->ch_bd;
|
|
|
|
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENODEV;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
if (un->un_open_count <= 0) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EIO;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
/* Here are all the standard ioctl's that we MUST implement */
|
|
|
|
|
|
|
|
case TCSBRK:
|
|
|
|
/*
|
2013-08-21 17:08:11 +02:00
|
|
|
* TCSBRK is SVID version: non-zero arg --> no break
|
2013-08-01 23:00:20 +02:00
|
|
|
* this behaviour is exploited by tcdrain().
|
|
|
|
*
|
|
|
|
* According to POSIX.1 spec (7.2.2.1.2) breaks should be
|
|
|
|
* between 0.25 and 0.5 seconds so we'll ask for something
|
|
|
|
* in the middle: 0.375 seconds.
|
|
|
|
*/
|
|
|
|
rc = tty_check_change(tty);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2014-05-18 01:54:31 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
rc = ch->ch_bd->bd_ops->drain(tty, 0);
|
|
|
|
|
2014-08-19 17:30:23 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EINTR;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-09-29 10:40:41 +02:00
|
|
|
if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP))
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_bd->bd_ops->send_break(ch, 250);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case TCSBRKP:
|
2013-08-21 19:30:11 +02:00
|
|
|
/* support for POSIX tcsendbreak()
|
2013-08-01 23:00:20 +02:00
|
|
|
* According to POSIX.1 spec (7.2.2.1.2) breaks should be
|
|
|
|
* between 0.25 and 0.5 seconds so we'll ask for something
|
|
|
|
* in the middle: 0.375 seconds.
|
|
|
|
*/
|
|
|
|
rc = tty_check_change(tty);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2014-05-18 01:54:31 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
rc = ch->ch_bd->bd_ops->drain(tty, 0);
|
2014-08-19 17:30:23 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EINTR;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_bd->bd_ops->send_break(ch, 250);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case TIOCSBRK:
|
|
|
|
rc = tty_check_change(tty);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2014-05-18 01:54:31 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
rc = ch->ch_bd->bd_ops->drain(tty, 0);
|
2014-08-19 17:30:23 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EINTR;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
ch->ch_bd->bd_ops->send_break(ch, 250);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case TIOCCBRK:
|
|
|
|
/* Do Nothing */
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case TIOCGSOFTCAR:
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2015-10-02 19:15:55 +02:00
|
|
|
rc = put_user(C_CLOCAL(tty) ? 1 : 0,
|
2015-10-04 16:20:13 +02:00
|
|
|
(unsigned long __user *)arg);
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case TIOCSSOFTCAR:
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2015-10-04 16:20:13 +02:00
|
|
|
rc = get_user(arg, (unsigned long __user *)arg);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2015-10-02 19:15:55 +02:00
|
|
|
tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) |
|
|
|
|
(arg ? CLOCAL : 0));
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_bd->bd_ops->param(tty);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
case TIOCMGET:
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return dgnc_get_modem_info(ch, uarg);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case TIOCMBIS:
|
|
|
|
case TIOCMBIC:
|
|
|
|
case TIOCMSET:
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return dgnc_set_modem_info(tty, cmd, uarg);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Here are any additional ioctl's that we want to implement
|
|
|
|
*/
|
2013-08-21 17:08:11 +02:00
|
|
|
|
|
|
|
case TCFLSH:
|
2013-08-01 23:00:20 +02:00
|
|
|
/*
|
|
|
|
* The linux tty driver doesn't have a flush
|
|
|
|
* input routine for the driver, assuming all backed
|
|
|
|
* up data is in the line disc. buffers. However,
|
|
|
|
* we all know that's not the case. Here, we
|
|
|
|
* act on the ioctl, but then lie and say we didn't
|
|
|
|
* so the line discipline will process the flush
|
|
|
|
* also.
|
2013-08-21 17:08:11 +02:00
|
|
|
*/
|
2013-08-01 23:00:20 +02:00
|
|
|
rc = tty_check_change(tty);
|
|
|
|
if (rc) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((arg == TCIFLUSH) || (arg == TCIOFLUSH)) {
|
|
|
|
ch->ch_r_head = ch->ch_r_tail;
|
|
|
|
ch->ch_bd->bd_ops->flush_uart_read(ch);
|
|
|
|
/* Force queue flow control to be released, if needed */
|
|
|
|
dgnc_check_queue_flow_control(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((arg == TCOFLUSH) || (arg == TCIOFLUSH)) {
|
|
|
|
if (!(un->un_type == DGNC_PRINT)) {
|
|
|
|
ch->ch_w_head = ch->ch_w_tail;
|
|
|
|
ch->ch_bd->bd_ops->flush_uart_write(ch);
|
|
|
|
|
|
|
|
if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) {
|
2015-10-02 19:15:55 +02:00
|
|
|
ch->ch_tun.un_flags &=
|
|
|
|
~(UN_LOW|UN_EMPTY);
|
2013-08-01 23:00:20 +02:00
|
|
|
wake_up_interruptible(&ch->ch_tun.un_flags_wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) {
|
2015-10-02 19:15:55 +02:00
|
|
|
ch->ch_pun.un_flags &=
|
|
|
|
~(UN_LOW|UN_EMPTY);
|
2013-08-01 23:00:20 +02:00
|
|
|
wake_up_interruptible(&ch->ch_pun.un_flags_wait);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
/* pretend we didn't recognize this IOCTL */
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOIOCTLCMD;
|
2013-08-01 23:00:20 +02:00
|
|
|
case TCSETSF:
|
|
|
|
case TCSETSW:
|
|
|
|
/*
|
|
|
|
* The linux tty driver doesn't have a flush
|
|
|
|
* input routine for the driver, assuming all backed
|
|
|
|
* up data is in the line disc. buffers. However,
|
|
|
|
* we all know that's not the case. Here, we
|
|
|
|
* act on the ioctl, but then lie and say we didn't
|
|
|
|
* so the line discipline will process the flush
|
|
|
|
* also.
|
|
|
|
*/
|
|
|
|
if (cmd == TCSETSF) {
|
|
|
|
/* flush rx */
|
|
|
|
ch->ch_flags &= ~CH_STOP;
|
|
|
|
ch->ch_r_head = ch->ch_r_tail;
|
|
|
|
ch->ch_bd->bd_ops->flush_uart_read(ch);
|
|
|
|
/* Force queue flow control to be released, if needed */
|
|
|
|
dgnc_check_queue_flow_control(ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now wait for all the output to drain */
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
rc = ch->ch_bd->bd_ops->drain(tty, 0);
|
2014-08-19 17:30:23 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EINTR;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* pretend we didn't recognize this */
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOIOCTLCMD;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case TCSETAW:
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
rc = ch->ch_bd->bd_ops->drain(tty, 0);
|
2014-08-19 17:30:23 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EINTR;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/* pretend we didn't recognize this */
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOIOCTLCMD;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case TCXONC:
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
/* Make the ld do it */
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOIOCTLCMD;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case DIGI_GETA:
|
|
|
|
/* get information for ditty */
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return dgnc_tty_digigeta(tty, uarg);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case DIGI_SETAW:
|
|
|
|
case DIGI_SETAF:
|
|
|
|
|
|
|
|
/* set information for ditty */
|
|
|
|
if (cmd == (DIGI_SETAW)) {
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
rc = ch->ch_bd->bd_ops->drain(tty, 0);
|
2014-08-19 17:30:23 +02:00
|
|
|
|
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EINTR;
|
2014-08-19 17:30:23 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2014-05-18 01:54:29 +02:00
|
|
|
} else {
|
2013-08-01 23:00:20 +02:00
|
|
|
tty_ldisc_flush(tty);
|
|
|
|
}
|
|
|
|
/* fall thru */
|
|
|
|
|
|
|
|
case DIGI_SETA:
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return dgnc_tty_digiseta(tty, uarg);
|
2013-08-21 17:08:11 +02:00
|
|
|
|
2013-08-01 23:00:20 +02:00
|
|
|
case DIGI_LOOPBACK:
|
|
|
|
{
|
|
|
|
uint loopback = 0;
|
2015-10-02 19:15:55 +02:00
|
|
|
/* Let go of locks when accessing user space,
|
|
|
|
* could sleep
|
|
|
|
*/
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2015-10-04 16:20:13 +02:00
|
|
|
rc = get_user(loopback, (unsigned int __user *)arg);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-08-21 17:08:11 +02:00
|
|
|
/* Enable/disable internal loopback for this port */
|
2013-08-01 23:00:20 +02:00
|
|
|
if (loopback)
|
|
|
|
ch->ch_flags |= CH_LOOPBACK;
|
|
|
|
else
|
|
|
|
ch->ch_flags &= ~(CH_LOOPBACK);
|
|
|
|
|
|
|
|
ch->ch_bd->bd_ops->param(tty);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-21 19:30:11 +02:00
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case DIGI_GETCUSTOMBAUD:
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2015-10-04 16:20:13 +02:00
|
|
|
rc = put_user(ch->ch_custom_speed, (unsigned int __user *)arg);
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
case DIGI_SETCUSTOMBAUD:
|
|
|
|
{
|
2014-03-11 04:19:06 +01:00
|
|
|
int new_rate;
|
2013-08-01 23:00:20 +02:00
|
|
|
/* Let go of locks when accessing user space, could sleep */
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2015-10-04 16:20:13 +02:00
|
|
|
rc = get_user(new_rate, (int __user *)arg);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
dgnc_set_custom_speed(ch, new_rate);
|
|
|
|
ch->ch_bd->bd_ops->param(tty);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-21 19:30:11 +02:00
|
|
|
}
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This ioctl allows insertion of a character into the front
|
|
|
|
* of any pending data to be transmitted.
|
|
|
|
*
|
|
|
|
* This ioctl is to satify the "Send Character Immediate"
|
|
|
|
* call that the RealPort protocol spec requires.
|
|
|
|
*/
|
|
|
|
case DIGI_REALPORT_SENDIMMEDIATE:
|
|
|
|
{
|
|
|
|
unsigned char c;
|
2014-09-29 10:42:28 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2015-10-04 16:20:13 +02:00
|
|
|
rc = get_user(c, (unsigned char __user *)arg);
|
2013-08-01 23:00:20 +02:00
|
|
|
if (rc)
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
ch->ch_bd->bd_ops->send_immediate_char(ch, c);
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This ioctl returns all the current counts for the port.
|
|
|
|
*
|
|
|
|
* This ioctl is to satify the "Line Error Counters"
|
|
|
|
* call that the RealPort protocol spec requires.
|
|
|
|
*/
|
|
|
|
case DIGI_REALPORT_GETCOUNTERS:
|
|
|
|
{
|
|
|
|
struct digi_getcounter buf;
|
|
|
|
|
|
|
|
buf.norun = ch->ch_err_overrun;
|
2014-10-08 12:49:51 +02:00
|
|
|
buf.noflow = 0; /* The driver doesn't keep this stat */
|
2013-08-01 23:00:20 +02:00
|
|
|
buf.nframe = ch->ch_err_frame;
|
|
|
|
buf.nparity = ch->ch_err_parity;
|
|
|
|
buf.nbreak = ch->ch_err_break;
|
|
|
|
buf.rbytes = ch->ch_rxcount;
|
|
|
|
buf.tbytes = ch->ch_txcount;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (copy_to_user(uarg, &buf, sizeof(buf)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2014-05-18 01:54:31 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This ioctl returns all current events.
|
|
|
|
*
|
|
|
|
* This ioctl is to satify the "Event Reporting"
|
|
|
|
* call that the RealPort protocol spec requires.
|
2013-08-21 19:30:11 +02:00
|
|
|
*/
|
2013-08-01 23:00:20 +02:00
|
|
|
case DIGI_REALPORT_GETEVENTS:
|
|
|
|
{
|
|
|
|
unsigned int events = 0;
|
|
|
|
|
|
|
|
/* NOTE: MORE EVENTS NEEDS TO BE ADDED HERE */
|
|
|
|
if (ch->ch_flags & CH_BREAK_SENDING)
|
|
|
|
events |= EV_TXB;
|
2015-10-02 19:15:55 +02:00
|
|
|
if ((ch->ch_flags & CH_STOP) ||
|
|
|
|
(ch->ch_flags & CH_FORCED_STOP))
|
2013-08-01 23:00:20 +02:00
|
|
|
events |= (EV_OPU | EV_OPS);
|
2014-05-18 01:54:31 +02:00
|
|
|
|
2015-10-02 19:15:55 +02:00
|
|
|
if ((ch->ch_flags & CH_STOPI) ||
|
|
|
|
(ch->ch_flags & CH_FORCED_STOPI))
|
2013-08-01 23:00:20 +02:00
|
|
|
events |= (EV_IPU | EV_IPS);
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2015-10-04 16:20:13 +02:00
|
|
|
rc = put_user(events, (unsigned int __user *)arg);
|
2013-09-09 21:01:23 +02:00
|
|
|
return rc;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This ioctl returns TOUT and TIN counters based
|
|
|
|
* upon the values passed in by the RealPort Server.
|
|
|
|
* It also passes back whether the UART Transmitter is
|
|
|
|
* empty as well.
|
2013-08-21 19:30:11 +02:00
|
|
|
*/
|
2013-08-01 23:00:20 +02:00
|
|
|
case DIGI_REALPORT_GETBUFFERS:
|
|
|
|
{
|
|
|
|
struct digi_getbuffer buf;
|
|
|
|
int tdist;
|
|
|
|
int count;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get data from user first.
|
|
|
|
*/
|
2014-05-18 01:54:31 +02:00
|
|
|
if (copy_from_user(&buf, uarg, sizeof(buf)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2013-08-01 23:00:20 +02:00
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_lock_irqsave(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Figure out how much data is in our RX and TX queues.
|
|
|
|
*/
|
|
|
|
buf.rxbuf = (ch->ch_r_head - ch->ch_r_tail) & RQUEUEMASK;
|
|
|
|
buf.txbuf = (ch->ch_w_head - ch->ch_w_tail) & WQUEUEMASK;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is the UART empty? Add that value to whats in our TX queue.
|
|
|
|
*/
|
|
|
|
count = buf.txbuf + ch->ch_bd->bd_ops->get_uart_bytes_left(ch);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Figure out how much data the RealPort Server believes should
|
|
|
|
* be in our TX queue.
|
|
|
|
*/
|
|
|
|
tdist = (buf.tIn - buf.tOut) & 0xffff;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have more data than the RealPort Server believes we
|
|
|
|
* should have, reduce our count to its amount.
|
|
|
|
*
|
|
|
|
* This count difference CAN happen because the Linux LD can
|
|
|
|
* insert more characters into our queue for OPOST processing
|
|
|
|
* that the RealPort Server doesn't know about.
|
|
|
|
*/
|
2014-05-18 01:54:31 +02:00
|
|
|
if (buf.txbuf > tdist)
|
2013-08-01 23:00:20 +02:00
|
|
|
buf.txbuf = tdist;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Report whether our queue and UART TX are completely empty.
|
|
|
|
*/
|
2014-05-18 01:54:31 +02:00
|
|
|
if (count)
|
2013-08-01 23:00:20 +02:00
|
|
|
buf.txdone = 0;
|
2014-05-18 01:54:31 +02:00
|
|
|
else
|
2013-08-01 23:00:20 +02:00
|
|
|
buf.txdone = 1;
|
|
|
|
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2014-05-18 01:54:31 +02:00
|
|
|
if (copy_to_user(uarg, &buf, sizeof(buf)))
|
2013-09-09 21:01:23 +02:00
|
|
|
return -EFAULT;
|
2014-05-18 01:54:31 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return 0;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
default:
|
staging: dgnc: dgnc_tty.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:37 +02:00
|
|
|
spin_unlock_irqrestore(&ch->ch_lock, flags);
|
2013-08-01 23:00:20 +02:00
|
|
|
|
2013-09-09 21:01:23 +02:00
|
|
|
return -ENOIOCTLCMD;
|
2013-08-01 23:00:20 +02:00
|
|
|
}
|
|
|
|
}
|