浏览代码

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: