* tiny tty driver sample
@ 2007-03-07 16:27 Jon Ringle
2007-03-07 16:32 ` Jiri Kosina
2007-03-07 16:50 ` Jiri Slaby
0 siblings, 2 replies; 6+ messages in thread
From: Jon Ringle @ 2007-03-07 16:27 UTC (permalink / raw)
To: linux-kernel
Hello,
I'm trying to write a tty driver and I'm using
http://lwn.net/images/pdf/LDD3/ch18.pdf as a guide. The sample tiny tty
driver includes the following code:
for (i = 0; i < data_size; ++i) {
if (tty->flip.count >= TTY_FLIPBUF_SIZE)
tty_flip_buffer_push(tty);
tty_insert_flip_char(tty, data[i], TTY_NORMAL);
}
tty_flip_buffer_push(tty);
This doesn't compile against Linux 2.6.16 kernel I'm using, because
tty->flip.count doesn't exist anymore.
How should this sample be re-coded?
Thanks,
Jon
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: tiny tty driver sample
2007-03-07 16:27 tiny tty driver sample Jon Ringle
@ 2007-03-07 16:32 ` Jiri Kosina
2007-03-07 18:23 ` Alan Cox
2007-03-07 16:50 ` Jiri Slaby
1 sibling, 1 reply; 6+ messages in thread
From: Jiri Kosina @ 2007-03-07 16:32 UTC (permalink / raw)
To: Jon Ringle; +Cc: linux-kernel
On Wed, 7 Mar 2007, Jon Ringle wrote:
> I'm trying to write a tty driver and I'm using
> http://lwn.net/images/pdf/LDD3/ch18.pdf as a guide. The sample tiny tty
> driver includes the following code:
> for (i = 0; i < data_size; ++i) {
> if (tty->flip.count >= TTY_FLIPBUF_SIZE)
> tty_flip_buffer_push(tty);
> tty_insert_flip_char(tty, data[i], TTY_NORMAL);
> }
> tty_flip_buffer_push(tty);
> This doesn't compile against Linux 2.6.16 kernel I'm using, because
> tty->flip.count doesn't exist anymore. How should this sample be
> re-coded?
I guess something like
tty_buffer_request_room(tty, data_size);
for (i = 0; i < data_size; ++i)
work += tty_insert_flip_char(tty, data[i], TTY_NORMAL);
if (work)
tty_flip_buffer_push(tty);
will do.
--
Jiri Kosina
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: tiny tty driver sample
2007-03-07 16:32 ` Jiri Kosina
@ 2007-03-07 18:23 ` Alan Cox
2007-03-07 17:51 ` H. Peter Anvin
0 siblings, 1 reply; 6+ messages in thread
From: Alan Cox @ 2007-03-07 18:23 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Jon Ringle, linux-kernel
> I guess something like
>
> tty_buffer_request_room(tty, data_size);
> for (i = 0; i < data_size; ++i)
> work += tty_insert_flip_char(tty, data[i], TTY_NORMAL);
> if (work)
> tty_flip_buffer_push(tty);
Unless data_size can be very large and high speed then you can replace the
lot with
if (tty_insert_flip_string(tty, data, data_size))
tty_flip_buffer_push(tty);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: tiny tty driver sample
2007-03-07 18:23 ` Alan Cox
@ 2007-03-07 17:51 ` H. Peter Anvin
2007-03-08 0:40 ` Alan Cox
0 siblings, 1 reply; 6+ messages in thread
From: H. Peter Anvin @ 2007-03-07 17:51 UTC (permalink / raw)
To: Alan Cox; +Cc: Jiri Kosina, Jon Ringle, linux-kernel
Alan Cox wrote:
>> I guess something like
>>
>> tty_buffer_request_room(tty, data_size);
>> for (i = 0; i < data_size; ++i)
>> work += tty_insert_flip_char(tty, data[i], TTY_NORMAL);
>> if (work)
>> tty_flip_buffer_push(tty);
>
>
> Unless data_size can be very large and high speed then you can replace the
> lot with
>
> if (tty_insert_flip_string(tty, data, data_size))
> tty_flip_buffer_push(tty);
>
What does "very large and high speed" mean in this context?
-hpa
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: tiny tty driver sample
2007-03-07 17:51 ` H. Peter Anvin
@ 2007-03-08 0:40 ` Alan Cox
0 siblings, 0 replies; 6+ messages in thread
From: Alan Cox @ 2007-03-08 0:40 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Jiri Kosina, Jon Ringle, linux-kernel
> > Unless data_size can be very large and high speed then you can replace the
> > lot with
> >
> > if (tty_insert_flip_string(tty, data, data_size))
> > tty_flip_buffer_push(tty);
> >
>
> What does "very large and high speed" mean in this context?
The default behaviour is to generate buffers based upon perceived need
and then cycle them, so you tend to get chunks of 512 bytes or so. The
logic is abstracted into tty_buffer_find() so can easily be changed.
Some hardware at high speeds with big FIFOs (or virtualised interfaces)
produces big chunks of data in blocks with the size known at read time (eg
that with large fifos and 100 polls/sec) - for those you can avoid
generating a series of allocations or buffers by using the request_room
interface to hint the size of the buffer you will actually need.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: tiny tty driver sample
2007-03-07 16:27 tiny tty driver sample Jon Ringle
2007-03-07 16:32 ` Jiri Kosina
@ 2007-03-07 16:50 ` Jiri Slaby
1 sibling, 0 replies; 6+ messages in thread
From: Jiri Slaby @ 2007-03-07 16:50 UTC (permalink / raw)
To: Jon Ringle; +Cc: linux-kernel
Jon Ringle napsal(a):
> Hello,
>
> I'm trying to write a tty driver and I'm using
> http://lwn.net/images/pdf/LDD3/ch18.pdf as a guide. The sample tiny tty
> driver includes the following code:
>
> for (i = 0; i < data_size; ++i) {
> if (tty->flip.count >= TTY_FLIPBUF_SIZE)
> tty_flip_buffer_push(tty);
> tty_insert_flip_char(tty, data[i], TTY_NORMAL);
> }
> tty_flip_buffer_push(tty);
>
> This doesn't compile against Linux 2.6.16 kernel I'm using, because
> tty->flip.count doesn't exist anymore.
> How should this sample be re-coded?
I think this way:
http://lkml.org/lkml/2007/2/17/65
regards,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-07 23:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-07 16:27 tiny tty driver sample Jon Ringle
2007-03-07 16:32 ` Jiri Kosina
2007-03-07 18:23 ` Alan Cox
2007-03-07 17:51 ` H. Peter Anvin
2007-03-08 0:40 ` Alan Cox
2007-03-07 16:50 ` Jiri Slaby
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox