linuxkpi: Define hrtimer_try_to_cancel()
It is the same as callout_stop(9) but the return values are different. Reviewed by: hselasky Approved by: hselasky Differential Revision: https://reviews.freebsd.org/D38081
This commit is contained in:
parent
424f1296bd
commit
bb651c77f5
@ -53,6 +53,7 @@ struct hrtimer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define hrtimer_active(hrtimer) linux_hrtimer_active(hrtimer)
|
#define hrtimer_active(hrtimer) linux_hrtimer_active(hrtimer)
|
||||||
|
#define hrtimer_try_to_cancel(hrtimer) linux_hrtimer_try_to_cancel(hrtimer)
|
||||||
#define hrtimer_cancel(hrtimer) linux_hrtimer_cancel(hrtimer)
|
#define hrtimer_cancel(hrtimer) linux_hrtimer_cancel(hrtimer)
|
||||||
|
|
||||||
#define hrtimer_init(hrtimer, clock, mode) do { \
|
#define hrtimer_init(hrtimer, clock, mode) do { \
|
||||||
@ -79,6 +80,7 @@ struct hrtimer {
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
bool linux_hrtimer_active(struct hrtimer *);
|
bool linux_hrtimer_active(struct hrtimer *);
|
||||||
|
int linux_hrtimer_try_to_cancel(struct hrtimer *);
|
||||||
int linux_hrtimer_cancel(struct hrtimer *);
|
int linux_hrtimer_cancel(struct hrtimer *);
|
||||||
void linux_hrtimer_init(struct hrtimer *);
|
void linux_hrtimer_init(struct hrtimer *);
|
||||||
void linux_hrtimer_set_expires(struct hrtimer *, ktime_t);
|
void linux_hrtimer_set_expires(struct hrtimer *, ktime_t);
|
||||||
|
@ -65,6 +65,28 @@ linux_hrtimer_active(struct hrtimer *hrtimer)
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to cancel active hrtimer.
|
||||||
|
* Return 1 if timer was active and cancellation succeeded, 0 if timer was
|
||||||
|
* inactive, or -1 if the timer is being serviced and can't be cancelled.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
linux_hrtimer_try_to_cancel(struct hrtimer *hrtimer)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
mtx_lock(&hrtimer->mtx);
|
||||||
|
ret = callout_stop(&hrtimer->callout);
|
||||||
|
mtx_unlock(&hrtimer->mtx);
|
||||||
|
if (ret > 0) {
|
||||||
|
return (1);
|
||||||
|
} else if (ret < 0) {
|
||||||
|
return (0);
|
||||||
|
} else {
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cancel active hrtimer.
|
* Cancel active hrtimer.
|
||||||
* Return 1 if timer was active and cancellation succeeded, or 0 otherwise.
|
* Return 1 if timer was active and cancellation succeeded, or 0 otherwise.
|
||||||
|
Loading…
Reference in New Issue
Block a user