2019-11-07 08:54:37

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH] media: c8sectpfe: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the
return value. The function can work or not, but the code logic should
never do something different based on this.

Cc: Patrice Chotard <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
.../sti/c8sectpfe/c8sectpfe-debugfs.c | 26 +++----------------
1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c
index 8f0ddcbeed9d..301fa10f419b 100644
--- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c
@@ -225,36 +225,16 @@ static const struct debugfs_reg32 fei_sys_regs[] = {

void c8sectpfe_debugfs_init(struct c8sectpfei *fei)
{
- struct dentry *root;
- struct dentry *file;
-
- root = debugfs_create_dir("c8sectpfe", NULL);
- if (!root)
- goto err;
-
- fei->root = root;
-
fei->regset = devm_kzalloc(fei->dev, sizeof(*fei->regset), GFP_KERNEL);
if (!fei->regset)
- goto err;
+ return;

fei->regset->regs = fei_sys_regs;
fei->regset->nregs = ARRAY_SIZE(fei_sys_regs);
fei->regset->base = fei->io;

- file = debugfs_create_regset32("registers", S_IRUGO, root,
- fei->regset);
- if (!file) {
- dev_err(fei->dev,
- "%s not able to create 'registers' debugfs\n"
- , __func__);
- goto err;
- }
-
- return;
-
-err:
- debugfs_remove_recursive(root);
+ fei->root = debugfs_create_dir("c8sectpfe", NULL);
+ debugfs_create_regset32("registers", S_IRUGO, fei->root, fei->regset);
}

void c8sectpfe_debugfs_exit(struct c8sectpfei *fei)
--
2.23.0


2019-11-07 10:02:23

by Patrice CHOTARD

[permalink] [raw]
Subject: Re: [PATCH] media: c8sectpfe: no need to check return value of debugfs_create functions

Hi

On 11/7/19 9:52 AM, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value. The function can work or not, but the code logic should
> never do something different based on this.
>
> Cc: Patrice Chotard <[email protected]>
> Cc: Mauro Carvalho Chehab <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> .../sti/c8sectpfe/c8sectpfe-debugfs.c | 26 +++----------------
> 1 file changed, 3 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c
> index 8f0ddcbeed9d..301fa10f419b 100644
> --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c
> +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c
> @@ -225,36 +225,16 @@ static const struct debugfs_reg32 fei_sys_regs[] = {
>
> void c8sectpfe_debugfs_init(struct c8sectpfei *fei)
> {
> - struct dentry *root;
> - struct dentry *file;
> -
> - root = debugfs_create_dir("c8sectpfe", NULL);
> - if (!root)
> - goto err;
> -
> - fei->root = root;
> -
> fei->regset = devm_kzalloc(fei->dev, sizeof(*fei->regset), GFP_KERNEL);
> if (!fei->regset)
> - goto err;
> + return;
>
> fei->regset->regs = fei_sys_regs;
> fei->regset->nregs = ARRAY_SIZE(fei_sys_regs);
> fei->regset->base = fei->io;
>
> - file = debugfs_create_regset32("registers", S_IRUGO, root,
> - fei->regset);
> - if (!file) {
> - dev_err(fei->dev,
> - "%s not able to create 'registers' debugfs\n"
> - , __func__);
> - goto err;
> - }
> -
> - return;
> -
> -err:
> - debugfs_remove_recursive(root);
> + fei->root = debugfs_create_dir("c8sectpfe", NULL);
> + debugfs_create_regset32("registers", S_IRUGO, fei->root, fei->regset);
> }
>
> void c8sectpfe_debugfs_exit(struct c8sectpfei *fei)

Reviewed-by: Patrice Chotard <[email protected]>

Thanks