[PATCH 1/1] Staging: dgnc: dgnc_tty: code style improvements

From: Tolga Ceylan
Date: Wed Feb 11 2015 - 04:09:09 EST


Coding style improvements based on check_patch.pl:
1) Modified lines over 80 characters to fit.
2) Removed curly braces from a single line if block at
dgnc_check_queue_flow_control().
3) Combined two if statements to reduce nesting in
dgnc_wakeup_writes().
4) Combined and reverted logic in if statement in
dgnc_tty_ioctl() at case TCLFLSH to reduce nesting.

Signed-off-by: Tolga Ceylan <tolga.ceylan@xxxxxxxxx>
---
drivers/staging/dgnc/dgnc_tty.c | 266 +++++++++++++++++++++++++---------------
1 file changed, 168 insertions(+), 98 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index f81a375..ff650cb 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -105,10 +105,14 @@ static struct ktermios DgncDefaultTermios = {
/* 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);
-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);
+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);
static int dgnc_tty_write_room(struct tty_struct *tty);
static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c);
static int dgnc_tty_chars_in_buffer(struct tty_struct *tty);
@@ -119,14 +123,19 @@ 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);
-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);
+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);
static int dgnc_tty_tiocmget(struct tty_struct *tty);
-static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear);
+static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set,
+ unsigned int clear);
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);
-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);
+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);
static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch);


@@ -207,18 +216,22 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL;
brd->SerialDriver.init_termios = DgncDefaultTermios;
brd->SerialDriver.driver_name = DRVSTR;
- brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
+ brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);

/*
* The kernel wants space to store pointers to
* tty_struct's and termios's.
*/
- brd->SerialDriver.ttys = kcalloc(brd->maxports, sizeof(*brd->SerialDriver.ttys), GFP_KERNEL);
+ brd->SerialDriver.ttys = kcalloc(brd->maxports,
+ sizeof(*brd->SerialDriver.ttys), GFP_KERNEL);
if (!brd->SerialDriver.ttys)
return -ENOMEM;

kref_init(&brd->SerialDriver.kref);
- brd->SerialDriver.termios = kcalloc(brd->maxports, sizeof(*brd->SerialDriver.termios), GFP_KERNEL);
+ brd->SerialDriver.termios = kcalloc(brd->maxports,
+ sizeof(*brd->SerialDriver.termios), GFP_KERNEL);
if (!brd->SerialDriver.termios)
return -ENOMEM;

@@ -256,18 +269,22 @@ int dgnc_tty_register(struct dgnc_board *brd)
brd->PrintDriver.subtype = SERIAL_TYPE_NORMAL;
brd->PrintDriver.init_termios = DgncDefaultTermios;
brd->PrintDriver.driver_name = DRVSTR;
- brd->PrintDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK);
+ brd->PrintDriver.flags = (TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_DYNAMIC_DEV |
+ TTY_DRIVER_HARDWARE_BREAK);

/*
* The kernel wants space to store pointers to
* tty_struct's and termios's. Must be separated from
* the Serial Driver so we don't get confused
*/
- brd->PrintDriver.ttys = kcalloc(brd->maxports, sizeof(*brd->PrintDriver.ttys), GFP_KERNEL);
+ brd->PrintDriver.ttys = kcalloc(brd->maxports,
+ sizeof(*brd->PrintDriver.ttys), GFP_KERNEL);
if (!brd->PrintDriver.ttys)
return -ENOMEM;
kref_init(&brd->PrintDriver.kref);
- brd->PrintDriver.termios = kcalloc(brd->maxports, sizeof(*brd->PrintDriver.termios), GFP_KERNEL);
+ brd->PrintDriver.termios = kcalloc(brd->maxports,
+ sizeof(*brd->PrintDriver.termios), GFP_KERNEL);
if (!brd->PrintDriver.termios)
return -ENOMEM;

@@ -331,7 +348,8 @@ int dgnc_tty_init(struct dgnc_board *brd)
* 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);
+ brd->channels[i] = kzalloc(sizeof(*brd->channels[i]),
+ GFP_KERNEL);
}
}

@@ -420,7 +438,8 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
dgnc_BoardsByMajor[brd->SerialDriver.major] = NULL;
brd->dgnc_Serial_Major = 0;
for (i = 0; i < brd->nasync; i++) {
- dgnc_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs);
+ dgnc_remove_tty_sysfs(
+ brd->channels[i]->ch_tun.un_sysfs);
tty_unregister_device(&brd->SerialDriver, i);
}
tty_unregister_driver(&brd->SerialDriver);
@@ -431,7 +450,8 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
dgnc_BoardsByMajor[brd->PrintDriver.major] = NULL;
brd->dgnc_TransparentPrint_Major = 0;
for (i = 0; i < brd->nasync; i++) {
- dgnc_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs);
+ dgnc_remove_tty_sysfs(
+ brd->channels[i]->ch_pun.un_sysfs);
tty_unregister_device(&brd->PrintDriver, i);
}
tty_unregister_driver(&brd->PrintDriver);
@@ -548,8 +568,10 @@ void dgnc_input(struct channel_t *ch)
* If the device is not open, or CREAD is off,
* flush input data and return immediately.
*/
- 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)) {
+ 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)) {

ch->ch_r_head = tail;

@@ -649,16 +671,27 @@ void dgnc_input(struct channel_t *ch)
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)
- 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);
+ 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);
else
- tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_NORMAL);
+ tty_insert_flip_char(tp->port,
+ *(ch->ch_rqueue + tail + i),
+ TTY_NORMAL);
}
} else {
- tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s);
+ tty_insert_flip_string(tp->port,
+ ch->ch_rqueue + tail, s);
}

tail += s;
@@ -830,7 +863,8 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate)
*/
if (testrate_high != newrate) {
/*
- * Otherwise, pick the rate that is closer (i.e. whichever rate
+ * Otherwise, pick the rate that is closer
+ * (i.e. whichever rate
* has a smaller delta).
*/
deltahigh = testrate_high - newrate;
@@ -873,7 +907,8 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
*/
if (qleft < 256) {
/* HWFLOW */
- if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS) {
+ if (ch->ch_digi.digi_flags & CTSPACE ||
+ ch->ch_c_cflag & CRTSCTS) {
if (!(ch->ch_flags & CH_RECEIVER_OFF)) {
ch->ch_bd->bd_ops->disable_receiver(ch);
ch->ch_flags |= (CH_RECEIVER_OFF);
@@ -888,7 +923,9 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
}
/* No FLOW */
else {
- /* Empty... Can't do anything about the impending overflow... */
+ /* Empty... Can't do anything about
+ * the impending overflow...
+ */
}
}

@@ -909,7 +946,8 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
*/
if (qleft > (RQUEUESIZE / 2)) {
/* HWFLOW */
- if (ch->ch_digi.digi_flags & RTSPACE || ch->ch_c_cflag & CRTSCTS) {
+ if (ch->ch_digi.digi_flags & RTSPACE ||
+ ch->ch_c_cflag & CRTSCTS) {
if (ch->ch_flags & CH_RECEIVER_OFF) {
ch->ch_bd->bd_ops->enable_receiver(ch);
ch->ch_flags &= ~(CH_RECEIVER_OFF);
@@ -921,9 +959,8 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
ch->ch_bd->bd_ops->send_start_character(ch);
}
/* No FLOW */
- else {
+ else
/* Nothing needed. */
- }
}
}

@@ -954,7 +991,8 @@ void dgnc_wakeup_writes(struct channel_t *ch)
if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
ch->ch_tun.un_tty->ldisc->ops->write_wakeup) {
spin_unlock_irqrestore(&ch->ch_lock, flags);
- (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty);
+ (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(
+ ch->ch_tun.un_tty);
spin_lock_irqsave(&ch->ch_lock, flags);
}

@@ -964,27 +1002,27 @@ void dgnc_wakeup_writes(struct channel_t *ch)
* 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) {
- if ((qlen == 0) && (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) {
- 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);
- }
+ if ((ch->ch_tun.un_flags & UN_EMPTY) &&
+ (qlen == 0) &&
+ (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) {
+ 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);
}
}

@@ -995,7 +1033,8 @@ void dgnc_wakeup_writes(struct channel_t *ch)
if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
ch->ch_pun.un_tty->ldisc->ops->write_wakeup) {
spin_unlock_irqrestore(&ch->ch_lock, flags);
- (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty);
+ (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(
+ ch->ch_pun.un_tty);
spin_lock_irqsave(&ch->ch_lock, flags);
}

@@ -1006,7 +1045,8 @@ void dgnc_wakeup_writes(struct channel_t *ch)
* the queue AND FIFO are both empty.
*/
if (ch->ch_pun.un_flags & UN_EMPTY) {
- if ((qlen == 0) && (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0))
+ if ((qlen == 0) &&
+ (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0))
ch->ch_pun.un_flags &= ~(UN_EMPTY);
}

@@ -1100,7 +1140,8 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
*/
spin_unlock_irqrestore(&ch->ch_lock, flags);

- rc = wait_event_interruptible(ch->ch_flags_wait, ((ch->ch_flags & CH_OPENING) == 0));
+ rc = wait_event_interruptible(ch->ch_flags_wait,
+ ((ch->ch_flags & CH_OPENING) == 0));

/* If ret is non-zero, user ctrl-c'ed us */
if (rc)
@@ -1114,7 +1155,8 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
* ch_flags_wait to wake us back up.
*/
rc = wait_event_interruptible(ch->ch_flags_wait,
- (((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING) == 0));
+ (((ch->ch_tun.un_flags | ch->ch_pun.un_flags) &
+ UN_CLOSING) == 0));

/* If ret is non-zero, user ctrl-c'ed us */
if (rc)
@@ -1233,7 +1275,8 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
*
* Wait for DCD, if needed.
*/
-static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch)
+static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file,
+ struct channel_t *ch)
{
int retval = 0;
struct un_t *un = NULL;
@@ -1241,7 +1284,8 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc
uint old_flags = 0;
int sleep_on_un_flags = 0;

- if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGNC_CHANNEL_MAGIC)
+ if (!tty || tty->magic != TTY_MAGIC || !file || !ch ||
+ ch->magic != DGNC_CHANNEL_MAGIC)
return -ENXIO;

un = tty->driver_data;
@@ -1258,7 +1302,8 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc
sleep_on_un_flags = 0;

/*
- * If board has failed somehow during our sleep, bail with error.
+ * If board has failed somehow during our sleep,
+ * bail with error.
*/
if (ch->ch_bd->state == BOARD_FAILED) {
retval = -ENXIO;
@@ -1278,7 +1323,8 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc
* touched safely, the close routine will signal the
* ch_wait_flags to wake us back up.
*/
- if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING)) {
+ if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) &
+ UN_CLOSING)) {

/*
* Our conditions to leave cleanly and happily:
@@ -1331,11 +1377,13 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc
spin_unlock_irqrestore(&ch->ch_lock, flags);

/*
- * Wait for something in the flags to change from the current value.
+ * Wait for something in the flags to change
+ * from the current value.
*/
if (sleep_on_un_flags)
retval = wait_event_interruptible(un->un_flags_wait,
- (old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags)));
+ (old_flags != (ch->ch_tun.un_flags |
+ ch->ch_pun.un_flags)));
else
retval = wait_event_interruptible(ch->ch_flags_wait,
(old_flags != ch->ch_flags));
@@ -1454,7 +1502,8 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file)
* Only officially close channel if count is 0 and
* DIGI_PRINTER bit is not set.
*/
- if ((ch->ch_open_count == 0) && !(ch->ch_digi.digi_flags & DIGI_PRINTER)) {
+ if ((ch->ch_open_count == 0) &&
+ !(ch->ch_digi.digi_flags & DIGI_PRINTER)) {

ch->ch_flags &= ~(CH_STOPI | CH_FORCED_STOPI);

@@ -1611,15 +1660,19 @@ static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available)
int cps_limit = 0;
unsigned long current_time = jiffies;
unsigned long buffer_time = current_time +
- (HZ * ch->ch_digi.digi_bufsize) / ch->ch_digi.digi_maxcps;
+ (HZ * ch->ch_digi.digi_bufsize) /
+ ch->ch_digi.digi_maxcps;

if (ch->ch_cpstime < current_time) {
/* buffer is empty */
- ch->ch_cpstime = current_time; /* reset ch_cpstime */
+ /* reset ch_cpstime */
+ ch->ch_cpstime = current_time;
cps_limit = ch->ch_digi.digi_bufsize;
} else if (ch->ch_cpstime < buffer_time) {
/* still room in the buffer */
- cps_limit = ((buffer_time - ch->ch_cpstime) * ch->ch_digi.digi_maxcps) / HZ;
+ cps_limit = (
+ (buffer_time - ch->ch_cpstime) *
+ ch->ch_digi.digi_maxcps) / HZ;
} else {
/* no room in the buffer */
cps_limit = 0;
@@ -1805,7 +1858,8 @@ static int dgnc_tty_write(struct tty_struct *tty,
}

/*
- * If there is nothing left to copy, or I can't handle any more data, leave.
+ * If there is nothing left to copy, or
+ * I can't handle any more data, leave.
*/
if (count <= 0) {
spin_unlock_irqrestore(&ch->ch_lock, flags);
@@ -1831,7 +1885,8 @@ static int dgnc_tty_write(struct tty_struct *tty,
* copy_from_user() returns the number
* of bytes that could *NOT* be copied.
*/
- count -= copy_from_user(dgnc_TmpWriteBuf, (const unsigned char __user *) buf, count);
+ count -= copy_from_user(dgnc_TmpWriteBuf,
+ (const unsigned char __user *) buf, count);

if (!count) {
up(&dgnc_TmpWriteSem);
@@ -2160,7 +2215,8 @@ static inline int dgnc_get_mstat(struct channel_t *ch)
/*
* Return modem signals to ld.
*/
-static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value)
+static int dgnc_get_modem_info(struct channel_t *ch,
+ unsigned int __user *value)
{
int result;

@@ -2181,7 +2237,8 @@ static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value
*
* Set modem signals, called by ld.
*/
-static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value)
+static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command,
+ unsigned int __user *value)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -2264,7 +2321,8 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns
*
*
*/
-static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo)
+static int dgnc_tty_digigeta(struct tty_struct *tty,
+ struct digi_t __user *retinfo)
{
struct channel_t *ch;
struct un_t *un;
@@ -2306,7 +2364,8 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin
*
*
*/
-static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info)
+static int dgnc_tty_digiseta(struct tty_struct *tty,
+ struct digi_t __user *new_info)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -2337,17 +2396,21 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i
/*
* Handle transistions to and from RTS Toggle.
*/
- if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && (new_digi.digi_flags & DIGI_RTS_TOGGLE))
+ if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) &&
+ (new_digi.digi_flags & DIGI_RTS_TOGGLE))
ch->ch_mostat &= ~(UART_MCR_RTS);
- if ((ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && !(new_digi.digi_flags & DIGI_RTS_TOGGLE))
+ if ((ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) &&
+ !(new_digi.digi_flags & DIGI_RTS_TOGGLE))
ch->ch_mostat |= (UART_MCR_RTS);

/*
* Handle transistions to and from DTR Toggle.
*/
- if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && (new_digi.digi_flags & DIGI_DTR_TOGGLE))
+ if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) &&
+ (new_digi.digi_flags & DIGI_DTR_TOGGLE))
ch->ch_mostat &= ~(UART_MCR_DTR);
- if ((ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && !(new_digi.digi_flags & DIGI_DTR_TOGGLE))
+ if ((ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) &&
+ !(new_digi.digi_flags & DIGI_DTR_TOGGLE))
ch->ch_mostat |= (UART_MCR_DTR);

memcpy(&ch->ch_digi, &new_digi, sizeof(new_digi));
@@ -2384,7 +2447,8 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i
/*
* dgnc_set_termios()
*/
-static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
+static void dgnc_tty_set_termios(struct tty_struct *tty,
+ struct ktermios *old_termios)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -2748,7 +2812,8 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,

spin_unlock_irqrestore(&ch->ch_lock, flags);

- rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg);
+ rc = put_user(C_CLOCAL(tty) ? 1 : 0,
+ (unsigned long __user *) arg);
return rc;

case TIOCSSOFTCAR:
@@ -2759,7 +2824,8 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
return rc;

spin_lock_irqsave(&ch->ch_lock, flags);
- tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
+ tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) |
+ (arg ? CLOCAL : 0));
ch->ch_bd->bd_ops->param(tty);
spin_unlock_irqrestore(&ch->ch_lock, flags);

@@ -2802,21 +2868,21 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
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 (((arg == TCOFLUSH) || (arg == TCIOFLUSH)) &&
+ (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)) {
- 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);
- }
+ 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);
}
}

@@ -2897,7 +2963,9 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
case DIGI_LOOPBACK:
{
uint loopback = 0;
- /* Let go of locks when accessing user space, could sleep */
+ /* Let go of locks when accessing user space,
+ * could sleep
+ */
spin_unlock_irqrestore(&ch->ch_lock, flags);
rc = get_user(loopback, (unsigned int __user *) arg);
if (rc)
@@ -2995,10 +3063,12 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
/* NOTE: MORE EVENTS NEEDS TO BE ADDED HERE */
if (ch->ch_flags & CH_BREAK_SENDING)
events |= EV_TXB;
- if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP))
+ if ((ch->ch_flags & CH_STOP) ||
+ (ch->ch_flags & CH_FORCED_STOP))
events |= (EV_OPU | EV_OPS);

- if ((ch->ch_flags & CH_STOPI) || (ch->ch_flags & CH_FORCED_STOPI))
+ if ((ch->ch_flags & CH_STOPI) ||
+ (ch->ch_flags & CH_FORCED_STOPI))
events |= (EV_IPU | EV_IPS);

spin_unlock_irqrestore(&ch->ch_lock, flags);
--
2.3.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/