From 9fb93a4743f518eae61dbd4c6b59de17212d62ae Mon Sep 17 00:00:00 2001 From: kalathik Date: Wed, 19 Aug 2020 14:24:43 +0530 Subject: [PATCH] wakeup_source: Choose wakeup_source API based on version Its required to choose the wakeup source API depends on Linux kernel version. Added new mmi_wake_lock.h file to select the API, depends on kernel version. Change-Id: I066e679e2f923f47b51b288ca0196e2c8dbd86d2 Signed-off-by: Kanagarathina Kalathi Reviewed-on: https://gerrit.mot.com/1727382 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Konstantin Makariev Submit-Approved: Jira Key --- include/linux/mmi_wake_lock.h | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 include/linux/mmi_wake_lock.h diff --git a/include/linux/mmi_wake_lock.h b/include/linux/mmi_wake_lock.h new file mode 100644 index 000000000000..fe5a7412117f --- /dev/null +++ b/include/linux/mmi_wake_lock.h @@ -0,0 +1,48 @@ +/* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _MMI_WAKE_LOCK_H +#define _MMI_WAKE_LOCK_H + +#include +#include + +#define PM_STAY_AWAKE(_wakeup_source) __pm_stay_awake(_wakeup_source); +#define PM_RELAX(_wakeup_source) __pm_relax(_wakeup_source); +#define PM_WAKEUP_EVENT(_wakeup_source, _time) \ + __pm_wakeup_event(_wakeup_source, _time); + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 110) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 163) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0))) +#define PM_WAKEUP_REGISTER(_dev, _wakeup_source, _name) \ + _wakeup_source = wakeup_source_register(_dev, _name); +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 81) +#define PM_WAKEUP_REGISTER(_dev, _wakeup_source, _name) \ + _wakeup_source = wakeup_source_register(_name); +#else +#define PM_WAKEUP_REGISTER(_dev, _wakeup_source, _name) { \ + _wakeup_source = (struct wakeup_source *)kmalloc(struct wakeup_source); \ + wakeup_source_init(_wakeup_source, _name); \ +} +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 81) +#define PM_WAKEUP_UNREGISTER(_wakeup_source) \ + wakeup_source_unregister(_wakeup_source); +#else +#define PM_WAKEUP_UNREGISTER(_wakeup_source) { \ + wakeup_source_trash(_wakeup_source); \ + kfree(_wakeup_source); \ +} +#endif + +#endif // _MMI_WAKE_LOCK_H