Skip to content

Commit

Permalink
ptp: introduce ptp_cancel_worker_sync
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vladimir Oltean authored and David S. Miller committed Dec 31, 2019
1 parent db99d51 commit 544fed4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/ptp/ptp_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay)
}
EXPORT_SYMBOL(ptp_schedule_worker);

void ptp_cancel_worker_sync(struct ptp_clock *ptp)
{
kthread_cancel_delayed_work_sync(&ptp->aux_work);
}
EXPORT_SYMBOL(ptp_cancel_worker_sync);

/* module operations */

static void __exit ptp_exit(void)
Expand Down
9 changes: 9 additions & 0 deletions include/linux/ptp_clock_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ int ptp_find_pin(struct ptp_clock *ptp,

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

/**
* ptp_cancel_worker_sync() - cancel ptp auxiliary clock
*
* @ptp: The clock obtained from ptp_clock_register().
*/
void ptp_cancel_worker_sync(struct ptp_clock *ptp);

#else
static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
struct device *parent)
Expand All @@ -260,6 +267,8 @@ static inline int ptp_find_pin(struct ptp_clock *ptp,
static inline int ptp_schedule_worker(struct ptp_clock *ptp,
unsigned long delay)
{ return -EOPNOTSUPP; }
static inline void ptp_cancel_worker_sync(struct ptp_clock *ptp)
{ }

#endif

Expand Down

0 comments on commit 544fed4

Please sign in to comment.