mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 17:25:35 +03:00
drivers: Use runtime debugfs check
When kernel command line debugfs=off is specified instead of disabling CONFIG_DEBUG_FS in defconfig to disable Debug-FS, debugfs functions like debugfs_create_dir will fail. Use function debugfs_initialized() to check if debugfs functionality is enabled before calling any debugfs functions. This allows us to by-pass debugfs initialization if debugfs is not enabled. Also, there is no need to protect debugfs related code under CONFIG_DEBUG_FS, as stub functions for all debugfs APIs are defined when CONFIG_DEBUG_FS is disabled. Bug 3752450 Change-Id: I1aa2c46bc822da54fdc87504ac75c91845e02c12 Signed-off-by: Bharat Nihalani <bnihalani@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2820666 Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com> Reviewed-by: Dara Ramesh <dramesh@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
Laxman Dewangan
parent
83ee116f72
commit
d40e2df1b2
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* ARAM manager
|
* ARAM manager
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2018, NVIDIA Corporation. All rights reserved.
|
* Copyright (C) 2014-2022, NVIDIA Corporation. All rights reserved.
|
||||||
*
|
*
|
||||||
* This software is licensed under the terms of the GNU General Public
|
* This software is licensed under the terms of the GNU General Public
|
||||||
* License version 2, as published by the Free Software Foundation, and
|
* License version 2, as published by the Free Software Foundation, and
|
||||||
@@ -48,7 +48,6 @@ unsigned long nvadsp_aram_get_address(void *handle)
|
|||||||
return mem_get_address(handle);
|
return mem_get_address(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FS
|
|
||||||
static struct dentry *aram_dump_debugfs_file;
|
static struct dentry *aram_dump_debugfs_file;
|
||||||
|
|
||||||
static int nvadsp_aram_dump(struct seq_file *s, void *data)
|
static int nvadsp_aram_dump(struct seq_file *s, void *data)
|
||||||
@@ -68,7 +67,6 @@ static const struct file_operations aram_dump_fops = {
|
|||||||
.llseek = seq_lseek,
|
.llseek = seq_lseek,
|
||||||
.release = single_release,
|
.release = single_release,
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
int nvadsp_aram_init(unsigned long addr, unsigned long size)
|
int nvadsp_aram_init(unsigned long addr, unsigned long size)
|
||||||
{
|
{
|
||||||
@@ -78,23 +76,21 @@ int nvadsp_aram_init(unsigned long addr, unsigned long size)
|
|||||||
return PTR_ERR(aram_handle);
|
return PTR_ERR(aram_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FS
|
if (debugfs_initialized()) {
|
||||||
aram_dump_debugfs_file = debugfs_create_file("aram_dump",
|
aram_dump_debugfs_file = debugfs_create_file("aram_dump",
|
||||||
S_IRUSR, NULL, NULL, &aram_dump_fops);
|
S_IRUSR, NULL, NULL, &aram_dump_fops);
|
||||||
if (!aram_dump_debugfs_file) {
|
if (!aram_dump_debugfs_file) {
|
||||||
pr_err("ERROR: failed to create aram_dump debugfs");
|
pr_err("ERROR: failed to create aram_dump debugfs");
|
||||||
destroy_mem_manager(aram_handle);
|
destroy_mem_manager(aram_handle);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nvadsp_aram_exit(void)
|
void nvadsp_aram_exit(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_DEBUG_FS
|
|
||||||
debugfs_remove(aram_dump_debugfs_file);
|
debugfs_remove(aram_dump_debugfs_file);
|
||||||
#endif
|
|
||||||
destroy_mem_manager(aram_handle);
|
destroy_mem_manager(aram_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* dram app memory manager for allocating memory for text,bss and data
|
* dram app memory manager for allocating memory for text,bss and data
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2018, NVIDIA Corporation. All rights reserved.
|
* Copyright (C) 2014-2022, NVIDIA Corporation. All rights reserved.
|
||||||
*
|
*
|
||||||
* This software is licensed under the terms of the GNU General Public
|
* This software is licensed under the terms of the GNU General Public
|
||||||
* License version 2, as published by the Free Software Foundation, and
|
* License version 2, as published by the Free Software Foundation, and
|
||||||
@@ -50,7 +50,6 @@ unsigned long dram_app_mem_get_address(void *handle)
|
|||||||
return mem_get_address(handle);
|
return mem_get_address(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FS
|
|
||||||
static struct dentry *dram_app_mem_dump_debugfs_file;
|
static struct dentry *dram_app_mem_dump_debugfs_file;
|
||||||
|
|
||||||
static int dram_app_mem_dump(struct seq_file *s, void *data)
|
static int dram_app_mem_dump(struct seq_file *s, void *data)
|
||||||
@@ -70,7 +69,6 @@ static const struct file_operations dram_app_mem_dump_fops = {
|
|||||||
.llseek = seq_lseek,
|
.llseek = seq_lseek,
|
||||||
.release = single_release,
|
.release = single_release,
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
int dram_app_mem_init(unsigned long start, unsigned long size)
|
int dram_app_mem_init(unsigned long start, unsigned long size)
|
||||||
{
|
{
|
||||||
@@ -81,24 +79,22 @@ int dram_app_mem_init(unsigned long start, unsigned long size)
|
|||||||
return PTR_ERR(dram_app_mem_handle);
|
return PTR_ERR(dram_app_mem_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FS
|
if (debugfs_initialized()) {
|
||||||
dram_app_mem_dump_debugfs_file =
|
dram_app_mem_dump_debugfs_file =
|
||||||
debugfs_create_file("dram_app_mem_dump",
|
debugfs_create_file("dram_app_mem_dump",
|
||||||
S_IRUSR, NULL, NULL, &dram_app_mem_dump_fops);
|
S_IRUSR, NULL, NULL, &dram_app_mem_dump_fops);
|
||||||
if (!dram_app_mem_dump_debugfs_file) {
|
if (!dram_app_mem_dump_debugfs_file) {
|
||||||
pr_err("ERROR: failed to create dram_app_mem_dump debugfs");
|
pr_err("ERROR: failed to create dram_app_mem_dump debugfs");
|
||||||
destroy_mem_manager(dram_app_mem_handle);
|
destroy_mem_manager(dram_app_mem_handle);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dram_app_mem_exit(void)
|
void dram_app_mem_exit(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_DEBUG_FS
|
|
||||||
debugfs_remove(dram_app_mem_dump_debugfs_file);
|
debugfs_remove(dram_app_mem_dump_debugfs_file);
|
||||||
#endif
|
|
||||||
destroy_mem_manager(dram_app_mem_handle);
|
destroy_mem_manager(dram_app_mem_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user