#if 1 /* * Copyright (c) 2014-2018, 2020 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ /* * This file was originally distributed by Qualcomm Atheros, Inc. * under proprietary terms before Copyright ownership was assigned * to the Linux Foundation. */ /** * DOC: qdf_hrtimer * This file provides OS dependent timer API's. */ #include #include #include #include #include #include void __qdf_hrtimer_start(__qdf_hrtimer_data_t *timer, ktime_t interval, enum qdf_hrtimer_mode mode) { if (timer->ctx == QDF_CONTEXT_HARDWARE) hrtimer_start(&timer->u.hrtimer, interval, mode); else if (timer->ctx == QDF_CONTEXT_TASKLET) tasklet_hrtimer_start(&timer->u.tasklet_hrtimer, interval, mode); } EXPORT_SYMBOL(__qdf_hrtimer_start); void __qdf_hrtimer_cancel(__qdf_hrtimer_data_t *timer) { if (timer->ctx == QDF_CONTEXT_HARDWARE) hrtimer_cancel(&timer->u.hrtimer); else if (timer->ctx == QDF_CONTEXT_TASKLET) hrtimer_cancel(&timer->u.tasklet_hrtimer.timer); } EXPORT_SYMBOL(__qdf_hrtimer_cancel); void __qdf_hrtimer_init(__qdf_hrtimer_data_t *timer, void *cback, enum qdf_clock_id clock, enum qdf_hrtimer_mode mode, enum qdf_context_mode ctx) { struct hrtimer *hrtimer = &timer->u.hrtimer; struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer; timer->ctx = ctx; if (timer->ctx == QDF_CONTEXT_HARDWARE) { hrtimer_init(hrtimer, clock, mode); hrtimer->function = cback; } else if (timer->ctx == QDF_CONTEXT_TASKLET) { tasklet_hrtimer_init(tasklet_hrtimer, cback, clock, mode); } } EXPORT_SYMBOL(__qdf_hrtimer_init); void __qdf_hrtimer_kill(__qdf_hrtimer_data_t *timer) { if (timer->ctx == QDF_CONTEXT_HARDWARE) hrtimer_cancel(&timer->u.hrtimer); else if (timer->ctx == QDF_CONTEXT_TASKLET) tasklet_hrtimer_cancel(&timer->u.tasklet_hrtimer); } EXPORT_SYMBOL(__qdf_hrtimer_kill); bool __qdf_hrtimer_active(__qdf_hrtimer_data_t *timer) { struct hrtimer *hrtimer = &timer->u.hrtimer; struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer; if (timer->ctx == QDF_CONTEXT_HARDWARE) return hrtimer_active(hrtimer); else return hrtimer_active(&tasklet_hrtimer->timer); } EXPORT_SYMBOL(__qdf_hrtimer_active); uint64_t __qdf_hrtimer_forward(__qdf_hrtimer_data_t *timer, ktime_t now, ktime_t interval) { struct hrtimer *hrtimer = &timer->u.hrtimer; struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer; if (timer->ctx == QDF_CONTEXT_HARDWARE) return hrtimer_forward(hrtimer, now, interval); else return hrtimer_forward(&tasklet_hrtimer->timer, now, interval); } EXPORT_SYMBOL(__qdf_hrtimer_forward); ktime_t __qdf_hrtimer_get_remaining(__qdf_hrtimer_data_t *timer) { struct hrtimer *hrtimer = &timer->u.hrtimer; struct tasklet_hrtimer *tasklet_hrtimer = &timer->u.tasklet_hrtimer; if (timer->ctx == QDF_CONTEXT_HARDWARE) return hrtimer_get_remaining(hrtimer); else return hrtimer_get_remaining(&tasklet_hrtimer->timer); } EXPORT_SYMBOL(__qdf_hrtimer_get_remaining); #endif