Skip to content

Commit

Permalink
qcacld: defer hdd initialization and rely on userspace writing to /de…
Browse files Browse the repository at this point in the history
…v/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 is ready to be read.

This also eliminates the needs for horrible hack to read userspace file.

Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
  • Loading branch information
arter97 authored and acuicultor committed Feb 12, 2021
1 parent 16ed6e0 commit 7b5082f
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_main.c
Expand Up @@ -214,6 +214,8 @@ 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;


/* the Android framework expects this param even though we don't use it */
#define BUF_LEN 20
Expand Down Expand Up @@ -14549,6 +14551,8 @@ static int wlan_hdd_state_ctrl_param_open(struct inode *inode,
return 0;
}

static int hdd_driver_load(void);

static void hdd_inform_wifi_off(void)
{
struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Expand Down Expand Up @@ -14597,6 +14601,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));
Expand Down Expand Up @@ -15454,16 +15465,10 @@ static 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;
}

hdd_driver_mode_change_register();
Expand All @@ -15478,6 +15483,7 @@ static int hdd_driver_load(void)
goto pld_deinit;
}

hdd_loaded = true;
hdd_debug("%s: driver loaded", WLAN_MODULE_NAME);

return 0;
Expand All @@ -15496,8 +15502,6 @@ static int hdd_driver_load(void)
/* 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:
Expand Down Expand Up @@ -15612,10 +15616,13 @@ static void hdd_driver_unload(void)
*/
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;
}

/**
Expand Down

0 comments on commit 7b5082f

Please sign in to comment.