From: "Ron Bianco" <ronb@junction.net>
To: "Ian Abbott" <abbotti@mev.co.uk>
Cc: <linuxppc-embedded@lists.linuxppc.org>
Subject: RE: which errno should I use
Date: Wed, 31 Jan 2001 15:45:20 -0800 [thread overview]
Message-ID: <000501c08bdf$df460610$4d012ac7@warp-speed> (raw)
In-Reply-To: <00933BFA237CD2119B3400409543582704A2AE@MEV01>
Hi Ian,
In your driver's read() fileop implementation, assuming you're using a non-blocking
technique, if the count parameter is not 1024 just return 0 for num byes written to
user's buffer. The error codes are actually used as -EINVAL for example, any
positive return value or 0 indicates the bytes actually processed. Also if you're
intending the user program to select() your device then you need to implement the
poll() fileop.
I just finished writing a non-blocking char device driver, so can offer some tips if
need be.
Cheers, Ron
Ron Bianco
Computer Systems Technologist
Level Control Systems
email: ronb@junction.net
phone: 250-549-2558 Ext 8
web: www.lcsaudio.com
> -----Original Message-----
> From: owner-linuxppc-embedded@lists.linuxppc.org
> [mailto:owner-linuxppc-embedded@lists.linuxppc.org]On Behalf Of Ian
> Abbott
> Sent: Wednesday, January 31, 2001 10:48 AM
> To: Embedded Linux list
> Subject: RE: which errno should I use
>
>
>
> On Tuesday, January 30, 2001 4:53 PM, Ralph Blach
> <rcblach@raleigh.ibm.com> wrote:
>
> > I am writing a character device driver. I want this device driver to
> > return an error if the user request less than say 1024 byte of data.
> > What errno should I use? Is it legal to return an error if not enouth
> > bytes are requested?
>
> I have a similar driver that wants exactly one long's worth of data to
> be read. If the supplied buffer is smaller than a long, I return 0,
> otherwise I return sizeof(long) (assuming their are no other errors).
> Admittedly this does not let the user level distinguish "buffer too
> small" from "no data", but I let the programmer at the user level deal
> with that! Just mention it in the documentation for your driver, if
> there is any.
>
> Wolfgang Denk suggested EINVAL. I didn't use that as the man page for
> read(2) says that means "fd is attached to an object which is unsuitable
> for reading." There's no harm in overloading this meaning though. Just
> document what your driver does.
>
>
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
next prev parent reply other threads:[~2001-01-31 23:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-31 18:48 which errno should I use Ian Abbott
2001-01-31 23:45 ` Ron Bianco [this message]
2001-02-01 2:15 ` add-symbole-file doesn't work properly in powerpc-linux-gdb Kwanksuk Kim
2001-02-01 3:08 ` Kwanksuk Kim
-- strict thread matches above, loose matches on Subject: below --
2001-01-30 16:52 which errno should I use Ralph Blach
2001-01-30 17:19 ` Wolfgang Denk
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='000501c08bdf$df460610$4d012ac7@warp-speed' \
--to=ronb@junction.net \
--cc=abbotti@mev.co.uk \
--cc=linuxppc-embedded@lists.linuxppc.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).