diff --git a/drivers/dahdi/trunkdev/frame_fifo.c b/drivers/dahdi/trunkdev/frame_fifo.c index 19b6dba..3b7732f 100644 --- a/drivers/dahdi/trunkdev/frame_fifo.c +++ b/drivers/dahdi/trunkdev/frame_fifo.c @@ -53,6 +53,15 @@ void frame_fifo_init(struct frame_fifo *fifo, unsigned int threshold, spin_lock_init(&fifo->lock); } +/*! Flush (drop) the entire content of the FIFO */ +void frame_fifo_flush(struct frame_fifo *fifo) +{ + unsigned long flags; + spin_lock_irqsave(&fifo->lock, flags); + fifo->next_out = fifo->next_in; + spin_unlock_irqrestore(&fifo->lock, flags); +} + #define FIFO_BUF_END(f) ((f)->buf + sizeof((f)->buf)) /*! put one received frames into the FIFO. diff --git a/drivers/dahdi/trunkdev/frame_fifo.h b/drivers/dahdi/trunkdev/frame_fifo.h index af02811..b07cddc 100644 --- a/drivers/dahdi/trunkdev/frame_fifo.h +++ b/drivers/dahdi/trunkdev/frame_fifo.h @@ -20,6 +20,8 @@ void frame_fifo_init(struct frame_fifo *fifo, unsigned int threshold, void (*threshold_cb)(struct frame_fifo *fifo, unsigned int frames, void *priv), void *priv); +void frame_fifo_flush(struct frame_fifo *fifo); + /* number of frames currently available in FIFO */ static inline unsigned int __frame_fifo_frames(struct frame_fifo *fifo) { diff --git a/drivers/dahdi/trunkdev/trunkdev.c b/drivers/dahdi/trunkdev/trunkdev.c index 5569888..1163849 100644 --- a/drivers/dahdi/trunkdev/trunkdev.c +++ b/drivers/dahdi/trunkdev/trunkdev.c @@ -456,6 +456,9 @@ static long dahdi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned l span->alarms &= ~(ALL_RY_ALARMS|DAHDI_ALARM_LOS); dahdi_alarm_notify(span); spin_unlock_irqrestore(&span->lock, flags); + /* FIFO should be full at this point, let's flush it as now we actually + * have a receiver */ + frame_fifo_flush(&td->to_trunk); open.spanno = span->spanno; if (copy_to_user((__user void *) data, &open, sizeof(open)))