Преглед на файлове

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 години
родител
ревизия
bcada72bd7
променени са 1 файла, в които са добавени 9 реда и са изтрити 0 реда
  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: