From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: linux-kernel@vger.kernel.org, cphealy@gmail.com,
Lucas Stach <l.stach@pengutronix.de>,
Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
Lee Jones <lee.jones@linaro.org>, Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor
Date: Thu, 31 Aug 2017 18:45:11 +0200 [thread overview]
Message-ID: <20170831164511.GA7247@kroah.com> (raw)
In-Reply-To: <20170828163131.24815-2-andrew.smirnov@gmail.com>
On Mon, Aug 28, 2017 at 09:31:30AM -0700, Andrey Smirnov wrote:
> +static int rave_sp_debugfs_create(struct rave_sp *sp)
> +{
> + struct dentry *file;
> +
> + sp->debugfs = debugfs_create_dir("rave", NULL);
> + if (!sp->debugfs)
> + return -ENOMEM;
Why do you care about the return value of the debugfs function? Hint,
you don't...
You should never care if debugfs failed, was built in, or succeeded,
your code should just do the same thing always. Any value returned from
a debugfs call can just be passed to another one, regardless of the
value returned from the first one.
So here, just save it, and don't check it.
> + file = debugfs_create_file("i2c_device_status", 0444,
> + sp->debugfs, sp,
> + &rave_sp_i2c_device_status);
> + if (!file)
> + goto error;
Nope, you don't care, just make the call.
> +
> + file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, part_number_firmware);
> + if (!file)
> + goto error;
Same for all of these.
> +
> + file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, part_number_bootloader);
> + if (!file)
> + goto error;
> +
> + file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, copper_rev_deb);
> + if (!file)
> + goto error;
> +
> + file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, copper_rev_rmb);
> + if (!file)
> + goto error;
> +
> + file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, copper_mod_deb);
> + if (!file)
> + goto error;
> +
> + file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, copper_mod_rmb);
> + if (!file)
> + goto error;
> +
> + file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, silicon_devrev);
> + if (!file)
> + goto error;
> +
> + file = RAVE_SP_DEBUGFS_CREATE_DEVM_SEQFILE(sp, silicon_devid);
> + if (!file)
> + goto error;
> +
> + return 0;
And your function can not fail, no need for this to return anything.
> +error:
> + debugfs_remove_recursive(sp->debugfs);
> + return -ENOMEM;
> +}
> +
> +static void rave_sp_degugfs_release(struct device *dev, void *res)
> +{
> + struct rave_sp *sp = *(struct rave_sp **)res;
> +
> + debugfs_remove_recursive(sp->debugfs);
> +}
> +
> +static int devm_rave_sp_debugfs_create(struct rave_sp *sp)
> +{
> + struct rave_sp **rcsp;
> + struct device *dev = &sp->serdev->dev;
> + int ret;
> +
> + rcsp = devres_alloc(rave_sp_degugfs_release, sizeof(*rcsp), GFP_KERNEL);
> + if (!rcsp)
> + return -ENOMEM;
> +
> + ret = rave_sp_debugfs_create(sp);
> + if (!ret) {
> + *rcsp = sp;
> + devres_add(dev, rcsp);
> + } else {
> + devres_free(rcsp);
> + }
You should not care what debugfs is doing, if it is working or not. So
no need to check here either.
debugfs was written to make it dirt-simple to use, I don't know why
people keep trying to put some error handling around it :)
thanks,
greg k-h
next prev parent reply other threads:[~2017-08-31 16:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-28 16:31 [PATCH v6 0/2] ZII RAVE platform driver Andrey Smirnov
2017-08-28 16:31 ` [PATCH v6 1/2] platform: Add driver for RAVE Supervisory Processor Andrey Smirnov
2017-08-30 10:55 ` Pavel Machek
2017-08-30 19:00 ` Andrey Smirnov
2017-08-30 20:38 ` Pavel Machek
2017-08-31 8:10 ` Nikita Yushchenko
2017-08-31 8:18 ` Pavel Machek
2017-08-31 9:01 ` Nikita Yushchenko
2017-08-31 9:15 ` Pavel Machek
2017-08-31 16:45 ` Greg Kroah-Hartman [this message]
2017-08-28 16:31 ` [PATCH v6 2/2] dt-bindings: mfd: Add bindings for ZII RAVE devices Andrey Smirnov
2017-09-04 7:52 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170831164511.GA7247@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=andrew.smirnov@gmail.com \
--cc=cphealy@gmail.com \
--cc=l.stach@pengutronix.de \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nikita.yoush@cogentembedded.com \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox