All of lore.kernel.org
 help / color / mirror / Atom feed
* [13/22] USB: chipidea: no need to check return value of debugfs_create functions
@ 2018-05-30  1:58 Peter Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Chen @ 2018-05-30  1:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-usb

> 
> 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: Peter Chen <Peter.Chen@nxp.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Tested on imx6sx-sdb board.

Acked-by: Peter Chen <peter.chen@nxp.com>

> ---
>  drivers/usb/chipidea/ci.h    |  2 +-
>  drivers/usb/chipidea/core.c  |  4 +--
>  drivers/usb/chipidea/debug.c | 56 ++++++++++--------------------------
>  3 files changed, 17 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index
> 98b7cb3d0064..0bf244d50544 100644
> --- a/drivers/usb/chipidea/ci.h
> +++ b/drivers/usb/chipidea/ci.h
> @@ -450,7 +450,7 @@ void hw_phymode_configure(struct ci_hdrc *ci);
> 
>  void ci_platform_configure(struct ci_hdrc *ci);
> 
> -int dbg_create_files(struct ci_hdrc *ci);
> +void dbg_create_files(struct ci_hdrc *ci);
> 
>  void dbg_remove_files(struct ci_hdrc *ci);
>  #endif	/* __DRIVERS_USB_CHIPIDEA_CI_H */
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index
> 33ae87fa3ff3..85fc6db48e44 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -1062,9 +1062,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
>  		ci_hdrc_otg_fsm_start(ci);
> 
>  	device_set_wakeup_capable(&pdev->dev, true);
> -	ret = dbg_create_files(ci);
> -	if (ret)
> -		goto stop;
> +	dbg_create_files(ci);
> 
>  	ret = sysfs_create_group(&dev->kobj, &ci_attr_group);
>  	if (ret)
> diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index
> ce648cb3ed94..fcc91a338875 100644
> --- a/drivers/usb/chipidea/debug.c
> +++ b/drivers/usb/chipidea/debug.c
> @@ -340,54 +340,28 @@ DEFINE_SHOW_ATTRIBUTE(ci_registers);
>   *
>   * This function returns an error code
>   */
> -int dbg_create_files(struct ci_hdrc *ci)
> +void dbg_create_files(struct ci_hdrc *ci)
>  {
> -	struct dentry *dent;
> -
>  	ci->debugfs = debugfs_create_dir(dev_name(ci->dev), NULL);
> -	if (!ci->debugfs)
> -		return -ENOMEM;
> -
> -	dent = debugfs_create_file("device", S_IRUGO, ci->debugfs, ci,
> -				   &ci_device_fops);
> -	if (!dent)
> -		goto err;
> -
> -	dent = debugfs_create_file("port_test", S_IRUGO | S_IWUSR, ci->debugfs,
> -				   ci, &ci_port_test_fops);
> -	if (!dent)
> -		goto err;
> -
> -	dent = debugfs_create_file("qheads", S_IRUGO, ci->debugfs, ci,
> -				   &ci_qheads_fops);
> -	if (!dent)
> -		goto err;
> 
> -	dent = debugfs_create_file("requests", S_IRUGO, ci->debugfs, ci,
> -				   &ci_requests_fops);
> -	if (!dent)
> -		goto err;
> +	debugfs_create_file("device", S_IRUGO, ci->debugfs, ci,
> +			    &ci_device_fops);
> +	debugfs_create_file("port_test", S_IRUGO | S_IWUSR, ci->debugfs, ci,
> +			    &ci_port_test_fops);
> +	debugfs_create_file("qheads", S_IRUGO, ci->debugfs, ci,
> +			    &ci_qheads_fops);
> +	debugfs_create_file("requests", S_IRUGO, ci->debugfs, ci,
> +			    &ci_requests_fops);
> 
>  	if (ci_otg_is_fsm_mode(ci)) {
> -		dent = debugfs_create_file("otg", S_IRUGO, ci->debugfs, ci,
> -					&ci_otg_fops);
> -		if (!dent)
> -			goto err;
> +		debugfs_create_file("otg", S_IRUGO, ci->debugfs, ci,
> +				    &ci_otg_fops);
>  	}
> 
> -	dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci,
> -				   &ci_role_fops);
> -	if (!dent)
> -		goto err;
> -
> -	dent = debugfs_create_file("registers", S_IRUGO, ci->debugfs, ci,
> -				&ci_registers_fops);
> -
> -	if (dent)
> -		return 0;
> -err:
> -	debugfs_remove_recursive(ci->debugfs);
> -	return -ENOMEM;
> +	debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci,
> +			    &ci_role_fops);
> +	debugfs_create_file("registers", S_IRUGO, ci->debugfs, ci,
> +			    &ci_registers_fops);
>  }
> 
>  /**
> --
> 2.17.0
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [13/22] USB: chipidea: no need to check return value of debugfs_create functions
@ 2018-05-31 10:48 Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2018-05-31 10:48 UTC (permalink / raw)
  To: Peter Chen; +Cc: linux-usb

On Wed, May 30, 2018 at 01:58:18AM +0000, Peter Chen 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: Peter Chen <Peter.Chen@nxp.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> Tested on imx6sx-sdb board.
> 
> Acked-by: Peter Chen <peter.chen@nxp.com>

Thanks for testing!
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [13/22] USB: chipidea: no need to check return value of debugfs_create functions
@ 2018-05-29 15:30 Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2018-05-29 15:30 UTC (permalink / raw)
  To: linux-usb; +Cc: Greg Kroah-Hartman, Peter Chen

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: Peter Chen <Peter.Chen@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/chipidea/ci.h    |  2 +-
 drivers/usb/chipidea/core.c  |  4 +--
 drivers/usb/chipidea/debug.c | 56 ++++++++++--------------------------
 3 files changed, 17 insertions(+), 45 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 98b7cb3d0064..0bf244d50544 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -450,7 +450,7 @@ void hw_phymode_configure(struct ci_hdrc *ci);
 
 void ci_platform_configure(struct ci_hdrc *ci);
 
-int dbg_create_files(struct ci_hdrc *ci);
+void dbg_create_files(struct ci_hdrc *ci);
 
 void dbg_remove_files(struct ci_hdrc *ci);
 #endif	/* __DRIVERS_USB_CHIPIDEA_CI_H */
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 33ae87fa3ff3..85fc6db48e44 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -1062,9 +1062,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 		ci_hdrc_otg_fsm_start(ci);
 
 	device_set_wakeup_capable(&pdev->dev, true);
-	ret = dbg_create_files(ci);
-	if (ret)
-		goto stop;
+	dbg_create_files(ci);
 
 	ret = sysfs_create_group(&dev->kobj, &ci_attr_group);
 	if (ret)
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index ce648cb3ed94..fcc91a338875 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -340,54 +340,28 @@ DEFINE_SHOW_ATTRIBUTE(ci_registers);
  *
  * This function returns an error code
  */
-int dbg_create_files(struct ci_hdrc *ci)
+void dbg_create_files(struct ci_hdrc *ci)
 {
-	struct dentry *dent;
-
 	ci->debugfs = debugfs_create_dir(dev_name(ci->dev), NULL);
-	if (!ci->debugfs)
-		return -ENOMEM;
-
-	dent = debugfs_create_file("device", S_IRUGO, ci->debugfs, ci,
-				   &ci_device_fops);
-	if (!dent)
-		goto err;
-
-	dent = debugfs_create_file("port_test", S_IRUGO | S_IWUSR, ci->debugfs,
-				   ci, &ci_port_test_fops);
-	if (!dent)
-		goto err;
-
-	dent = debugfs_create_file("qheads", S_IRUGO, ci->debugfs, ci,
-				   &ci_qheads_fops);
-	if (!dent)
-		goto err;
 
-	dent = debugfs_create_file("requests", S_IRUGO, ci->debugfs, ci,
-				   &ci_requests_fops);
-	if (!dent)
-		goto err;
+	debugfs_create_file("device", S_IRUGO, ci->debugfs, ci,
+			    &ci_device_fops);
+	debugfs_create_file("port_test", S_IRUGO | S_IWUSR, ci->debugfs, ci,
+			    &ci_port_test_fops);
+	debugfs_create_file("qheads", S_IRUGO, ci->debugfs, ci,
+			    &ci_qheads_fops);
+	debugfs_create_file("requests", S_IRUGO, ci->debugfs, ci,
+			    &ci_requests_fops);
 
 	if (ci_otg_is_fsm_mode(ci)) {
-		dent = debugfs_create_file("otg", S_IRUGO, ci->debugfs, ci,
-					&ci_otg_fops);
-		if (!dent)
-			goto err;
+		debugfs_create_file("otg", S_IRUGO, ci->debugfs, ci,
+				    &ci_otg_fops);
 	}
 
-	dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci,
-				   &ci_role_fops);
-	if (!dent)
-		goto err;
-
-	dent = debugfs_create_file("registers", S_IRUGO, ci->debugfs, ci,
-				&ci_registers_fops);
-
-	if (dent)
-		return 0;
-err:
-	debugfs_remove_recursive(ci->debugfs);
-	return -ENOMEM;
+	debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci,
+			    &ci_role_fops);
+	debugfs_create_file("registers", S_IRUGO, ci->debugfs, ci,
+			    &ci_registers_fops);
 }
 
 /**

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-31 10:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-30  1:58 [13/22] USB: chipidea: no need to check return value of debugfs_create functions Peter Chen
  -- strict thread matches above, loose matches on Subject: below --
2018-05-31 10:48 Greg Kroah-Hartman
2018-05-29 15:30 Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.