Pārlūkot izejas kodu

ptp: cleanup timestamp event queue when extts is disabled

When extts is disabled, the queue that holds the existing reported
timestamps should be cleaned up in order to prevent user applications from
using old timestamps when extts is re-enabled.

Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
WingMan Kwok 6 gadi atpakaļ
vecāks
revīzija
bcada72bd7
1 mainītis faili ar 9 papildinājumiem un 0 dzēšanām
  1. 9 0
      drivers/ptp/ptp_chardev.c

+ 9 - 0
drivers/ptp/ptp_chardev.c

@@ -162,6 +162,15 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
 		req.type = PTP_CLK_REQ_EXTTS;
 		enable = req.extts.flags & PTP_ENABLE_FEATURE ? 1 : 0;
 		err = ops->enable(ops, &req, enable);
+		if (!enable && !err && queue_cnt(&ptp->tsevq)) {
+			struct timestamp_event_queue *queue = &ptp->tsevq;
+			unsigned long flags;
+
+			spin_lock_irqsave(&queue->lock, flags);
+			queue->head = 0;
+			queue->tail = 0;
+			spin_unlock_irqrestore(&queue->lock, flags);
+		}
 		break;
 
 	case PTP_PEROUT_REQUEST: