This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: [Fwd: I/O errors - confusion]
Gary Thomas <gary at mlbassoc dot com> writes:
> On Tue, 2003-03-18 at 11:44, Nick Garnett wrote:
> > Gary Thomas <gary at mlbassoc dot com> writes:
> >
> > >
> > > I agree - either there is data or not and the return code should
> > > be very clear: EAGAIN means there is none, anything else means
> > > there was. I think that the code in serial.c you quote should
> > > return no error when there is data.
> >
> > That is exactly my interpretation of what should happen. The only real
> > question is whether we should make that change, or just fix it in the
> > fileio code. I would vote for the former, since it results in code
> > being removed, but we have to be sure we are not breaking anything
> > else by doing it.
>
> I think that this patch fixes it [correctly]:
>
> Index: io/serial/current/src/common/serial.c
> ===================================================================
> RCS file: /misc/cvsfiles/ecos/packages/io/serial/current/src/common/serial.c,v
> retrieving revision 1.17
> diff -u -5 -p -r1.17 serial.c
> --- io/serial/current/src/common/serial.c 23 May 2002 23:06:27 -0000 1.17
> +++ io/serial/current/src/common/serial.c 18 Mar 2003 23:37:03 -0000
> @@ -341,11 +341,11 @@ serial_write(cyg_io_handle_t handle, con
> #ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
> // Optionally return if configured for non-blocking mode.
> if (!cbuf->blocking) {
> *len -= size; // number of characters actually sent
> cbuf->waiting = false;
> - res = -EAGAIN;
> + res = size == 0 ? -EAGAIN : ENOERROR;
> break;
> }
> #endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
> cbuf->pending += size; // Have this much more to send [eventually]
> if( !cyg_drv_cond_wait(&cbuf->wait) )
> @@ -438,11 +438,11 @@ serial_read(cyg_io_handle_t handle, void
> size++;
> } else {
> #ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
> if (!cbuf->blocking) {
> *len = size; // characters actually read
> - res = -EAGAIN;
> + res = size == 0 ? -EAGAIN : ENOERROR;
> break;
> }
> #endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING
> cbuf->waiting = true;
> #ifdef XX_CYGDBG_DIAG_BUF
>
> Comments?
Without actually trying it, that looks OK to me.
You should also be able to take the -EAGAIN tests out of dev_fo_read()
and dev_fo_write().
--
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com/ The eCos and RedBoot experts