diff mbox series

[2/4] mmc: host: atmel-mci: no need to check return value of debugfs_create functions

Message ID 20190612082531.2652-2-gregkh@linuxfoundation.org (mailing list archive)
State New, archived
Headers show
Series [1/4] mmc: core: no need to check return value of debugfs_create functions | expand

Commit Message

Greg Kroah-Hartman June 12, 2019, 8:25 a.m. UTC
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: Ludovic Desroches <ludovic.desroches@microchip.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/mmc/host/atmel-mci.c | 38 +++++++-----------------------------
 1 file changed, 7 insertions(+), 31 deletions(-)

Comments

Alexandre Belloni June 12, 2019, 8:30 a.m. UTC | #1
On 12/06/2019 10:25:29+0200, 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: Ludovic Desroches <ludovic.desroches@microchip.com>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: <linux-mmc@vger.kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/mmc/host/atmel-mci.c | 38 +++++++-----------------------------
>  1 file changed, 7 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 735aa5871358..e1f10c3fa144 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -579,42 +579,18 @@ static void atmci_init_debugfs(struct atmel_mci_slot *slot)
>  	struct mmc_host		*mmc = slot->mmc;
>  	struct atmel_mci	*host = slot->host;
>  	struct dentry		*root;
> -	struct dentry		*node;
>  
>  	root = mmc->debugfs_root;
>  	if (!root)
>  		return;
>  
> -	node = debugfs_create_file("regs", S_IRUSR, root, host,
> -				   &atmci_regs_fops);
> -	if (IS_ERR(node))
> -		return;
> -	if (!node)
> -		goto err;
> -
> -	node = debugfs_create_file("req", S_IRUSR, root, slot,
> -				   &atmci_req_fops);
> -	if (!node)
> -		goto err;
> -
> -	node = debugfs_create_u32("state", S_IRUSR, root, (u32 *)&host->state);
> -	if (!node)
> -		goto err;
> -
> -	node = debugfs_create_x32("pending_events", S_IRUSR, root,
> -				     (u32 *)&host->pending_events);
> -	if (!node)
> -		goto err;
> -
> -	node = debugfs_create_x32("completed_events", S_IRUSR, root,
> -				     (u32 *)&host->completed_events);
> -	if (!node)
> -		goto err;
> -
> -	return;
> -
> -err:
> -	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
> +	debugfs_create_file("regs", S_IRUSR, root, host, &atmci_regs_fops);
> +	debugfs_create_file("req", S_IRUSR, root, slot, &atmci_req_fops);
> +	debugfs_create_u32("state", S_IRUSR, root, (u32 *)&host->state);
> +	debugfs_create_x32("pending_events", S_IRUSR, root,
> +			   (u32 *)&host->pending_events);
> +	debugfs_create_x32("completed_events", S_IRUSR, root,
> +			   (u32 *)&host->completed_events);
>  }
>  
>  #if defined(CONFIG_OF)
> -- 
> 2.22.0
>
Ludovic Desroches June 12, 2019, 2:12 p.m. UTC | #2
On Wed, Jun 12, 2019 at 10:30:08AM +0200, Alexandre Belloni wrote:
> External E-Mail
> 
> 
> On 12/06/2019 10:25:29+0200, 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: Ludovic Desroches <ludovic.desroches@microchip.com>
> > Cc: Ulf Hansson <ulf.hansson@linaro.org>
> > Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: <linux-mmc@vger.kernel.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com> 

Thanks

> 
> > ---
> >  drivers/mmc/host/atmel-mci.c | 38 +++++++-----------------------------
> >  1 file changed, 7 insertions(+), 31 deletions(-)
> > 
> > diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> > index 735aa5871358..e1f10c3fa144 100644
> > --- a/drivers/mmc/host/atmel-mci.c
> > +++ b/drivers/mmc/host/atmel-mci.c
> > @@ -579,42 +579,18 @@ static void atmci_init_debugfs(struct atmel_mci_slot *slot)
> >  	struct mmc_host		*mmc = slot->mmc;
> >  	struct atmel_mci	*host = slot->host;
> >  	struct dentry		*root;
> > -	struct dentry		*node;
> >  
> >  	root = mmc->debugfs_root;
> >  	if (!root)
> >  		return;
> >  
> > -	node = debugfs_create_file("regs", S_IRUSR, root, host,
> > -				   &atmci_regs_fops);
> > -	if (IS_ERR(node))
> > -		return;
> > -	if (!node)
> > -		goto err;
> > -
> > -	node = debugfs_create_file("req", S_IRUSR, root, slot,
> > -				   &atmci_req_fops);
> > -	if (!node)
> > -		goto err;
> > -
> > -	node = debugfs_create_u32("state", S_IRUSR, root, (u32 *)&host->state);
> > -	if (!node)
> > -		goto err;
> > -
> > -	node = debugfs_create_x32("pending_events", S_IRUSR, root,
> > -				     (u32 *)&host->pending_events);
> > -	if (!node)
> > -		goto err;
> > -
> > -	node = debugfs_create_x32("completed_events", S_IRUSR, root,
> > -				     (u32 *)&host->completed_events);
> > -	if (!node)
> > -		goto err;
> > -
> > -	return;
> > -
> > -err:
> > -	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
> > +	debugfs_create_file("regs", S_IRUSR, root, host, &atmci_regs_fops);
> > +	debugfs_create_file("req", S_IRUSR, root, slot, &atmci_req_fops);
> > +	debugfs_create_u32("state", S_IRUSR, root, (u32 *)&host->state);
> > +	debugfs_create_x32("pending_events", S_IRUSR, root,
> > +			   (u32 *)&host->pending_events);
> > +	debugfs_create_x32("completed_events", S_IRUSR, root,
> > +			   (u32 *)&host->completed_events);
> >  }
> >  
> >  #if defined(CONFIG_OF)
> > -- 
> > 2.22.0
> > 
> 
> -- 
> Alexandre Belloni, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
diff mbox series

Patch

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 735aa5871358..e1f10c3fa144 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -579,42 +579,18 @@  static void atmci_init_debugfs(struct atmel_mci_slot *slot)
 	struct mmc_host		*mmc = slot->mmc;
 	struct atmel_mci	*host = slot->host;
 	struct dentry		*root;
-	struct dentry		*node;
 
 	root = mmc->debugfs_root;
 	if (!root)
 		return;
 
-	node = debugfs_create_file("regs", S_IRUSR, root, host,
-				   &atmci_regs_fops);
-	if (IS_ERR(node))
-		return;
-	if (!node)
-		goto err;
-
-	node = debugfs_create_file("req", S_IRUSR, root, slot,
-				   &atmci_req_fops);
-	if (!node)
-		goto err;
-
-	node = debugfs_create_u32("state", S_IRUSR, root, (u32 *)&host->state);
-	if (!node)
-		goto err;
-
-	node = debugfs_create_x32("pending_events", S_IRUSR, root,
-				     (u32 *)&host->pending_events);
-	if (!node)
-		goto err;
-
-	node = debugfs_create_x32("completed_events", S_IRUSR, root,
-				     (u32 *)&host->completed_events);
-	if (!node)
-		goto err;
-
-	return;
-
-err:
-	dev_err(&mmc->class_dev, "failed to initialize debugfs for slot\n");
+	debugfs_create_file("regs", S_IRUSR, root, host, &atmci_regs_fops);
+	debugfs_create_file("req", S_IRUSR, root, slot, &atmci_req_fops);
+	debugfs_create_u32("state", S_IRUSR, root, (u32 *)&host->state);
+	debugfs_create_x32("pending_events", S_IRUSR, root,
+			   (u32 *)&host->pending_events);
+	debugfs_create_x32("completed_events", S_IRUSR, root,
+			   (u32 *)&host->completed_events);
 }
 
 #if defined(CONFIG_OF)