qcacld-3.0: Load driver during kernel init when not built as a module
Requiring userspace to write to /sys/kernel/boot_wlan/boot_wlan when qcacld isn't built as a module is unnecessary. Loading this driver only takes 1-2 ms, so we should just do so directly during kernel init. Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
This commit is contained in:
parent
c68e456ab1
commit
b74b6638c6
1 changed files with 1 additions and 175 deletions
|
@ -248,33 +248,6 @@ static uint16_t sec_max_station = 0;
|
|||
extern int cur_sec_sar_index;
|
||||
#endif /* SEC_CONFIG_POWER_BACKOFF */
|
||||
|
||||
#ifndef MODULE
|
||||
static struct gwlan_loader *wlan_loader;
|
||||
static ssize_t wlan_boot_cb(struct kobject *kobj,
|
||||
struct kobj_attribute *attr,
|
||||
const char *buf, size_t count);
|
||||
struct gwlan_loader {
|
||||
bool loaded_state;
|
||||
struct kobject *boot_wlan_obj;
|
||||
struct attribute_group *attr_group;
|
||||
};
|
||||
|
||||
static struct kobj_attribute wlan_boot_attribute =
|
||||
__ATTR(boot_wlan, 0220, NULL, wlan_boot_cb);
|
||||
|
||||
static struct attribute *attrs[] = {
|
||||
&wlan_boot_attribute.attr,
|
||||
NULL,
|
||||
};
|
||||
#define MODULE_INITIALIZED 1
|
||||
|
||||
#ifdef MULTI_IF_NAME
|
||||
#define WLAN_LOADER_NAME "boot_" MULTI_IF_NAME
|
||||
#else
|
||||
#define WLAN_LOADER_NAME "boot_wlan"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* the Android framework expects this param even though we don't use it */
|
||||
#define BUF_LEN 20
|
||||
static char fwpath_buffer[BUF_LEN];
|
||||
|
@ -16671,6 +16644,7 @@ static void hdd_driver_unload(void)
|
|||
osif_sync_deinit();
|
||||
|
||||
hdd_qdf_deinit();
|
||||
|
||||
}
|
||||
|
||||
#if defined (SEC_CONFIG_PSM_SYSFS)
|
||||
|
@ -16685,133 +16659,6 @@ int wlan_hdd_sec_get_psm(void)
|
|||
}
|
||||
#endif /* SEC_CONFIG_PSM_SYSFS */
|
||||
|
||||
#ifndef MODULE
|
||||
/**
|
||||
* wlan_boot_cb() - Wlan boot callback
|
||||
* @kobj: object whose directory we're creating the link in.
|
||||
* @attr: attribute the user is interacting with
|
||||
* @buff: the buffer containing the user data
|
||||
* @count: number of bytes in the buffer
|
||||
*
|
||||
* This callback is invoked when the fs is ready to start the
|
||||
* wlan driver initialization.
|
||||
*
|
||||
* Return: 'count' on success or a negative error code in case of failure
|
||||
*/
|
||||
static ssize_t wlan_boot_cb(struct kobject *kobj,
|
||||
struct kobj_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
|
||||
if (wlan_loader->loaded_state) {
|
||||
hdd_err("wlan driver already initialized");
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
if (hdd_driver_load())
|
||||
return -EIO;
|
||||
|
||||
wlan_loader->loaded_state = MODULE_INITIALIZED;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* hdd_sysfs_cleanup() - cleanup sysfs
|
||||
*
|
||||
* Return: None
|
||||
*
|
||||
*/
|
||||
static void hdd_sysfs_cleanup(void)
|
||||
{
|
||||
/* remove from group */
|
||||
if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group)
|
||||
sysfs_remove_group(wlan_loader->boot_wlan_obj,
|
||||
wlan_loader->attr_group);
|
||||
|
||||
/* unlink the object from parent */
|
||||
kobject_del(wlan_loader->boot_wlan_obj);
|
||||
|
||||
/* free the object */
|
||||
kobject_put(wlan_loader->boot_wlan_obj);
|
||||
|
||||
kfree(wlan_loader->attr_group);
|
||||
kfree(wlan_loader);
|
||||
|
||||
wlan_loader = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is
|
||||
* ready
|
||||
*
|
||||
* This is creates the syfs entry boot_wlan. Which shall be invoked
|
||||
* when the filesystem is ready.
|
||||
*
|
||||
* QDF API cannot be used here since this function is called even before
|
||||
* initializing WLAN driver.
|
||||
*
|
||||
* Return: 0 for success, errno on failure
|
||||
*/
|
||||
static int wlan_init_sysfs(void)
|
||||
{
|
||||
int ret = -ENOMEM;
|
||||
|
||||
wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL);
|
||||
if (!wlan_loader)
|
||||
return -ENOMEM;
|
||||
|
||||
wlan_loader->boot_wlan_obj = NULL;
|
||||
wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)),
|
||||
GFP_KERNEL);
|
||||
if (!wlan_loader->attr_group)
|
||||
goto error_return;
|
||||
|
||||
wlan_loader->loaded_state = 0;
|
||||
wlan_loader->attr_group->attrs = attrs;
|
||||
|
||||
wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME,
|
||||
kernel_kobj);
|
||||
if (!wlan_loader->boot_wlan_obj) {
|
||||
hdd_err("sysfs create and add failed");
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
ret = sysfs_create_group(wlan_loader->boot_wlan_obj,
|
||||
wlan_loader->attr_group);
|
||||
if (ret) {
|
||||
hdd_err("sysfs create group failed; errno:%d", ret);
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error_return:
|
||||
hdd_sysfs_cleanup();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan
|
||||
*
|
||||
* Return: 0 on success or errno on failure
|
||||
*/
|
||||
static int wlan_deinit_sysfs(void)
|
||||
{
|
||||
if (!wlan_loader) {
|
||||
hdd_err("wlan_loader is null");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hdd_sysfs_cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* MODULE */
|
||||
|
||||
#ifdef MODULE
|
||||
/**
|
||||
* hdd_module_init() - Module init helper
|
||||
*
|
||||
|
@ -16826,21 +16673,7 @@ static int hdd_module_init(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int __init hdd_module_init(void)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
|
||||
ret = wlan_init_sysfs();
|
||||
if (ret)
|
||||
hdd_err("Failed to create sysfs entry");
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MODULE
|
||||
/**
|
||||
* hdd_module_exit() - Exit function
|
||||
*
|
||||
|
@ -16852,13 +16685,6 @@ static void __exit hdd_module_exit(void)
|
|||
{
|
||||
hdd_driver_unload();
|
||||
}
|
||||
#else
|
||||
static void __exit hdd_module_exit(void)
|
||||
{
|
||||
hdd_driver_unload();
|
||||
wlan_deinit_sysfs();
|
||||
}
|
||||
#endif
|
||||
|
||||
static int fwpath_changed_handler(const char *kmessage,
|
||||
const struct kernel_param *kp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue