From 624b2f87e5b095b91d73a7863a6826472eea5e4b Mon Sep 17 00:00:00 2001 From: chenlj2 Date: Thu, 20 Oct 2022 18:57:06 +0800 Subject: [PATCH] dlkm:optimise report function for pen revert https://gerrit.mot.com/#/c/2409191/ above submit that cause pen didn't work optimise report function for kernel panic add NULL judge Change-Id: I4ce63ced28120c9b6d22fbdf5a84af2d858ac1b4 Signed-off-by: chenlj2 Reviewed-on: https://gerrit.mot.com/2409699 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jianqiu Huang Reviewed-by: Tao Sun Submit-Approved: Jira Key --- drivers/misc/pen/bu520xx_pen.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/misc/pen/bu520xx_pen.c b/drivers/misc/pen/bu520xx_pen.c index c3eaf09e4369..d49815dd3e1e 100644 --- a/drivers/misc/pen/bu520xx_pen.c +++ b/drivers/misc/pen/bu520xx_pen.c @@ -297,8 +297,8 @@ static void pen_report_function(struct work_struct *dat) int counter, status = 0, initial_status; pen_dbg_func_in(); - if (!hall_sensor_dev->enable) { - pen_info("[%s] pen isn't enable,don't report.\n", DRIVER_NAME); + if (!hall_sensor_dev) { + pen_info("[%s] hall_sensor_dev isn't init.\n", DRIVER_NAME); return; } initial_status = hall_sensor_dev->status; @@ -321,6 +321,10 @@ static void pen_report_function(struct work_struct *dat) return; } + if (!hall_sensor_dev->pen_indev) { + pen_info("[%s] pen_indev isn't ready,don't report.\n", DRIVER_NAME); + return; + } input_report_switch(hall_sensor_dev->pen_indev, SW_PEN_INSERTED, !hall_sensor_dev->status); input_sync(hall_sensor_dev->pen_indev); #ifdef CONFIG_HAS_WAKELOCK @@ -426,7 +430,7 @@ static int bu520xx_pen_probe(struct platform_device *pdev) } spin_lock_init(&hall_sensor_dev->mHallSensorLock); - hall_sensor_dev->enable = 0; + hall_sensor_dev->enable = 1; //set gpio hall_sensor_dev->gpio = of_get_named_gpio_flags(np,