Re: [PATCH] opp: no need to check return value of debugfs_create functions

2019-01-22 Thread Viresh Kumar
On 22-01-19, 16:21, 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: Viresh Kumar 
> Cc: Nishanth Menon 
> Cc: Stephen Boyd 
> Cc: linux...@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  drivers/opp/core.c|  10 +---
>  drivers/opp/debugfs.c | 109 +++---
>  drivers/opp/opp.h |  15 +++---
>  3 files changed, 37 insertions(+), 97 deletions(-)

Applied with following changes. Thanks Greg.

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 91d15c58eae1..d455b84cce5a 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -793,7 +793,6 @@ static struct opp_device *_add_opp_dev_unlocked(const 
struct device *dev,
struct opp_table *opp_table)
 {
struct opp_device *opp_dev;
-   int ret;
 
opp_dev = kzalloc(sizeof(*opp_dev), GFP_KERNEL);
if (!opp_dev)
diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
index baac1ae33c55..a1c57fe14de4 100644
--- a/drivers/opp/debugfs.c
+++ b/drivers/opp/debugfs.c
@@ -93,7 +93,8 @@ void opp_debug_create_one(struct dev_pm_opp *opp, struct 
opp_table *opp_table)
debugfs_create_bool("suspend", S_IRUGO, d, >suspend);
debugfs_create_u32("performance_state", S_IRUGO, d, >pstate);
debugfs_create_ulong("rate_hz", S_IRUGO, d, >rate);
-   debugfs_create_ulong("clock_latency_ns", S_IRUGO, d, 
>clock_latency_ns);
+   debugfs_create_ulong("clock_latency_ns", S_IRUGO, d,
+>clock_latency_ns);
 
opp_debug_create_supplies(opp, opp_table, d);

-- 
viresh


Re: [PATCH] opp: no need to check return value of debugfs_create functions

2019-01-22 Thread Stephen Boyd
Quoting Greg Kroah-Hartman (2019-01-22 07:21:17)
> 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: Viresh Kumar 
> Cc: Nishanth Menon 
> Cc: Stephen Boyd 
> Cc: linux...@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman 
> ---

Reviewed-by: Stephen Boyd 



Re: [PATCH] opp: no need to check return value of debugfs_create functions

2019-01-22 Thread Rafael J. Wysocki
On Tue, Jan 22, 2019 at 4:28 PM 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: Viresh Kumar 
> Cc: Nishanth Menon 
> Cc: Stephen Boyd 
> Cc: linux...@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman 

Viresh, would you take this one, please?

> ---
>  drivers/opp/core.c|  10 +---
>  drivers/opp/debugfs.c | 109 +++---
>  drivers/opp/opp.h |  15 +++---
>  3 files changed, 37 insertions(+), 97 deletions(-)
>
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index 18f1639dbc4a..00b6b436a199 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -805,10 +805,7 @@ static struct opp_device *_add_opp_dev_unlocked(const 
> struct device *dev,
> list_add(_dev->node, _table->dev_list);
>
> /* Create debugfs entries for the opp_table */
> -   ret = opp_debug_register(opp_dev, opp_table);
> -   if (ret)
> -   dev_err(dev, "%s: Failed to register opp debugfs (%d)\n",
> -   __func__, ret);
> +   opp_debug_register(opp_dev, opp_table);
>
> return opp_dev;
>  }
> @@ -1229,10 +1226,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp 
> *new_opp,
> new_opp->opp_table = opp_table;
> kref_init(_opp->kref);
>
> -   ret = opp_debug_create_one(new_opp, opp_table);
> -   if (ret)
> -   dev_err(dev, "%s: Failed to register opp to debugfs (%d)\n",
> -   __func__, ret);
> +   opp_debug_create_one(new_opp, opp_table);
>
> if (!_opp_supported_by_regulators(new_opp, opp_table)) {
> new_opp->available = false;
> diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
> index e6828e5f81b0..baac1ae33c55 100644
> --- a/drivers/opp/debugfs.c
> +++ b/drivers/opp/debugfs.c
> @@ -35,7 +35,7 @@ void opp_debug_remove_one(struct dev_pm_opp *opp)
> debugfs_remove_recursive(opp->dentry);
>  }
>
> -static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
> +static void opp_debug_create_supplies(struct dev_pm_opp *opp,
>   struct opp_table *opp_table,
>   struct dentry *pdentry)
>  {
> @@ -50,30 +50,21 @@ static bool opp_debug_create_supplies(struct dev_pm_opp 
> *opp,
> /* Create per-opp directory */
> d = debugfs_create_dir(name, pdentry);
>
> -   if (!d)
> -   return false;
> +   debugfs_create_ulong("u_volt_target", S_IRUGO, d,
> +>supplies[i].u_volt);
>
> -   if (!debugfs_create_ulong("u_volt_target", S_IRUGO, d,
> - >supplies[i].u_volt))
> -   return false;
> +   debugfs_create_ulong("u_volt_min", S_IRUGO, d,
> +>supplies[i].u_volt_min);
>
> -   if (!debugfs_create_ulong("u_volt_min", S_IRUGO, d,
> - >supplies[i].u_volt_min))
> -   return false;
> +   debugfs_create_ulong("u_volt_max", S_IRUGO, d,
> +>supplies[i].u_volt_max);
>
> -   if (!debugfs_create_ulong("u_volt_max", S_IRUGO, d,
> - >supplies[i].u_volt_max))
> -   return false;
> -
> -   if (!debugfs_create_ulong("u_amp", S_IRUGO, d,
> - >supplies[i].u_amp))
> -   return false;
> +   debugfs_create_ulong("u_amp", S_IRUGO, d,
> +>supplies[i].u_amp);
> }
> -
> -   return true;
>  }
>
> -int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
> +void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table 
> *opp_table)
>  {
> struct dentry *pdentry = opp_table->dentry;
> struct dentry *d;
> @@ -95,40 +86,22 @@ int opp_debug_create_one(struct dev_pm_opp *opp, struct 
> opp_table *opp_table)
>
> /* Create per-opp directory */
> d = debugfs_create_dir(name, pdentry);
> -   if (!d)
> -   return -ENOMEM;
> -
> -   if (!debugfs_create_bool("available", S_IRUGO, d, >available))
> -   return -ENOMEM;
> -
> -   if (!debugfs_create_bool("dynamic", S_IRUGO, d, >dynamic))
> -   return -ENOMEM;
> -
> -   if (!debugfs_create_bool("turbo", S_IRUGO, d, >turbo))
> -   return -ENOMEM;
> -
> -   if (!debugfs_create_bool("suspend", S_IRUGO, d, >suspend))
> -   return -ENOMEM;
> -
> -   if (!debugfs_create_u32("performance_state", S_IRUGO, d, 
> >pstate))
> -   return -ENOMEM;
>
> -   if (!debugfs_create_ulong("rate_hz", S_IRUGO, 

[PATCH] opp: no need to check return value of debugfs_create functions

2019-01-22 Thread Greg Kroah-Hartman
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: Viresh Kumar 
Cc: Nishanth Menon 
Cc: Stephen Boyd 
Cc: linux...@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/opp/core.c|  10 +---
 drivers/opp/debugfs.c | 109 +++---
 drivers/opp/opp.h |  15 +++---
 3 files changed, 37 insertions(+), 97 deletions(-)

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 18f1639dbc4a..00b6b436a199 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -805,10 +805,7 @@ static struct opp_device *_add_opp_dev_unlocked(const 
struct device *dev,
list_add(_dev->node, _table->dev_list);
 
/* Create debugfs entries for the opp_table */
-   ret = opp_debug_register(opp_dev, opp_table);
-   if (ret)
-   dev_err(dev, "%s: Failed to register opp debugfs (%d)\n",
-   __func__, ret);
+   opp_debug_register(opp_dev, opp_table);
 
return opp_dev;
 }
@@ -1229,10 +1226,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp 
*new_opp,
new_opp->opp_table = opp_table;
kref_init(_opp->kref);
 
-   ret = opp_debug_create_one(new_opp, opp_table);
-   if (ret)
-   dev_err(dev, "%s: Failed to register opp to debugfs (%d)\n",
-   __func__, ret);
+   opp_debug_create_one(new_opp, opp_table);
 
if (!_opp_supported_by_regulators(new_opp, opp_table)) {
new_opp->available = false;
diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
index e6828e5f81b0..baac1ae33c55 100644
--- a/drivers/opp/debugfs.c
+++ b/drivers/opp/debugfs.c
@@ -35,7 +35,7 @@ void opp_debug_remove_one(struct dev_pm_opp *opp)
debugfs_remove_recursive(opp->dentry);
 }
 
-static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
+static void opp_debug_create_supplies(struct dev_pm_opp *opp,
  struct opp_table *opp_table,
  struct dentry *pdentry)
 {
@@ -50,30 +50,21 @@ static bool opp_debug_create_supplies(struct dev_pm_opp 
*opp,
/* Create per-opp directory */
d = debugfs_create_dir(name, pdentry);
 
-   if (!d)
-   return false;
+   debugfs_create_ulong("u_volt_target", S_IRUGO, d,
+>supplies[i].u_volt);
 
-   if (!debugfs_create_ulong("u_volt_target", S_IRUGO, d,
- >supplies[i].u_volt))
-   return false;
+   debugfs_create_ulong("u_volt_min", S_IRUGO, d,
+>supplies[i].u_volt_min);
 
-   if (!debugfs_create_ulong("u_volt_min", S_IRUGO, d,
- >supplies[i].u_volt_min))
-   return false;
+   debugfs_create_ulong("u_volt_max", S_IRUGO, d,
+>supplies[i].u_volt_max);
 
-   if (!debugfs_create_ulong("u_volt_max", S_IRUGO, d,
- >supplies[i].u_volt_max))
-   return false;
-
-   if (!debugfs_create_ulong("u_amp", S_IRUGO, d,
- >supplies[i].u_amp))
-   return false;
+   debugfs_create_ulong("u_amp", S_IRUGO, d,
+>supplies[i].u_amp);
}
-
-   return true;
 }
 
-int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
+void opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
 {
struct dentry *pdentry = opp_table->dentry;
struct dentry *d;
@@ -95,40 +86,22 @@ int opp_debug_create_one(struct dev_pm_opp *opp, struct 
opp_table *opp_table)
 
/* Create per-opp directory */
d = debugfs_create_dir(name, pdentry);
-   if (!d)
-   return -ENOMEM;
-
-   if (!debugfs_create_bool("available", S_IRUGO, d, >available))
-   return -ENOMEM;
-
-   if (!debugfs_create_bool("dynamic", S_IRUGO, d, >dynamic))
-   return -ENOMEM;
-
-   if (!debugfs_create_bool("turbo", S_IRUGO, d, >turbo))
-   return -ENOMEM;
-
-   if (!debugfs_create_bool("suspend", S_IRUGO, d, >suspend))
-   return -ENOMEM;
-
-   if (!debugfs_create_u32("performance_state", S_IRUGO, d, >pstate))
-   return -ENOMEM;
 
-   if (!debugfs_create_ulong("rate_hz", S_IRUGO, d, >rate))
-   return -ENOMEM;
+   debugfs_create_bool("available", S_IRUGO, d, >available);
+   debugfs_create_bool("dynamic", S_IRUGO, d, >dynamic);
+   debugfs_create_bool("turbo", S_IRUGO, d, >turbo);
+   debugfs_create_bool("suspend", S_IRUGO, d, >suspend);
+