Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 1 | From b6936450484b5aa9dd2438367a907af020341d1d Mon Sep 17 00:00:00 2001 |
| 2 | From: Madhurkiran Harikrishnan <madhurkiran.harikrishnan@xilinx.com> |
| 3 | Date: Thu, 6 Dec 2018 13:30:44 -0800 |
| 4 | Subject: [PATCH 3/3] linux: mali_*timer: Get rid of init_timer |
| 5 | |
| 6 | kernel 4.19 got rid of ancient init_timer. Hence, replace it with |
| 7 | timer_setup API. For more information refer kernel commit |
| 8 | 7eeb6b893bd28c68b6d664de1d3120e49b855cdb |
| 9 | |
| 10 | Signed-off-by: Madhurkiran Harikrishnan <madhurkiran.harikrishnan@xilinx.com> |
| 11 | Reviewed-by: Hyun Kwon <hyun.kwon@xilinx.com> |
| 12 | Upstream Status: Pending |
| 13 | --- |
| 14 | driver/src/devicedrv/mali/common/mali_control_timer.c | 6 ++++++ |
| 15 | driver/src/devicedrv/mali/common/mali_group.c | 6 ++++++ |
| 16 | driver/src/devicedrv/mali/common/mali_osk.h | 15 ++++++++++++++- |
| 17 | driver/src/devicedrv/mali/linux/mali_osk_timers.c | 15 ++++++++++++++- |
| 18 | 4 files changed, 40 insertions(+), 2 deletions(-) |
| 19 | |
| 20 | diff --git a/driver/src/devicedrv/mali/common/mali_control_timer.c b/driver/src/devicedrv/mali/common/mali_control_timer.c |
| 21 | index 1296ffe..d24b934 100644 |
| 22 | --- common/mali_control_timer.c |
| 23 | +++ b/common/mali_control_timer.c |
| 24 | @@ -65,11 +65,17 @@ _mali_osk_errcode_t mali_control_timer_init(void) |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) |
| 29 | + mali_control_timer = _mali_osk_timer_init(mali_control_timer_callback); |
| 30 | +#else |
| 31 | mali_control_timer = _mali_osk_timer_init(); |
| 32 | +#endif |
| 33 | if (NULL == mali_control_timer) { |
| 34 | return _MALI_OSK_ERR_FAULT; |
| 35 | } |
| 36 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) |
| 37 | _mali_osk_timer_setcallback(mali_control_timer, mali_control_timer_callback, NULL); |
| 38 | +#endif |
| 39 | |
| 40 | return _MALI_OSK_ERR_OK; |
| 41 | } |
| 42 | diff --git a/driver/src/devicedrv/mali/common/mali_group.c b/driver/src/devicedrv/mali/common/mali_group.c |
| 43 | index 5c7b3f4..1702e9a 100644 |
| 44 | --- common/mali_group.c |
| 45 | +++ b/common/mali_group.c |
| 46 | @@ -65,9 +65,15 @@ struct mali_group *mali_group_create(struct mali_l2_cache_core *core, |
| 47 | |
| 48 | group = _mali_osk_calloc(1, sizeof(struct mali_group)); |
| 49 | if (NULL != group) { |
| 50 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) |
| 51 | + group->timeout_timer = _mali_osk_timer_init(mali_group_timeout); |
| 52 | +#else |
| 53 | group->timeout_timer = _mali_osk_timer_init(); |
| 54 | +#endif |
| 55 | if (NULL != group->timeout_timer) { |
| 56 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) |
| 57 | _mali_osk_timer_setcallback(group->timeout_timer, mali_group_timeout, (void *)group); |
| 58 | +#endif |
| 59 | |
| 60 | group->l2_cache_core[0] = core; |
| 61 | _mali_osk_list_init(&group->group_list); |
| 62 | diff --git a/driver/src/devicedrv/mali/common/mali_osk.h b/driver/src/devicedrv/mali/common/mali_osk.h |
| 63 | index a501778..fe93d79 100644 |
| 64 | --- common/mali_osk.h |
| 65 | +++ b/common/mali_osk.h |
| 66 | @@ -947,7 +947,17 @@ _mali_osk_errcode_t _mali_osk_notification_queue_dequeue(_mali_osk_notification_ |
| 67 | * asked for. |
| 68 | * |
| 69 | * @{ */ |
| 70 | - |
| 71 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) |
| 72 | +/** @brief Initialize a timer |
| 73 | + * |
| 74 | + * Allocates resources for a new timer, and initializes them. This does not |
| 75 | + * start the timer. |
| 76 | + * |
| 77 | + * @param callback Function to call when timer expires |
| 78 | + * @return a pointer to the allocated timer object, or NULL on failure. |
| 79 | + */ |
| 80 | +_mali_osk_timer_t *_mali_osk_timer_init(_mali_osk_timer_callback_t callback); |
| 81 | +#else |
| 82 | /** @brief Initialize a timer |
| 83 | * |
| 84 | * Allocates resources for a new timer, and initializes them. This does not |
| 85 | @@ -956,6 +966,7 @@ _mali_osk_errcode_t _mali_osk_notification_queue_dequeue(_mali_osk_notification_ |
| 86 | * @return a pointer to the allocated timer object, or NULL on failure. |
| 87 | */ |
| 88 | _mali_osk_timer_t *_mali_osk_timer_init(void); |
| 89 | +#endif |
| 90 | |
| 91 | /** @brief Start a timer |
| 92 | * |
| 93 | @@ -1034,6 +1045,7 @@ void _mali_osk_timer_del_async(_mali_osk_timer_t *tim); |
| 94 | */ |
| 95 | mali_bool _mali_osk_timer_pending(_mali_osk_timer_t *tim); |
| 96 | |
| 97 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) |
| 98 | /** @brief Set a timer's callback parameters. |
| 99 | * |
| 100 | * This must be called at least once before a timer is started/modified. |
| 101 | @@ -1047,6 +1059,7 @@ mali_bool _mali_osk_timer_pending(_mali_osk_timer_t *tim); |
| 102 | * @param data Function-specific data to supply to the function on expiry. |
| 103 | */ |
| 104 | void _mali_osk_timer_setcallback(_mali_osk_timer_t *tim, _mali_osk_timer_callback_t callback, void *data); |
| 105 | +#endif |
| 106 | |
| 107 | /** @brief Terminate a timer, and deallocate resources. |
| 108 | * |
| 109 | diff --git a/driver/src/devicedrv/mali/linux/mali_osk_timers.c b/driver/src/devicedrv/mali/linux/mali_osk_timers.c |
| 110 | index e5d7238..f9b5a86 100644 |
| 111 | --- linux/mali_osk_timers.c |
| 112 | +++ b/linux/mali_osk_timers.c |
| 113 | @@ -21,13 +21,24 @@ |
| 114 | struct _mali_osk_timer_t_struct { |
| 115 | struct timer_list timer; |
| 116 | }; |
| 117 | - |
| 118 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) |
| 119 | +typedef void (*timer_timeout_function_t)(struct timer_list *); |
| 120 | +#else |
| 121 | typedef void (*timer_timeout_function_t)(unsigned long); |
| 122 | +#endif |
| 123 | |
| 124 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) |
| 125 | +_mali_osk_timer_t *_mali_osk_timer_init(_mali_osk_timer_callback_t callback) |
| 126 | +#else |
| 127 | _mali_osk_timer_t *_mali_osk_timer_init(void) |
| 128 | +#endif |
| 129 | { |
| 130 | _mali_osk_timer_t *t = (_mali_osk_timer_t *)kmalloc(sizeof(_mali_osk_timer_t), GFP_KERNEL); |
| 131 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0) |
| 132 | + if (NULL != t) timer_setup(&t->timer, (timer_timeout_function_t)callback, 0); |
| 133 | +#else |
| 134 | if (NULL != t) init_timer(&t->timer); |
| 135 | +#endif |
| 136 | return t; |
| 137 | } |
| 138 | |
| 139 | @@ -62,12 +73,14 @@ mali_bool _mali_osk_timer_pending(_mali_osk_timer_t *tim) |
| 140 | return 1 == timer_pending(&(tim->timer)); |
| 141 | } |
| 142 | |
| 143 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) |
| 144 | void _mali_osk_timer_setcallback(_mali_osk_timer_t *tim, _mali_osk_timer_callback_t callback, void *data) |
| 145 | { |
| 146 | MALI_DEBUG_ASSERT_POINTER(tim); |
| 147 | tim->timer.data = (unsigned long)data; |
| 148 | tim->timer.function = (timer_timeout_function_t)callback; |
| 149 | } |
| 150 | +#endif |
| 151 | |
| 152 | void _mali_osk_timer_term(_mali_osk_timer_t *tim) |
| 153 | { |
| 154 | -- |
| 155 | 2.7.4 |
| 156 | |