[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [rtl] Is there a way to flush a FIFO ?



Gang,

Gabor Kiss Recently suggested:

> >  Is there any way to flush a fifo ?
> 
> char buf;
> rtl_irqstate_t flags;
> 
> rtl_no_interrupts(flags);
> while (rtf_get(FIFO_NUMBER, &buf, 1)>0);
> rtl_restore_interrupts(flags);

	May I humbly suggest doing it with as few calls as possible when
interrupts are disabled?  I would suggest something more like:

	static char buf[1024];
	rtl_irqstate_t flags;
	rtl_no_interrupts(flags);
	while	(rtf_get(FIFOR_NUMBER, &buf, 1000) == 1000) {
		;
	}
	rtl_restore_interrupts(flags);

	Alternatively, a quick browse of rtl_fifo.c in the kernel source
shows an rtf_flush function which takes the FIFO number as an argument and
handles protecting from interrupts.  I would recommend using that function
unless one of the FSM guys complains about non-published APIs, etc.

Steve

P.S. For the FSM guys, why hasn't rtf_flush been published?  Too much coding
to keep up with documentation or not-available on purpose?  How about
rtf_isempty?  These look useful!