linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: avs: smartreflex: no need to check return value of debugfs_create functions
@ 2019-06-11 18:05 Greg Kroah-Hartman
  2019-06-27 22:01 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-11 18:05 UTC (permalink / raw)
  To: Kevin Hilman, Nishanth Menon; +Cc: linux-pm

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.

And even when not checking the return value, no need to cast away the
call to (void), as these functions were never a "must check" type of a
function, so remove that odd cast.

Cc: Kevin Hilman <khilman@kernel.org>
Cc: Nishanth Menon <nm@ti.com>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/power/avs/smartreflex.c | 41 +++++++++------------------------
 1 file changed, 11 insertions(+), 30 deletions(-)

diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c
index c96c01e09740..4684e7df833a 100644
--- a/drivers/power/avs/smartreflex.c
+++ b/drivers/power/avs/smartreflex.c
@@ -899,38 +899,19 @@ static int omap_sr_probe(struct platform_device *pdev)
 	}
 
 	dev_info(&pdev->dev, "%s: SmartReflex driver initialized\n", __func__);
-	if (!sr_dbg_dir) {
+	if (!sr_dbg_dir)
 		sr_dbg_dir = debugfs_create_dir("smartreflex", NULL);
-		if (IS_ERR_OR_NULL(sr_dbg_dir)) {
-			ret = PTR_ERR(sr_dbg_dir);
-			pr_err("%s:sr debugfs dir creation failed(%d)\n",
-			       __func__, ret);
-			goto err_list_del;
-		}
-	}
 
 	sr_info->dbg_dir = debugfs_create_dir(sr_info->name, sr_dbg_dir);
-	if (IS_ERR_OR_NULL(sr_info->dbg_dir)) {
-		dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n",
-			__func__);
-		ret = PTR_ERR(sr_info->dbg_dir);
-		goto err_debugfs;
-	}
 
-	(void) debugfs_create_file("autocomp", S_IRUGO | S_IWUSR,
-			sr_info->dbg_dir, (void *)sr_info, &pm_sr_fops);
-	(void) debugfs_create_x32("errweight", S_IRUGO, sr_info->dbg_dir,
-			&sr_info->err_weight);
-	(void) debugfs_create_x32("errmaxlimit", S_IRUGO, sr_info->dbg_dir,
-			&sr_info->err_maxlimit);
+	debugfs_create_file("autocomp", S_IRUGO | S_IWUSR, sr_info->dbg_dir,
+			    (void *)sr_info, &pm_sr_fops);
+	debugfs_create_x32("errweight", S_IRUGO, sr_info->dbg_dir,
+			   &sr_info->err_weight);
+	debugfs_create_x32("errmaxlimit", S_IRUGO, sr_info->dbg_dir,
+			   &sr_info->err_maxlimit);
 
 	nvalue_dir = debugfs_create_dir("nvalue", sr_info->dbg_dir);
-	if (IS_ERR_OR_NULL(nvalue_dir)) {
-		dev_err(&pdev->dev, "%s: Unable to create debugfs directory for n-values\n",
-			__func__);
-		ret = PTR_ERR(nvalue_dir);
-		goto err_debugfs;
-	}
 
 	if (sr_info->nvalue_count == 0 || !sr_info->nvalue_table) {
 		dev_warn(&pdev->dev, "%s: %s: No Voltage table for the corresponding vdd. Cannot create debugfs entries for n-values\n",
@@ -945,12 +926,12 @@ static int omap_sr_probe(struct platform_device *pdev)
 
 		snprintf(name, sizeof(name), "volt_%lu",
 				sr_info->nvalue_table[i].volt_nominal);
-		(void) debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
-				&(sr_info->nvalue_table[i].nvalue));
+		debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
+				   &(sr_info->nvalue_table[i].nvalue));
 		snprintf(name, sizeof(name), "errminlimit_%lu",
 			 sr_info->nvalue_table[i].volt_nominal);
-		(void) debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
-				&(sr_info->nvalue_table[i].errminlimit));
+		debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
+				   &(sr_info->nvalue_table[i].errminlimit));
 
 	}
 
-- 
2.22.0


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

* Re: [PATCH] power: avs: smartreflex: no need to check return value of debugfs_create functions
  2019-06-11 18:05 [PATCH] power: avs: smartreflex: no need to check return value of debugfs_create functions Greg Kroah-Hartman
@ 2019-06-27 22:01 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2019-06-27 22:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Kevin Hilman, Nishanth Menon, linux-pm

On Tuesday, June 11, 2019 8:05:47 PM CEST 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.
> 
> And even when not checking the return value, no need to cast away the
> call to (void), as these functions were never a "must check" type of a
> function, so remove that odd cast.
> 
> Cc: Kevin Hilman <khilman@kernel.org>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/power/avs/smartreflex.c | 41 +++++++++------------------------
>  1 file changed, 11 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c
> index c96c01e09740..4684e7df833a 100644
> --- a/drivers/power/avs/smartreflex.c
> +++ b/drivers/power/avs/smartreflex.c
> @@ -899,38 +899,19 @@ static int omap_sr_probe(struct platform_device *pdev)
>  	}
>  
>  	dev_info(&pdev->dev, "%s: SmartReflex driver initialized\n", __func__);
> -	if (!sr_dbg_dir) {
> +	if (!sr_dbg_dir)
>  		sr_dbg_dir = debugfs_create_dir("smartreflex", NULL);
> -		if (IS_ERR_OR_NULL(sr_dbg_dir)) {
> -			ret = PTR_ERR(sr_dbg_dir);
> -			pr_err("%s:sr debugfs dir creation failed(%d)\n",
> -			       __func__, ret);
> -			goto err_list_del;
> -		}
> -	}
>  
>  	sr_info->dbg_dir = debugfs_create_dir(sr_info->name, sr_dbg_dir);
> -	if (IS_ERR_OR_NULL(sr_info->dbg_dir)) {
> -		dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n",
> -			__func__);
> -		ret = PTR_ERR(sr_info->dbg_dir);
> -		goto err_debugfs;
> -	}
>  
> -	(void) debugfs_create_file("autocomp", S_IRUGO | S_IWUSR,
> -			sr_info->dbg_dir, (void *)sr_info, &pm_sr_fops);
> -	(void) debugfs_create_x32("errweight", S_IRUGO, sr_info->dbg_dir,
> -			&sr_info->err_weight);
> -	(void) debugfs_create_x32("errmaxlimit", S_IRUGO, sr_info->dbg_dir,
> -			&sr_info->err_maxlimit);
> +	debugfs_create_file("autocomp", S_IRUGO | S_IWUSR, sr_info->dbg_dir,
> +			    (void *)sr_info, &pm_sr_fops);
> +	debugfs_create_x32("errweight", S_IRUGO, sr_info->dbg_dir,
> +			   &sr_info->err_weight);
> +	debugfs_create_x32("errmaxlimit", S_IRUGO, sr_info->dbg_dir,
> +			   &sr_info->err_maxlimit);
>  
>  	nvalue_dir = debugfs_create_dir("nvalue", sr_info->dbg_dir);
> -	if (IS_ERR_OR_NULL(nvalue_dir)) {
> -		dev_err(&pdev->dev, "%s: Unable to create debugfs directory for n-values\n",
> -			__func__);
> -		ret = PTR_ERR(nvalue_dir);
> -		goto err_debugfs;
> -	}
>  
>  	if (sr_info->nvalue_count == 0 || !sr_info->nvalue_table) {
>  		dev_warn(&pdev->dev, "%s: %s: No Voltage table for the corresponding vdd. Cannot create debugfs entries for n-values\n",
> @@ -945,12 +926,12 @@ static int omap_sr_probe(struct platform_device *pdev)
>  
>  		snprintf(name, sizeof(name), "volt_%lu",
>  				sr_info->nvalue_table[i].volt_nominal);
> -		(void) debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
> -				&(sr_info->nvalue_table[i].nvalue));
> +		debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
> +				   &(sr_info->nvalue_table[i].nvalue));
>  		snprintf(name, sizeof(name), "errminlimit_%lu",
>  			 sr_info->nvalue_table[i].volt_nominal);
> -		(void) debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
> -				&(sr_info->nvalue_table[i].errminlimit));
> +		debugfs_create_x32(name, S_IRUGO | S_IWUSR, nvalue_dir,
> +				   &(sr_info->nvalue_table[i].errminlimit));
>  
>  	}
>  
> 

Applied, thanks!





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

end of thread, other threads:[~2019-06-27 22:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-11 18:05 [PATCH] power: avs: smartreflex: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-06-27 22:01 ` Rafael J. Wysocki

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).