[PATCH RFC] staging: dgap: more 80+ char lines work

Mark Hounschell markh at compro.net
Fri Mar 7 21:57:50 UTC 2014


This is just for comments. The indentation was alread so far
over 80 chars I (as recommended earlier) make a couple of
new functions. Somehow I don't think this is proper and there
is probably a better way to do this. This is untested.

Signed-off-by: Mark Hounschell <markh at compro.net>
---
 drivers/staging/dgap/dgap.c | 93 ++++++++++++++++++++++-----------------------
 1 file changed, 46 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index af87df9..477ae0b 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -5732,6 +5732,44 @@ static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf,
 	*len = count;
 }
 
+static void dgap_try_tty_write_wakeup(ulong lock_flags, ulong lock_flags2,
+				      struct channel_t *ch)
+{
+	void (*write_wakeup)(struct tty_struct *);
+	struct board_t *bd = ch->ch_bd;
+
+	write_wakeup = ch->ch_tun.un_tty->ldisc->ops->write_wakeup;
+	if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+	    write_wakeup) {
+		DGAP_UNLOCK(ch->ch_lock, lock_flags2);
+		DGAP_UNLOCK(bd->bd_lock, lock_flags);
+		(*write_wakeup)(ch->ch_tun.un_tty);
+		DGAP_LOCK(bd->bd_lock, lock_flags);
+		DGAP_LOCK(ch->ch_lock, lock_flags2);
+	}
+	wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
+	wake_up_interruptible(&ch->ch_tun.un_flags_wait);
+}
+
+static void dgap_try_pr_write_wakeup(ulong lock_flags, ulong lock_flags2,
+				     struct channel_t *ch)
+{
+	void (*write_wakeup)(struct tty_struct *);
+	struct board_t *bd = ch->ch_bd;
+
+	write_wakeup = ch->ch_pun.un_tty->ldisc->ops->write_wakeup;
+	if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+	    write_wakeup) {
+		DGAP_UNLOCK(ch->ch_lock, lock_flags2);
+		DGAP_UNLOCK(bd->bd_lock, lock_flags);
+		(*write_wakeup)(ch->ch_pun.un_tty);
+		DGAP_LOCK(bd->bd_lock, lock_flags);
+		DGAP_LOCK(ch->ch_lock, lock_flags2);
+	}
+	wake_up_interruptible(&ch->ch_pun.un_tty->write_wait);
+	wake_up_interruptible(&ch->ch_pun.un_flags_wait);
+}
+
 /*=======================================================================
  *
  *      dgap_event - FEP to host event processing routine.
@@ -5889,36 +5927,17 @@ static int dgap_event(struct board_t *bd)
 
 			if (ch->ch_tun.un_flags & UN_LOW) {
 				ch->ch_tun.un_flags &= ~UN_LOW;
-
 				if (ch->ch_tun.un_flags & UN_ISOPEN) {
-					if ((ch->ch_tun.un_tty->flags &
-					   (1 << TTY_DO_WRITE_WAKEUP)) &&
-						ch->ch_tun.un_tty->ldisc->ops->write_wakeup) {
-						DGAP_UNLOCK(ch->ch_lock, lock_flags2);
-						DGAP_UNLOCK(bd->bd_lock, lock_flags);
-						(ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty);
-						DGAP_LOCK(bd->bd_lock, lock_flags);
-						DGAP_LOCK(ch->ch_lock, lock_flags2);
-					}
-					wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
-					wake_up_interruptible(&ch->ch_tun.un_flags_wait);
+					dgap_try_tty_write_wakeup
+						(lock_flags, lock_flags2, ch);
 				}
 			}
 
 			if (ch->ch_pun.un_flags & UN_LOW) {
 				ch->ch_pun.un_flags &= ~UN_LOW;
 				if (ch->ch_pun.un_flags & UN_ISOPEN) {
-					if ((ch->ch_pun.un_tty->flags &
-					   (1 << TTY_DO_WRITE_WAKEUP)) &&
-						ch->ch_pun.un_tty->ldisc->ops->write_wakeup) {
-						DGAP_UNLOCK(ch->ch_lock, lock_flags2);
-						DGAP_UNLOCK(bd->bd_lock, lock_flags);
-						(ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty);
-						DGAP_LOCK(bd->bd_lock, lock_flags);
-						DGAP_LOCK(ch->ch_lock, lock_flags2);
-					}
-					wake_up_interruptible(&ch->ch_pun.un_tty->write_wait);
-					wake_up_interruptible(&ch->ch_pun.un_flags_wait);
+					dgap_try_pr_write_wakeup
+						(lock_flags, lock_flags2, ch);
 				}
 			}
 
@@ -5935,39 +5954,19 @@ static int dgap_event(struct board_t *bd)
 			if (ch->ch_tun.un_flags & UN_EMPTY) {
 				ch->ch_tun.un_flags &= ~UN_EMPTY;
 				if (ch->ch_tun.un_flags & UN_ISOPEN) {
-					if ((ch->ch_tun.un_tty->flags &
-					   (1 << TTY_DO_WRITE_WAKEUP)) &&
-						ch->ch_tun.un_tty->ldisc->ops->write_wakeup) {
-						DGAP_UNLOCK(ch->ch_lock, lock_flags2);
-						DGAP_UNLOCK(bd->bd_lock, lock_flags);
-
-						(ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty);
-						DGAP_LOCK(bd->bd_lock, lock_flags);
-						DGAP_LOCK(ch->ch_lock, lock_flags2);
-					}
-					wake_up_interruptible(&ch->ch_tun.un_tty->write_wait);
-					wake_up_interruptible(&ch->ch_tun.un_flags_wait);
+					dgap_try_tty_write_wakeup
+						(lock_flags, lock_flags2, ch);
 				}
 			}
 
 			if (ch->ch_pun.un_flags & UN_EMPTY) {
 				ch->ch_pun.un_flags &= ~UN_EMPTY;
 				if (ch->ch_pun.un_flags & UN_ISOPEN) {
-					if ((ch->ch_pun.un_tty->flags &
-					   (1 << TTY_DO_WRITE_WAKEUP)) &&
-						ch->ch_pun.un_tty->ldisc->ops->write_wakeup) {
-						DGAP_UNLOCK(ch->ch_lock, lock_flags2);
-						DGAP_UNLOCK(bd->bd_lock, lock_flags);
-						(ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty);
-						DGAP_LOCK(bd->bd_lock, lock_flags);
-						DGAP_LOCK(ch->ch_lock, lock_flags2);
-					}
-					wake_up_interruptible(&ch->ch_pun.un_tty->write_wait);
-					wake_up_interruptible(&ch->ch_pun.un_flags_wait);
+					dgap_try_pr_write_wakeup
+						(lock_flags, lock_flags2, ch);
 				}
 			}
 
-
 			if (ch->ch_flags & CH_WEMPTY) {
 				ch->ch_flags &= ~CH_WEMPTY;
 				wake_up_interruptible(&ch->ch_flags_wait);
-- 
1.8.1.4



More information about the devel mailing list