Skip to content

Commit 544fed4

Browse files
vladimirolteandavem330
authored andcommitted
ptp: introduce ptp_cancel_worker_sync
In order to effectively use the PTP kernel thread for tasks such as timestamping packets, allow the user control over stopping it, which is needed e.g. when the timestamping queues must be drained. Signed-off-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent db99d51 commit 544fed4

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎drivers/ptp/ptp_clock.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay)
371371
}
372372
EXPORT_SYMBOL(ptp_schedule_worker);
373373

374+
void ptp_cancel_worker_sync(struct ptp_clock *ptp)
375+
{
376+
kthread_cancel_delayed_work_sync(&ptp->aux_work);
377+
}
378+
EXPORT_SYMBOL(ptp_cancel_worker_sync);
379+
374380
/* module operations */
375381

376382
static void __exit ptp_exit(void)

‎include/linux/ptp_clock_kernel.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ int ptp_find_pin(struct ptp_clock *ptp,
243243

244244
int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay);
245245

246+
/**
247+
* ptp_cancel_worker_sync() - cancel ptp auxiliary clock
248+
*
249+
* @ptp: The clock obtained from ptp_clock_register().
250+
*/
251+
void ptp_cancel_worker_sync(struct ptp_clock *ptp);
252+
246253
#else
247254
static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
248255
struct device *parent)
@@ -260,6 +267,8 @@ static inline int ptp_find_pin(struct ptp_clock *ptp,
260267
static inline int ptp_schedule_worker(struct ptp_clock *ptp,
261268
unsigned long delay)
262269
{ return -EOPNOTSUPP; }
270+
static inline void ptp_cancel_worker_sync(struct ptp_clock *ptp)
271+
{ }
263272

264273
#endif
265274

0 commit comments

Comments
 (0)