소스 검색

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: