All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lidza Louina <lidza.louina@gmail.com>
To: driverdev-devel@linuxdriverproject.org,
	Greg KH <gregkh@linuxfoundation.org>,
	Mark Hounschell <markh@compro.net>
Cc: Lidza Louina <lidza.louina@gmail.com>
Subject: [PATCH 8/9] staging: dgnc: removes read_cnt, real_raw and rawreadok
Date: Mon, 12 Aug 2013 17:05:12 -0400	[thread overview]
Message-ID: <1376341513-20578-9-git-send-email-lidza.louina@gmail.com> (raw)
In-Reply-To: <1376341513-20578-1-git-send-email-lidza.louina@gmail.com>

Signed-off-by: Lidza Louina <lidza.louina@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 154 +++++++++++-----------------------------
 1 file changed, 43 insertions(+), 111 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 1fbd09f..299453f 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -747,14 +747,11 @@ void dgnc_input(struct channel_t *ch)
 	DPR_READ(("dgnc_input start 2\n"));
 
 	/* Decide how much data we can send into the tty layer */
-	if (dgnc_rawreadok && tp->real_raw)
-		flip_len = MYFLIPLEN;
-	else
-		flip_len = TTY_FLIPBUF_SIZE;
+	flip_len = TTY_FLIPBUF_SIZE;
 
 	/* Chop down the length, if needed */
 	len = min(data_len, flip_len);
-	len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt);
+	len = min(len, (N_TTY_BUF_SIZE - 1));
 
 	ld = tty_ldisc_ref(tp);
 
@@ -807,123 +804,58 @@ void dgnc_input(struct channel_t *ch)
 	 * 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.
 	 */
-	if (dgnc_rawreadok && tp->real_raw) {
-
-		if (ch->ch_flags & CH_FLIPBUF_IN_USE) {
-			DPR_READ(("DGNC - FLIPBUF in use. delaying input\n"));
-			DGNC_UNLOCK(ch->ch_lock, lock_flags);
-			if (ld)
-				tty_ldisc_deref(ld);
-			return;
-		}
-
-		ch->ch_flags |= CH_FLIPBUF_IN_USE;
-		buf = ch->ch_bd->flipbuf;
-
-		n = len;
-
-		/*
-		 * n now contains the most amount of data we can copy,
-		 * bounded either by the flip buffer size or the amount
-		 * of data the card actually has pending...
-		 */
-		while (n) {
-			s = ((head >= tail) ? head : RQUEUESIZE) - tail;
-			s = min(s, n);
-
-			if (s <= 0)
-				break;
-
-			memcpy(buf, ch->ch_rqueue + tail, s);
-			dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s);
-
-			tail += s;
-			buf += s;
-
-			n -= s;
-			/* Flip queue if needed */
-			tail &= rmask;
-		}
-
-		ch->ch_r_tail = tail & rmask;
-		ch->ch_e_tail = tail & rmask;
-
-		dgnc_check_queue_flow_control(ch);
-
-		/* !!! WE *MUST* LET GO OF ALL LOCKS BEFORE CALLING RECEIVE BUF !!! */
-
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
-
-		DPR_READ(("dgnc_input. %d real_raw len:%d calling receive_buf for buffer for board %d\n", 
-			 __LINE__, len, ch->ch_bd->boardnum));
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
-		tp->ldisc->ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len);
-#else
-		tp->ldisc.ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len);
-#endif
+	len = tty_buffer_request_room(tp->port, len);
+	n = len;
 
-		/* Allow use of channel flip buffer again */
-		DGNC_LOCK(ch->ch_lock, lock_flags);
-		ch->ch_flags &= ~CH_FLIPBUF_IN_USE;
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+	/*
+	 * 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);
 
-	}
-	else {
-		len = tty_buffer_request_room(tp->port, len);
-		n = len;
+		if (s <= 0)
+			break;
 
 		/*
-		 * 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...
+		 * If conditions are such that ld needs to see all 
+		 * UART errors, we will have to walk each character
+		 * and error byte and send them to the buffer one at
+		 * a time.
 		 */
-		while (n) {
-			s = ((head >= tail) ? head : RQUEUESIZE) - tail;
-			s = min(s, n);
-
-			if (s <= 0)
-				break;
-
-			/*
-			 * If conditions are such that ld needs to see all 
-			 * UART errors, we will have to walk each character
-			 * and error byte and send them to the buffer one at
-			 * a time.
-			 */
-			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);
-					else
-						tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_NORMAL);
-				}
+		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);
+				else
+					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);
-			}
-
-			dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s);
-
-			tail += s;
-			n -= s;
-			/* Flip queue if needed */
-			tail &= rmask;
+		}
+		else {
+			tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s);
 		}
 
-		ch->ch_r_tail = tail & rmask;
-		ch->ch_e_tail = tail & rmask;
-		dgnc_check_queue_flow_control(ch);
-		DGNC_UNLOCK(ch->ch_lock, lock_flags);
+		dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s);
 
-		/* Tell the tty layer its okay to "eat" the data now */
-		tty_flip_buffer_push(tp->port);
+		tail += s;
+		n -= s;
+		/* Flip queue if needed */
+		tail &= rmask;
 	}
 
+	ch->ch_r_tail = tail & rmask;
+	ch->ch_e_tail = tail & rmask;
+	dgnc_check_queue_flow_control(ch);
+	DGNC_UNLOCK(ch->ch_lock, lock_flags);
+
+	/* Tell the tty layer its okay to "eat" the data now */
+	tty_flip_buffer_push(tp->port);
 	if (ld)
 		tty_ldisc_deref(ld);
 
-- 
1.8.1.2

  parent reply	other threads:[~2013-08-12 21:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-12 21:05 [PATCH 0/9] staging: dgnc: builds this driver into the kernel Lidza Louina
2013-08-12 21:05 ` [PATCH 1/9] staging: dgnc: removes Makefile.inc Lidza Louina
2013-08-12 21:13   ` Greg KH
2013-08-13  2:41     ` Lidza Louina
2013-08-12 21:05 ` [PATCH 2/9] staging: dgnc: builds into kernel Lidza Louina
2013-08-12 21:10   ` Greg KH
2013-08-13  2:22     ` Lidza Louina
2013-08-12 21:05 ` [PATCH 3/9] staging: dgnc: removes proc code Lidza Louina
2013-08-12 21:11   ` Greg KH
2013-08-13  2:32     ` Lidza Louina
2013-08-12 21:05 ` [PATCH 4/9] staging: dgnc: fixes error: invalid type argument of ‘->’ (have ‘struct ktermios’) Lidza Louina
2013-08-12 21:12   ` [PATCH 4/9] staging: dgnc: fixes error: invalid type argument of ‘->’ (have ���struct ktermios’) Greg KH
2013-08-12 21:05 ` [PATCH 5/9] staging: dgnc: fixes error: expected ‘struct tty_port *’ but argument is of type ‘struct tty_struct *’ Lidza Louina
2013-08-12 21:13   ` Greg KH
2013-08-12 21:05 ` [PATCH 6/9] staging: dgnc: fixes error: incompatible types when assigning to type ‘struct ktermios *’ from type ‘struct ktermios’ Lidza Louina
2013-08-12 21:14   ` Greg KH
2013-08-13  7:30   ` Dan Carpenter
2013-08-13 13:20     ` Lidza Louina
2013-08-12 21:05 ` [PATCH 7/9] staging: dgnc: fixes warning: initialization from incompatible pointer type Lidza Louina
2013-08-13  7:32   ` Dan Carpenter
2013-08-13 13:26     ` Lidza Louina
2013-08-12 21:05 ` Lidza Louina [this message]
2013-08-12 21:05 ` [PATCH 9/9] staging: dgnc: fixes warning: unused variable ‘buf’ Lidza Louina
2013-08-13  7:35   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376341513-20578-9-git-send-email-lidza.louina@gmail.com \
    --to=lidza.louina@gmail.com \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=markh@compro.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.