kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: elezegarcia@yahoo.com.ar (Ezequiel García)
To: kernelnewbies@lists.kernelnewbies.org
Subject: revisiting scullpipe implementation
Date: Sun, 22 May 2011 17:38:44 -0700 (PDT)	[thread overview]
Message-ID: <128933.53245.qm@web39308.mail.mud.yahoo.com> (raw)

Hi everybody,

I don't know if anyone cares about this subject. But here it goes anyway. 
I've been reading through the excellent Linux Device Driver book (third ed.) for the past months. 
I have decided to give it a try to the drivers samples, starting by scull. After some minor updates (mostly related to new mutex interface), I started playing with scull and scullpipe. 

The thing is the scullpipe implementation makes buffer initialization, and sets read and write pointer to zero at device open. Acordingly, it releases the buffer at device close.
This implementation makes this possible:

(first, on one terminal) $ cat /dev/scullpipe0

(second, another) $ dd if=/dev/zero of=/dev/scullpipe0 bs=512 count=1

But not the other way round:

(first, write) $ dd if=/dev/zero of=/dev/scullpipe0 bs=5000 count=5

(then, read) $ cat /dev/scullpipe0

Because when the reader (cat) opens the device the read/write pointers are made equal and buffer looks empty. (Besides, the buffer resets itself on device release; so it does not persist when nobody is using it.)

Questions: Did I misunderstand the driver's idea and this behavior is not buggy, or ... is the code just aimed at learning so it does not matter?

Actually it is pretty easy (and good training for starters) to change it. I had to move some code from device open to device init and from device release to device clean_up.

Maybe someone is reading the book and might be interested.

Greetings,
Ezequiel. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110522/b354d766/attachment.html 

                 reply	other threads:[~2011-05-23  0:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=128933.53245.qm@web39308.mail.mud.yahoo.com \
    --to=elezegarcia@yahoo.com.ar \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /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 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).