From 72bc40a410c5a55aa08c295c7e67a7f3a3b327a2 Mon Sep 17 00:00:00 2001 From: huangjq9 Date: Mon, 19 Oct 2020 14:57:15 +0800 Subject: [PATCH] hall: stylus bu520xx: Fix wakeup_source event API change Refer to https://gerrit.mot.com/#/c/1721469/ On latest kernel wakeup_source_init API remove, Need to use wakeup_source_register for the same. This fix replaces wakeup_source_init to wakeup_source_register wakeup_source_trash to wakeup_source_unregister Change-Id: I0ae76f3f942237fc89c943fbd65ed48eefd9b698 Signed-off-by: huangjq9 Reviewed-on: https://gerrit.mot.com/1778411 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jun Weng Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- drivers/misc/pen/bu520xx_pen.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/misc/pen/bu520xx_pen.c b/drivers/misc/pen/bu520xx_pen.c index 0c270915ad58..513b2461236b 100644 --- a/drivers/misc/pen/bu520xx_pen.c +++ b/drivers/misc/pen/bu520xx_pen.c @@ -24,6 +24,7 @@ #include #else #include +#include #endif #define BU520XX_DBG_ENABLE @@ -61,7 +62,7 @@ static struct hall_sensor_str { #ifdef CONFIG_HAS_WAKELOCK struct wake_lock wake_lock; #else - struct wakeup_source wake_lock; + struct wakeup_source *wake_lock; #endif struct input_dev *pen_indev; struct input_handler pen_handler; @@ -326,7 +327,7 @@ static void pen_report_function(struct work_struct *dat) #ifdef CONFIG_HAS_WAKELOCK wake_lock_timeout(&hall_sensor_dev->wake_lock, msecs_to_jiffies(3000)); #else - __pm_wakeup_event(&hall_sensor_dev->wake_lock, msecs_to_jiffies(3000)); + PM_WAKEUP_EVENT(hall_sensor_dev->wake_lock,msecs_to_jiffies(3000)); #endif if(!hall_sensor_dev->status) @@ -453,7 +454,12 @@ static int bu520xx_pen_probe(struct platform_device *pdev) #ifdef CONFIG_HAS_WAKELOCK wake_lock_init(&hall_sensor_dev->wake_lock, WAKE_LOCK_SUSPEND, "pen_suspend_blocker"); #else - wakeup_source_init(&hall_sensor_dev->wake_lock, "pen_suspend_blocker"); + PM_WAKEUP_REGISTER(&pdev->dev, hall_sensor_dev->wake_lock, "pen_suspend_blocker"); + if(!hall_sensor_dev->wake_lock){ + dev_err(&pdev->dev,"%s: Failed to allocate wakeup source\n",__func__); + ret = -ENOMEM; + goto fail_wakeup_init; + } #endif //set irq ret = set_irq_hall_sensor(); @@ -470,8 +476,9 @@ fail_for_irq_hall_sensor: #ifdef CONFIG_HAS_WAKELOCK wake_lock_destroy(&hall_sensor_dev->wake_lock); #else - wakeup_source_trash(&hall_sensor_dev->wake_lock); + PM_WAKEUP_UNREGISTER(hall_sensor_dev->wake_lock); #endif +fail_wakeup_init: fail_for_create_input_dev: hall_sensor_dev->pen_indev=NULL; gpio_free(hall_sensor_dev->gpio); @@ -494,7 +501,7 @@ static int bu520xx_pen_remove(struct platform_device *pdev) #ifdef CONFIG_HAS_WAKELOCK wake_lock_destroy(&hall_sensor_dev->wake_lock); #else - wakeup_source_trash(&hall_sensor_dev->wake_lock); + PM_WAKEUP_UNREGISTER(hall_sensor_dev->wake_lock); #endif hall_sensor_dev->pen_indev=NULL; kfree(hall_sensor_dev);