summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörgen Nilsson <jorgen.nilsson@stericsson.com>2012-01-13 16:09:03 +0100
committerPhilippe Langlais <philippe.langlais@stericsson.com>2012-05-22 11:04:24 +0200
commitbe54b155563428a1b859f564679e9257e3d67d9d (patch)
tree7d5a5ac42301a284d391aa04408d6eea8934f587
parentb47f59c9f03f771093b1cfb717b06d5173079454 (diff)
b2r2: Check return value from debugfs calls
Check for NULL and errors before using return value when building the debugfs nodes for B2R2. ST-Ericsson Linux next: NA ST-Ericsson ID: 406740 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I11f33d9ca794070c540463a69228136fe1b35bae Signed-off-by: Jörgen Nilsson <jorgen.nilsson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/45486 Reviewed-by: QABUILD Reviewed-by: Jimmy RUBIN <jimmy.rubin@stericsson.com> Reviewed-by: Per-Daniel OLSSON <per-daniel.olsson@stericsson.com>
-rw-r--r--drivers/video/b2r2/b2r2_blt_main.c4
-rw-r--r--drivers/video/b2r2/b2r2_core.c71
-rw-r--r--drivers/video/b2r2/b2r2_debug.c22
-rw-r--r--drivers/video/b2r2/b2r2_mem_alloc.c7
4 files changed, 60 insertions, 44 deletions
diff --git a/drivers/video/b2r2/b2r2_blt_main.c b/drivers/video/b2r2/b2r2_blt_main.c
index f79bfaee9ab..919de1ef0ee 100644
--- a/drivers/video/b2r2/b2r2_blt_main.c
+++ b/drivers/video/b2r2/b2r2_blt_main.c
@@ -3305,7 +3305,7 @@ int b2r2_blt_module_init(struct b2r2_control *cont)
#ifdef CONFIG_DEBUG_FS
/* Register debug fs */
- if (cont->debugfs_root_dir) {
+ if (!IS_ERR_OR_NULL(cont->debugfs_root_dir)) {
debugfs_create_file("last_request", 0666,
cont->debugfs_root_dir,
cont, &debugfs_b2r2_blt_request_fops);
@@ -3341,7 +3341,7 @@ void b2r2_blt_module_exit(struct b2r2_control *cont)
if (cont) {
b2r2_log_info(cont->dev, "%s\n", __func__);
#ifdef CONFIG_DEBUG_FS
- if (cont->debugfs_root_dir) {
+ if (!IS_ERR_OR_NULL(cont->debugfs_root_dir)) {
debugfs_remove_recursive(cont->debugfs_root_dir);
cont->debugfs_root_dir = NULL;
}
diff --git a/drivers/video/b2r2/b2r2_core.c b/drivers/video/b2r2/b2r2_core.c
index 629633a7888..ed5f52598da 100644
--- a/drivers/video/b2r2/b2r2_core.c
+++ b/drivers/video/b2r2/b2r2_core.c
@@ -2386,10 +2386,13 @@ static int init_hw(struct b2r2_core *core)
#ifdef CONFIG_DEBUG_FS
/* Register debug fs files for register access */
- if (core->debugfs_core_root_dir && !core->debugfs_regs_dir) {
- int i;
+ if (!IS_ERR_OR_NULL(core->debugfs_core_root_dir) &&
+ IS_ERR_OR_NULL(core->debugfs_regs_dir)) {
core->debugfs_regs_dir = debugfs_create_dir("regs",
core->debugfs_core_root_dir);
+ }
+ if (!IS_ERR_OR_NULL(core->debugfs_regs_dir)) {
+ int i;
debugfs_create_file("all", 0666, core->debugfs_regs_dir,
(void *)core->hw, &debugfs_b2r2_regs_fops);
/* Create debugfs entries for all static registers */
@@ -2397,7 +2400,7 @@ static int init_hw(struct b2r2_core *core)
debugfs_create_file(debugfs_regs[i].name, 0666,
core->debugfs_regs_dir,
(void *)(((u8 *) core->hw) +
- debugfs_regs[i].offset),
+ debugfs_regs[i].offset),
&debugfs_b2r2_reg_fops);
}
#endif
@@ -2432,7 +2435,7 @@ static void exit_hw(struct b2r2_core *core)
#ifdef CONFIG_DEBUG_FS
/* Unregister our debugfs entries */
- if (core->debugfs_regs_dir) {
+ if (!IS_ERR_OR_NULL(core->debugfs_regs_dir)) {
debugfs_remove_recursive(core->debugfs_regs_dir);
core->debugfs_regs_dir = NULL;
}
@@ -2579,29 +2582,33 @@ static int b2r2_probe(struct platform_device *pdev)
#ifdef CONFIG_DEBUG_FS
core->debugfs_root_dir = debugfs_create_dir(core->name, NULL);
- core->debugfs_core_root_dir = debugfs_create_dir("core",
- core->debugfs_root_dir);
- debugfs_create_file("stats", 0666, core->debugfs_core_root_dir,
- core, &debugfs_b2r2_stat_fops);
- debugfs_create_file("clock", 0666, core->debugfs_core_root_dir,
- core, &debugfs_b2r2_clock_fops);
- debugfs_create_u8("op_size", 0666, core->debugfs_core_root_dir,
- &core->op_size);
- debugfs_create_u8("ch_size", 0666, core->debugfs_core_root_dir,
- &core->ch_size);
- debugfs_create_u8("pg_size", 0666, core->debugfs_core_root_dir,
- &core->pg_size);
- debugfs_create_u8("mg_size", 0666, core->debugfs_core_root_dir,
- &core->mg_size);
- debugfs_create_u16("min_req_time", 0666, core->debugfs_core_root_dir,
- &core->min_req_time);
-
- control->debugfs_debug_root_dir = debugfs_create_dir("debug",
- core->debugfs_root_dir);
- control->mem_heap.debugfs_root_dir = debugfs_create_dir("mem",
- core->debugfs_root_dir);
- control->debugfs_root_dir = debugfs_create_dir("blt",
- core->debugfs_root_dir);
+ if (!IS_ERR_OR_NULL(core->debugfs_root_dir)) {
+ core->debugfs_core_root_dir = debugfs_create_dir("core",
+ core->debugfs_root_dir);
+ control->debugfs_debug_root_dir = debugfs_create_dir("debug",
+ core->debugfs_root_dir);
+ control->mem_heap.debugfs_root_dir = debugfs_create_dir("mem",
+ core->debugfs_root_dir);
+ control->debugfs_root_dir = debugfs_create_dir("blt",
+ core->debugfs_root_dir);
+ }
+
+ if (!IS_ERR_OR_NULL(core->debugfs_core_root_dir)) {
+ debugfs_create_file("stats", 0666, core->debugfs_core_root_dir,
+ core, &debugfs_b2r2_stat_fops);
+ debugfs_create_file("clock", 0666, core->debugfs_core_root_dir,
+ core, &debugfs_b2r2_clock_fops);
+ debugfs_create_u8("op_size", 0666, core->debugfs_core_root_dir,
+ &core->op_size);
+ debugfs_create_u8("ch_size", 0666, core->debugfs_core_root_dir,
+ &core->ch_size);
+ debugfs_create_u8("pg_size", 0666, core->debugfs_core_root_dir,
+ &core->pg_size);
+ debugfs_create_u8("mg_size", 0666, core->debugfs_core_root_dir,
+ &core->mg_size);
+ debugfs_create_u16("min_req_time", 0666,
+ core->debugfs_core_root_dir, &core->min_req_time);
+ }
#endif
ret = b2r2_debug_init(control);
@@ -2641,7 +2648,10 @@ b2r2_probe_no_work_queue:
b2r2_debug_exit();
b2r2_probe_debug_init_failed:
#ifdef CONFIG_DEBUG_FS
- debugfs_remove_recursive(core->debugfs_root_dir);
+ if (!IS_ERR_OR_NULL(core->debugfs_root_dir)) {
+ debugfs_remove_recursive(core->debugfs_root_dir);
+ core->debugfs_root_dir = NULL;
+ }
#endif
kfree(core);
b2r2_probe_core_alloc_fail:
@@ -2669,7 +2679,10 @@ static int b2r2_remove(struct platform_device *pdev)
b2r2_log_info(&pdev->dev, "%s: Started\n", __func__);
#ifdef CONFIG_DEBUG_FS
- debugfs_remove_recursive(core->debugfs_root_dir);
+ if (!IS_ERR_OR_NULL(core->debugfs_root_dir)) {
+ debugfs_remove_recursive(core->debugfs_root_dir);
+ core->debugfs_root_dir = NULL;
+ }
#endif
/* Flush B2R2 work queue (call all callbacks) */
diff --git a/drivers/video/b2r2/b2r2_debug.c b/drivers/video/b2r2/b2r2_debug.c
index 23a0b1aa9ac..934ba938ee5 100644
--- a/drivers/video/b2r2/b2r2_debug.c
+++ b/drivers/video/b2r2/b2r2_debug.c
@@ -297,14 +297,16 @@ int b2r2_debug_init(struct b2r2_control *cont)
/* No need to save the files,
* they will be removed recursively */
- (void)debugfs_create_bool("warnings", 0644, log_lvl_dir,
- &b2r2_log_levels[B2R2_LOG_LEVEL_WARN]);
- (void)debugfs_create_bool("info", 0644, log_lvl_dir,
- &b2r2_log_levels[B2R2_LOG_LEVEL_INFO]);
- (void)debugfs_create_bool("debug", 0644, log_lvl_dir,
- &b2r2_log_levels[B2R2_LOG_LEVEL_DEBUG]);
- (void)debugfs_create_bool("regdumps", 0644, log_lvl_dir,
- &b2r2_log_levels[B2R2_LOG_LEVEL_REGDUMP]);
+ if (!IS_ERR_OR_NULL(log_lvl_dir)) {
+ (void)debugfs_create_bool("warnings", 0644, log_lvl_dir,
+ &b2r2_log_levels[B2R2_LOG_LEVEL_WARN]);
+ (void)debugfs_create_bool("info", 0644, log_lvl_dir,
+ &b2r2_log_levels[B2R2_LOG_LEVEL_INFO]);
+ (void)debugfs_create_bool("debug", 0644, log_lvl_dir,
+ &b2r2_log_levels[B2R2_LOG_LEVEL_DEBUG]);
+ (void)debugfs_create_bool("regdumps", 0644, log_lvl_dir,
+ &b2r2_log_levels[B2R2_LOG_LEVEL_REGDUMP]);
+ }
#elif defined(CONFIG_DYNAMIC_DEBUG)
/* log_lvl_dir is never used */
@@ -313,7 +315,7 @@ int b2r2_debug_init(struct b2r2_control *cont)
module_init++;
}
- if (cont->debugfs_debug_root_dir) {
+ if (!IS_ERR_OR_NULL(cont->debugfs_debug_root_dir)) {
/* No need to save the file,
* it will be removed recursively */
(void)debugfs_create_file("last_job", 0444,
@@ -330,7 +332,7 @@ void b2r2_debug_exit(void)
{
#if !defined(CONFIG_DYNAMIC_DEBUG) && defined(CONFIG_DEBUG_FS)
module_init--;
- if (!module_init && log_lvl_dir) {
+ if (!module_init && !IS_ERR_OR_NULL(log_lvl_dir)) {
debugfs_remove_recursive(log_lvl_dir);
log_lvl_dir = NULL;
}
diff --git a/drivers/video/b2r2/b2r2_mem_alloc.c b/drivers/video/b2r2/b2r2_mem_alloc.c
index e5235d2c97f..584b324b8fe 100644
--- a/drivers/video/b2r2/b2r2_mem_alloc.c
+++ b/drivers/video/b2r2/b2r2_mem_alloc.c
@@ -182,10 +182,11 @@ void debugfs_create_mem_block_entry(struct b2r2_mem_block *mem_block,
struct timespec mtime = tm;
struct timespec ctime = tm;
- if (mem_block->debugfs_block) {
+ if (!IS_ERR_OR_NULL(mem_block->debugfs_block)) {
atime = mem_block->debugfs_block->d_inode->i_atime;
ctime = mem_block->debugfs_block->d_inode->i_ctime;
debugfs_remove(mem_block->debugfs_block);
+ mem_block->debugfs_block = NULL;
}
/* Add the block in debugfs */
@@ -204,7 +205,7 @@ void debugfs_create_mem_block_entry(struct b2r2_mem_block *mem_block,
mem_block->debugfs_fname,
0444, parent, mem_block,
&debugfs_b2r2_mem_block_fops);
- if (mem_block->debugfs_block) {
+ if (!IS_ERR_OR_NULL(mem_block->debugfs_block)) {
mem_block->debugfs_block->d_inode->i_size = mem_block->size;
mem_block->debugfs_block->d_inode->i_atime = atime;
mem_block->debugfs_block->d_inode->i_mtime = mtime;
@@ -243,7 +244,7 @@ int b2r2_mem_init(struct b2r2_control *cont,
#ifdef CONFIG_DEBUG_FS
/* Register debugfs */
- if (cont->mem_heap.debugfs_root_dir) {
+ if (!IS_ERR_OR_NULL(cont->mem_heap.debugfs_root_dir)) {
cont->mem_heap.debugfs_heap_stats = debugfs_create_file(
"stats", 0444, cont->mem_heap.debugfs_root_dir,
&cont->mem_heap, &debugfs_b2r2_mem_stats_fops);