2020-08-26 11:42:51

by Dan Carpenter

[permalink] [raw]
Subject: [PATCH] memory: emif: Remove bogus debugfs error handling

Callers are generally not supposed to check the return values from
debugfs functions. Debugfs functions never return NULL so this error
handling will never trigger. (Historically debugfs functions used to
return a mix of NULL and error pointers but it was eventually deemed too
complicated for something which wasn't intended to be used in normal
situations).

Delete all the error handling.

Signed-off-by: Dan Carpenter <[email protected]>
---
drivers/memory/emif.c | 33 +++++----------------------------
1 file changed, 5 insertions(+), 28 deletions(-)

diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c
index bb6a71d26798..5c4d8319c9cf 100644
--- a/drivers/memory/emif.c
+++ b/drivers/memory/emif.c
@@ -163,35 +163,12 @@ static const struct file_operations emif_mr4_fops = {

static int __init_or_module emif_debugfs_init(struct emif_data *emif)
{
- struct dentry *dentry;
- int ret;
-
- dentry = debugfs_create_dir(dev_name(emif->dev), NULL);
- if (!dentry) {
- ret = -ENOMEM;
- goto err0;
- }
- emif->debugfs_root = dentry;
-
- dentry = debugfs_create_file("regcache_dump", S_IRUGO,
- emif->debugfs_root, emif, &emif_regdump_fops);
- if (!dentry) {
- ret = -ENOMEM;
- goto err1;
- }
-
- dentry = debugfs_create_file("mr4", S_IRUGO,
- emif->debugfs_root, emif, &emif_mr4_fops);
- if (!dentry) {
- ret = -ENOMEM;
- goto err1;
- }
-
+ emif->debugfs_root = debugfs_create_dir(dev_name(emif->dev), NULL);
+ debugfs_create_file("regcache_dump", S_IRUGO, emif->debugfs_root, emif,
+ &emif_regdump_fops);
+ debugfs_create_file("mr4", S_IRUGO, emif->debugfs_root, emif,
+ &emif_mr4_fops);
return 0;
-err1:
- debugfs_remove_recursive(emif->debugfs_root);
-err0:
- return ret;
}

static void __exit emif_debugfs_exit(struct emif_data *emif)
--
2.28.0


2020-08-26 16:53:42

by Santosh Shilimkar

[permalink] [raw]
Subject: Re: [PATCH] memory: emif: Remove bogus debugfs error handling

On 8/26/20 4:37 AM, Dan Carpenter wrote:
> Callers are generally not supposed to check the return values from
> debugfs functions. Debugfs functions never return NULL so this error
> handling will never trigger. (Historically debugfs functions used to
> return a mix of NULL and error pointers but it was eventually deemed too
> complicated for something which wasn't intended to be used in normal
> situations).
>
> Delete all the error handling.
>
> Signed-off-by: Dan Carpenter <[email protected]>
> ---
Looks good to me !!

Acked-by: Santosh Shilimkar <[email protected]>

2020-08-27 19:38:48

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH] memory: emif: Remove bogus debugfs error handling

On Wed, Aug 26, 2020 at 09:52:37AM -0700, [email protected] wrote:
> On 8/26/20 4:37 AM, Dan Carpenter wrote:
> > Callers are generally not supposed to check the return values from
> > debugfs functions. Debugfs functions never return NULL so this error
> > handling will never trigger. (Historically debugfs functions used to
> > return a mix of NULL and error pointers but it was eventually deemed too
> > complicated for something which wasn't intended to be used in normal
> > situations).
> >
> > Delete all the error handling.
> >
> > Signed-off-by: Dan Carpenter <[email protected]>
> > ---
> Looks good to me !!
>
> Acked-by: Santosh Shilimkar <[email protected]>

Thanks, applied.

Santosh,
Your email does not match one in ack. I understand this is just a
mistake so I put the ack. However the tool (b4-am) ignores such cases
so ack could be lost in the future.

Best regards,
Krzysztof