[flashrom] [PATCH] Move OS-dependent serial code from buspirate_spi.c to serial.c

Michael Karcher flashrom at mkarcher.dialup.fu-berlin.de
Wed Jan 6 16:50:45 CET 2010


Am Mittwoch, den 06.01.2010, 16:27 +0100 schrieb Michael Karcher:
> Am Mittwoch, den 06.01.2010, 16:13 +0100 schrieb Carl-Daniel Hailfinger:
> > +int serialport_discard_read(void)
> > +{
> > +	int flags;
> > +
> > +	printf_debug("%s\n", __func__);
> > +	flags = fcntl(sp_fd, F_GETFL);
> > +	flags |= O_NONBLOCK;
> > +	fcntl(sp_fd, F_SETFL, flags);
> > +	sp_flush_incoming();
> > +	flags &= ~O_NONBLOCK;
> > +	fcntl(sp_fd, F_SETFL, flags);
> > +
> > +	return 0;
> > +}
> 
> I know that this patch is just about moving code, so of course the code
> will go in this way, but is there any reason not to use
>   tcflush(sp_fd, TCIFLUSH);
> instead of this complicated function?
> 
> OK, I think I got it. tcflush is or was broken on Windows. See for
> example http://www.cygwin.com/ml/cygwin/2003-10/msg00797.html
> Maybe add a reference to cygwin as explanation?
Don't worry. They changed cygwin. See tcflush in
http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/fhandler_serial.cc?rev=1.73&cvsroot=src
It maps to a native PurgeComm which is just fine. Thanks to patrickg for
the hint to recheck current code.

So no need to not use tcflush here.

Regards,
  Michael Karcher





More information about the flashrom mailing list