From cdf2f2b20bbab2a6faa23660b644aa0b7a33e013 Mon Sep 17 00:00:00 2001 From: Park Ju Hyung Date: Mon, 21 Jan 2019 20:18:37 +0900 Subject: [PATCH] qcacld-3.0: Defer HDD initialization * Also rely on userspace writing to /dev/wlan, Wi-Fi HAL writes "ON" or "OFF" to /dev/wlan. * Use this method to initialize hdd as it's a safer way to ensure both wlan_mac.bin and WCNSS_qcom_cfg.ini are ready to be read. * This also eliminates the needs for horrible hacks to read the userspace file. Change-Id: I648f1a107c095e50a64f44c39e78d6b6f917e190 --- .../qcacld-3.0/core/hdd/src/wlan_hdd_main.c | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_main.c b/drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_main.c index 4ba6753bce13..3ccb2ecd2bde 100644 --- a/drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_main.c +++ b/drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_main.c @@ -243,6 +243,7 @@ static unsigned int dev_num = 1; static struct cdev wlan_hdd_state_cdev; static struct class *class; static dev_t device; +static bool hdd_loaded = false; #ifndef MODULE static struct gwlan_loader *wlan_loader; static ssize_t wlan_boot_cb(struct kobject *kobj, @@ -16805,6 +16806,7 @@ static void hdd_inform_wifi_on(void) } #endif +int hdd_driver_load(void); static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, const char __user *user_buf, size_t count, @@ -16839,6 +16841,13 @@ static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, goto exit; } + if (!hdd_loaded) { + if (hdd_driver_load()) { + pr_err("%s: Failed to init hdd module\n", __func__); + goto exit; + } + } + if (!cds_is_driver_loaded() || cds_is_driver_recovering()) { rc = wait_for_completion_timeout(&wlan_start_comp, msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); @@ -17693,16 +17702,10 @@ int hdd_driver_load(void) hdd_set_conparam(con_mode); - errno = wlan_hdd_state_ctrl_param_create(); - if (errno) { - hdd_err("Failed to create ctrl param; errno:%d", errno); - goto wakelock_destroy; - } - errno = pld_init(); if (errno) { hdd_err("Failed to init PLD; errno:%d", errno); - goto param_destroy; + goto wakelock_destroy; } /* driver mode pass to cnss2 platform driver*/ @@ -17722,6 +17725,7 @@ int hdd_driver_load(void) goto pld_deinit; } + hdd_loaded = true; hdd_debug("%s: driver loaded", WLAN_MODULE_NAME); return 0; @@ -17740,8 +17744,6 @@ pld_deinit: /* Wait for any ref taken on /dev/wlan to be released */ while (qdf_atomic_read(&wlan_hdd_state_fops_ref)) ; -param_destroy: - wlan_hdd_state_ctrl_param_destroy(); wakelock_destroy: qdf_wake_lock_destroy(&wlan_wake_lock); comp_deinit: @@ -17990,10 +17992,13 @@ static int hdd_module_init(void) #else static int hdd_module_init(void) { - if (hdd_driver_load()) - return -EINVAL; + int ret; - return 0; + ret = wlan_hdd_state_ctrl_param_create(); + if (ret) + pr_err("wlan_hdd_state_create:%x\n", ret); + + return ret; } #endif #else