linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] tty: metag_da: fix flipping after tty changes
@ 2013-02-05 14:40 James Hogan
  2013-02-05 14:40 ` [PATCH 1/2] tty: metag_da: update flip functions to use tty_port James Hogan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: James Hogan @ 2013-02-05 14:40 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, James Hogan

The first patch fixes up tty/metag_da after Jiri's changes, "TTY: switch
tty_flip_buffer_push" and "TTY: convert more flipping functions",
switched tty_flip_buffer_push() and tty_prepare_flip_string() to take
tty_port rather than a tty_struct.

The second just refactors slightly as a result of it.

How is this sort of thing usually handled? I suppose either I squash it
into the original driver and base it on tty-next, move it into tty-next,
or just fix it up afterwards?

James Hogan (2):
  tty: metag_da: update flip functions to use tty_port
  tty: metag_da: avoid getting tty kref in dashtty_timer()

 drivers/tty/metag_da.c |   36 +++++++++++++++++-------------------
 1 files changed, 17 insertions(+), 19 deletions(-)

-- 
1.7.7.6



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] tty: metag_da: update flip functions to use tty_port
  2013-02-05 14:40 [PATCH 0/2] tty: metag_da: fix flipping after tty changes James Hogan
@ 2013-02-05 14:40 ` James Hogan
  2013-02-05 14:40 ` [PATCH 2/2] tty: metag_da: avoid getting tty kref in dashtty_timer() James Hogan
  2013-02-05 15:15 ` [PATCH 0/2] tty: metag_da: fix flipping after tty changes Jiri Slaby
  2 siblings, 0 replies; 5+ messages in thread
From: James Hogan @ 2013-02-05 14:40 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, James Hogan

Commit "TTY: switch tty_flip_buffer_push" and "TTY: convert more
flipping functions" switched tty_flip_buffer_push() and
tty_prepare_flip_string() to take tty_port rather than a tty_struct.

Convert the metag_da tty driver similarly.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/tty/metag_da.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/metag_da.c b/drivers/tty/metag_da.c
index 6a0b2e6..fc2a36b 100644
--- a/drivers/tty/metag_da.c
+++ b/drivers/tty/metag_da.c
@@ -163,13 +163,14 @@ static int fetch_data(struct tty_struct *tty)
 			int space;
 			unsigned char *cbuf;
 
-			space = tty_prepare_flip_string(tty, &cbuf, received);
+			space = tty_prepare_flip_string(&dport->port, &cbuf,
+							received);
 
 			if (space <= 0)
 				goto unlock;
 
 			memcpy(cbuf, dport->rx_buf, space);
-			tty_flip_buffer_push(tty);
+			tty_flip_buffer_push(&dport->port);
 		}
 	}
 unlock:
-- 
1.7.7.6



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] tty: metag_da: avoid getting tty kref in dashtty_timer()
  2013-02-05 14:40 [PATCH 0/2] tty: metag_da: fix flipping after tty changes James Hogan
  2013-02-05 14:40 ` [PATCH 1/2] tty: metag_da: update flip functions to use tty_port James Hogan
@ 2013-02-05 14:40 ` James Hogan
  2013-02-05 15:15 ` [PATCH 0/2] tty: metag_da: fix flipping after tty changes Jiri Slaby
  2 siblings, 0 replies; 5+ messages in thread
From: James Hogan @ 2013-02-05 14:40 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: linux-kernel, James Hogan

Getting the tty kref in dashtty_timer() is no longer necessary since it
isn't needed in fetch_data() any longer (due to changes which make the
tty flip functions refer to tty_ports instead of tty_structs), so just
pass around a channel number instead.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/tty/metag_da.c |   31 ++++++++++++++-----------------
 1 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/tty/metag_da.c b/drivers/tty/metag_da.c
index fc2a36b..0e88862 100644
--- a/drivers/tty/metag_da.c
+++ b/drivers/tty/metag_da.c
@@ -147,9 +147,8 @@ static int chancall(int in_bios_function, int in_channel,
 /*
  * Attempts to fetch count bytes from channel and returns actual count.
  */
-static int fetch_data(struct tty_struct *tty)
+static int fetch_data(unsigned int channel)
 {
-	unsigned int channel = tty->index;
 	struct dashtty_port *dport = &dashtty_ports[channel];
 	int received = 0;
 
@@ -180,31 +179,31 @@ unlock:
 }
 
 /**
- * find_channel_to_poll() - Returns kref to the next channel tty to poll.
- * Returns:	The TTY of the next channel to poll, or NULL if no TTY needs
- *		polling. Release with tty_kref_put().
+ * find_channel_to_poll() - Returns number of the next channel to poll.
+ * Returns:	The number of the next channel to poll, or -1 if none need
+ *		polling.
  */
-static struct tty_struct *find_channel_to_poll(void)
+static int find_channel_to_poll(void)
 {
 	static int last_polled_channel;
 	int last = last_polled_channel;
 	int chan;
-	struct tty_struct *tty = NULL;
+	struct dashtty_port *dport;
 
 	for (chan = last + 1; ; ++chan) {
 		if (chan >= NUM_TTY_CHANNELS)
 			chan = 0;
 
-		tty = tty_port_tty_get(&dashtty_ports[chan].port);
-		if (tty) {
+		dport = &dashtty_ports[chan];
+		if (dport->rx_buf) {
 			last_polled_channel = chan;
-			return tty;
+			return chan;
 		}
 
 		if (chan == last)
 			break;
 	}
-	return tty;
+	return -1;
 }
 
 /**
@@ -302,19 +301,17 @@ static int put_data(void *arg)
  */
 static void dashtty_timer(unsigned long ignored)
 {
-	struct tty_struct *tty;
+	int channel;
 
 	/* If there are no ports open do nothing and don't poll again. */
 	if (!atomic_read(&num_channels_need_poll))
 		return;
 
-	tty = find_channel_to_poll();
+	channel = find_channel_to_poll();
 
 	/* Did we find a channel to poll? */
-	if (tty) {
-		fetch_data(tty);
-		tty_kref_put(tty);
-	}
+	if (channel >= 0)
+		fetch_data(channel);
 
 	mod_timer_pinned(&poll_timer, jiffies + DA_TTY_POLL);
 }
-- 
1.7.7.6



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] tty: metag_da: fix flipping after tty changes
  2013-02-05 14:40 [PATCH 0/2] tty: metag_da: fix flipping after tty changes James Hogan
  2013-02-05 14:40 ` [PATCH 1/2] tty: metag_da: update flip functions to use tty_port James Hogan
  2013-02-05 14:40 ` [PATCH 2/2] tty: metag_da: avoid getting tty kref in dashtty_timer() James Hogan
@ 2013-02-05 15:15 ` Jiri Slaby
  2013-02-05 15:23   ` James Hogan
  2 siblings, 1 reply; 5+ messages in thread
From: Jiri Slaby @ 2013-02-05 15:15 UTC (permalink / raw)
  To: James Hogan, Greg Kroah-Hartman; +Cc: linux-kernel

On 02/05/2013 03:40 PM, James Hogan wrote:
> The first patch fixes up tty/metag_da after Jiri's changes, "TTY: switch
> tty_flip_buffer_push" and "TTY: convert more flipping functions",
> switched tty_flip_buffer_push() and tty_prepare_flip_string() to take
> tty_port rather than a tty_struct.
> 
> The second just refactors slightly as a result of it.
> 
> How is this sort of thing usually handled? I suppose either I squash it
> into the original driver and base it on tty-next, move it into tty-next,
> or just fix it up afterwards?
> 
> James Hogan (2):
>   tty: metag_da: update flip functions to use tty_port
>   tty: metag_da: avoid getting tty kref in dashtty_timer()

They both look good. You can add my:
Acked-by: Jiri Slaby <jslaby@suse.cz>
if you want.

thanks,
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] tty: metag_da: fix flipping after tty changes
  2013-02-05 15:15 ` [PATCH 0/2] tty: metag_da: fix flipping after tty changes Jiri Slaby
@ 2013-02-05 15:23   ` James Hogan
  0 siblings, 0 replies; 5+ messages in thread
From: James Hogan @ 2013-02-05 15:23 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Greg Kroah-Hartman, linux-kernel

On 05/02/13 15:15, Jiri Slaby wrote:
> On 02/05/2013 03:40 PM, James Hogan wrote:
>> The first patch fixes up tty/metag_da after Jiri's changes, "TTY: switch
>> tty_flip_buffer_push" and "TTY: convert more flipping functions",
>> switched tty_flip_buffer_push() and tty_prepare_flip_string() to take
>> tty_port rather than a tty_struct.
>>
>> The second just refactors slightly as a result of it.
>>
>> How is this sort of thing usually handled? I suppose either I squash it
>> into the original driver and base it on tty-next, move it into tty-next,
>> or just fix it up afterwards?
>>
>> James Hogan (2):
>>   tty: metag_da: update flip functions to use tty_port
>>   tty: metag_da: avoid getting tty kref in dashtty_timer()
> 
> They both look good. You can add my:
> Acked-by: Jiri Slaby <jslaby@suse.cz>
> if you want.

Thanks Jiri

Cheers
James


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-05 15:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-05 14:40 [PATCH 0/2] tty: metag_da: fix flipping after tty changes James Hogan
2013-02-05 14:40 ` [PATCH 1/2] tty: metag_da: update flip functions to use tty_port James Hogan
2013-02-05 14:40 ` [PATCH 2/2] tty: metag_da: avoid getting tty kref in dashtty_timer() James Hogan
2013-02-05 15:15 ` [PATCH 0/2] tty: metag_da: fix flipping after tty changes Jiri Slaby
2013-02-05 15:23   ` James Hogan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).