From c2fd2c3c666cc59ebde43e568da2c2f4ee17980a Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Tue, 1 Jul 2025 12:54:07 +0100 Subject: [PATCH] misc: bluedroid_pm: Ensure 'host_wake' is configured Currently the wakeup source is configured if only the 'ext_wake' is valid. However, the bluedroid_pm_timer and proc interface that are configured when 'ext_wake' is valid, also assumes that 'host_wake' is also valid. Therefore, update the code to only configure the bluedroid_pm_timer and proc interface if both of these are valid. Bug 4958861 Change-Id: I16ef55359c36acc9dc50464f43816ae2ef3c3123 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3397252 (cherry picked from commit b1e18d66aa0ab6d491b88caac5fa9abddb69d0e4) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3462461 Reviewed-by: Brad Griffis GVS: buildbot_gerritrpt --- drivers/misc/bluedroid_pm.c | 39 +++++++++++++++---------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/misc/bluedroid_pm.c b/drivers/misc/bluedroid_pm.c index 33984e2b..9d850565 100644 --- a/drivers/misc/bluedroid_pm.c +++ b/drivers/misc/bluedroid_pm.c @@ -438,34 +438,16 @@ static int bluedroid_pm_probe(struct platform_device *pdev) bluedroid_pm->rfkill = rfkill; } - if (IS_ERR(bluedroid_pm->host_wake)) - BDP_DBG("gpio_host_wake not registered\n"); - else + if (!IS_ERR(bluedroid_pm->ext_wake) && !IS_ERR(bluedroid_pm->host_wake)) { /* configure host_wake as input */ gpiod_direction_input(bluedroid_pm->host_wake); - if (bluedroid_pm->host_wake_irq > -1) { - BDP_DBG("found host_wake irq\n"); - ret = request_irq(bluedroid_pm->host_wake_irq, - bluedroid_pm_hostwake_isr, - IRQF_TRIGGER_RISING, - "bluetooth hostwake", bluedroid_pm); - if (ret) { - BDP_ERR("Failed to get host_wake irq\n"); - goto free_host_wake; - } - } else - BDP_DBG("host_wake not registered\n"); - - if (IS_ERR(bluedroid_pm->ext_wake)) { - BDP_DBG("host_wake not registered\n"); - } else { /* configure ext_wake as output mode*/ gpiod_direction_output(bluedroid_pm->ext_wake, 1); if (create_bt_proc_interface(bluedroid_pm)) { BDP_ERR("Failed to create proc interface"); - goto free_ext_wake; + goto free_host_wake; } /* initialize wake lock */ bluedroid_pm->wake_lock = wakeup_source_register(&pdev->dev, @@ -480,6 +462,20 @@ static int bluedroid_pm_probe(struct platform_device *pdev) bluedroid_pm_timer_expire, 0); } + if (bluedroid_pm->host_wake_irq > -1) { + BDP_DBG("found host_wake irq\n"); + ret = request_irq(bluedroid_pm->host_wake_irq, + bluedroid_pm_hostwake_isr, + IRQF_TRIGGER_RISING, + "bluetooth hostwake", bluedroid_pm); + if (ret) { + BDP_ERR("Failed to get host_wake irq\n"); + goto free_host_wake; + } + } else { + BDP_DBG("host_wake not registered\n"); + } + INIT_WORK(&bluedroid_pm->work, bluedroid_work); spin_lock_init(&bluedroid_pm->lock); @@ -491,9 +487,6 @@ static int bluedroid_pm_probe(struct platform_device *pdev) free_bt_proc: remove_bt_proc_interface(); -free_ext_wake: - if (bluedroid_pm->host_wake_irq > -1) - free_irq(bluedroid_pm->host_wake_irq, bluedroid_pm); free_host_wake: if (bluedroid_pm->rfkill) rfkill_unregister(bluedroid_pm->rfkill);