dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Jarzmik <robert.jarzmik@free.fr>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: dan.j.williams@intel.com, vkoul@kernel.org,
	Daniel Mack <daniel@zonque.org>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/6] dma: pxa_dma: no need to check return value of debugfs_create functions
Date: Sat, 10 Aug 2019 21:27:26 +0200	[thread overview]
Message-ID: <87tvaorfc1.fsf@belgarion.home> (raw)
In-Reply-To: <20190612122557.24158-4-gregkh@linuxfoundation.org> (Greg Kroah-Hartman's message of "Wed, 12 Jun 2019 14:25:55 +0200")

Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:

Hi Greg,

> 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.
>
> Also, because there is no need to save the file dentry, remove the
> variable that was saving it as it was never even being used once set.
>
> Cc: Daniel Mack <daniel@zonque.org>
> Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
> Cc: Robert Jarzmik <robert.jarzmik@free.fr>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: dmaengine@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/dma/pxa_dma.c | 56 +++++++++----------------------------------
>  1 file changed, 11 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
> index b429642f3e7a..0f698f49ee26 100644
> --- a/drivers/dma/pxa_dma.c
> +++ b/drivers/dma/pxa_dma.c
> @@ -132,7 +132,6 @@ struct pxad_device {
>  	spinlock_t			phy_lock;	/* Phy association */
>  #ifdef CONFIG_DEBUG_FS
>  	struct dentry			*dbgfs_root;
> -	struct dentry			*dbgfs_state;
>  	struct dentry			**dbgfs_chan;
>  #endif
>  };
> @@ -326,31 +325,18 @@ static struct dentry *pxad_dbg_alloc_chan(struct pxad_device *pdev,
>  					     int ch, struct dentry *chandir)
>  {
>  	char chan_name[11];
> -	struct dentry *chan, *chan_state = NULL, *chan_descr = NULL;
> -	struct dentry *chan_reqs = NULL;
> +	struct dentry *chan;
>  	void *dt;
>  
>  	scnprintf(chan_name, sizeof(chan_name), "%d", ch);
>  	chan = debugfs_create_dir(chan_name, chandir);
>  	dt = (void *)&pdev->phys[ch];
>  
> -	if (chan)
> -		chan_state = debugfs_create_file("state", 0400, chan, dt,
> -						 &chan_state_fops);
> -	if (chan_state)
> -		chan_descr = debugfs_create_file("descriptors", 0400, chan, dt,
> -						 &descriptors_fops);
> -	if (chan_descr)
> -		chan_reqs = debugfs_create_file("requesters", 0400, chan, dt,
> -						&requester_chan_fops);
> -	if (!chan_reqs)
> -		goto err_state;
> +	debugfs_create_file("state", 0400, chan, dt, &chan_state_fops);
> +	debugfs_create_file("descriptors", 0400, chan, dt, &descriptors_fops);
> +	debugfs_create_file("requesters", 0400, chan, dt, &requester_chan_fops);

This is not strictly equivalent.
Imagine that the debugfs_create_dir() fails and returns NULL :
 - in the former case, neither "state", "descriptors" nor "requesters" would be
   created
 - in the new code, "state", "descriptors" nor "requesters" will be created in
   the debugfs root directory

Apart from that it looks fine.

Cheers.

-- 
Robert

  reply	other threads:[~2019-08-10 19:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 12:25 [PATCH 1/6] dma: amba-pl08x: no need to cast away call to debugfs_create_file() Greg Kroah-Hartman
2019-06-12 12:25 ` [PATCH 2/6] dma: bcm-sba-raid: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-06-12 12:25 ` [PATCH 3/6] dma: coh901318: no need to cast away call to debugfs_create_file() Greg Kroah-Hartman
2019-06-12 12:42   ` Linus Walleij
2019-06-12 12:25 ` [PATCH 4/6] dma: pxa_dma: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-08-10 19:27   ` Robert Jarzmik [this message]
2019-08-11  7:03     ` Greg Kroah-Hartman
2019-08-13 21:21       ` Robert Jarzmik
2019-06-12 12:25 ` [PATCH 5/6] dma: mic_x100_dma: " Greg Kroah-Hartman
2019-06-12 15:44   ` Sudeep Dutt
2019-06-12 12:25 ` [PATCH 6/6] dma: qcom: hidma: " Greg Kroah-Hartman
2019-06-12 15:24   ` Sinan Kaya
2019-06-12 15:39     ` Greg Kroah-Hartman
2019-06-12 16:17       ` Sinan Kaya
2019-06-12 16:47         ` Greg Kroah-Hartman
2019-06-14  5:46 ` [PATCH 1/6] dma: amba-pl08x: no need to cast away call to debugfs_create_file() Vinod Koul
2019-06-14  5:55   ` Greg Kroah-Hartman
2019-06-18 16:00   ` Greg Kroah-Hartman

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=87tvaorfc1.fsf@belgarion.home \
    --to=robert.jarzmik@free.fr \
    --cc=dan.j.williams@intel.com \
    --cc=daniel@zonque.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=haojian.zhuang@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).