Commit a2dea4cb authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Viresh Kumar

opp: no need to check return value of debugfs_create functions

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 <vireshk@kernel.org>
Cc: Nishanth Menon <nm@ti.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-pm@vger.kernel.org
Reviewed-by: default avatarStephen Boyd <sboyd@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent 1058d1ef
...@@ -792,7 +792,6 @@ static struct opp_device *_add_opp_dev_unlocked(const struct device *dev, ...@@ -792,7 +792,6 @@ static struct opp_device *_add_opp_dev_unlocked(const struct device *dev,
struct opp_table *opp_table) struct opp_table *opp_table)
{ {
struct opp_device *opp_dev; struct opp_device *opp_dev;
int ret;
opp_dev = kzalloc(sizeof(*opp_dev), GFP_KERNEL); opp_dev = kzalloc(sizeof(*opp_dev), GFP_KERNEL);
if (!opp_dev) if (!opp_dev)
...@@ -804,10 +803,7 @@ static struct opp_device *_add_opp_dev_unlocked(const struct device *dev, ...@@ -804,10 +803,7 @@ static struct opp_device *_add_opp_dev_unlocked(const struct device *dev,
list_add(&opp_dev->node, &opp_table->dev_list); list_add(&opp_dev->node, &opp_table->dev_list);
/* Create debugfs entries for the opp_table */ /* Create debugfs entries for the opp_table */
ret = opp_debug_register(opp_dev, opp_table); opp_debug_register(opp_dev, opp_table);
if (ret)
dev_err(dev, "%s: Failed to register opp debugfs (%d)\n",
__func__, ret);
return opp_dev; return opp_dev;
} }
...@@ -1175,10 +1171,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, ...@@ -1175,10 +1171,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp,
new_opp->opp_table = opp_table; new_opp->opp_table = opp_table;
kref_init(&new_opp->kref); kref_init(&new_opp->kref);
ret = opp_debug_create_one(new_opp, opp_table); opp_debug_create_one(new_opp, opp_table);
if (ret)
dev_err(dev, "%s: Failed to register opp to debugfs (%d)\n",
__func__, ret);
if (!_opp_supported_by_regulators(new_opp, opp_table)) { if (!_opp_supported_by_regulators(new_opp, opp_table)) {
new_opp->available = false; new_opp->available = false;
......
...@@ -35,7 +35,7 @@ void opp_debug_remove_one(struct dev_pm_opp *opp) ...@@ -35,7 +35,7 @@ void opp_debug_remove_one(struct dev_pm_opp *opp)
debugfs_remove_recursive(opp->dentry); 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 opp_table *opp_table,
struct dentry *pdentry) struct dentry *pdentry)
{ {
...@@ -50,30 +50,21 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp, ...@@ -50,30 +50,21 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
/* Create per-opp directory */ /* Create per-opp directory */
d = debugfs_create_dir(name, pdentry); d = debugfs_create_dir(name, pdentry);
if (!d) debugfs_create_ulong("u_volt_target", S_IRUGO, d,
return false; &opp->supplies[i].u_volt);
if (!debugfs_create_ulong("u_volt_target", S_IRUGO, d, debugfs_create_ulong("u_volt_min", S_IRUGO, d,
&opp->supplies[i].u_volt)) &opp->supplies[i].u_volt_min);
return false;
if (!debugfs_create_ulong("u_volt_min", S_IRUGO, d, debugfs_create_ulong("u_volt_max", S_IRUGO, d,
&opp->supplies[i].u_volt_min)) &opp->supplies[i].u_volt_max);
return false;
if (!debugfs_create_ulong("u_volt_max", S_IRUGO, d, debugfs_create_ulong("u_amp", S_IRUGO, d,
&opp->supplies[i].u_volt_max)) &opp->supplies[i].u_amp);
return false;
if (!debugfs_create_ulong("u_amp", S_IRUGO, d,
&opp->supplies[i].u_amp))
return false;
} }
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 *pdentry = opp_table->dentry;
struct dentry *d; struct dentry *d;
...@@ -95,40 +86,23 @@ int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table) ...@@ -95,40 +86,23 @@ int opp_debug_create_one(struct dev_pm_opp *opp, struct opp_table *opp_table)
/* Create per-opp directory */ /* Create per-opp directory */
d = debugfs_create_dir(name, pdentry); d = debugfs_create_dir(name, pdentry);
if (!d)
return -ENOMEM;
if (!debugfs_create_bool("available", S_IRUGO, d, &opp->available))
return -ENOMEM;
if (!debugfs_create_bool("dynamic", S_IRUGO, d, &opp->dynamic))
return -ENOMEM;
if (!debugfs_create_bool("turbo", S_IRUGO, d, &opp->turbo))
return -ENOMEM;
if (!debugfs_create_bool("suspend", S_IRUGO, d, &opp->suspend))
return -ENOMEM;
if (!debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate))
return -ENOMEM;
if (!debugfs_create_ulong("rate_hz", S_IRUGO, d, &opp->rate)) debugfs_create_bool("available", S_IRUGO, d, &opp->available);
return -ENOMEM; debugfs_create_bool("dynamic", S_IRUGO, d, &opp->dynamic);
debugfs_create_bool("turbo", S_IRUGO, d, &opp->turbo);
debugfs_create_bool("suspend", S_IRUGO, d, &opp->suspend);
debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate);
debugfs_create_ulong("rate_hz", S_IRUGO, d, &opp->rate);
debugfs_create_ulong("clock_latency_ns", S_IRUGO, d,
&opp->clock_latency_ns);
if (!opp_debug_create_supplies(opp, opp_table, d)) opp_debug_create_supplies(opp, opp_table, d);
return -ENOMEM;
if (!debugfs_create_ulong("clock_latency_ns", S_IRUGO, d,
&opp->clock_latency_ns))
return -ENOMEM;
opp->dentry = d; opp->dentry = d;
return 0;
} }
static int opp_list_debug_create_dir(struct opp_device *opp_dev, static void opp_list_debug_create_dir(struct opp_device *opp_dev,
struct opp_table *opp_table) struct opp_table *opp_table)
{ {
const struct device *dev = opp_dev->dev; const struct device *dev = opp_dev->dev;
struct dentry *d; struct dentry *d;
...@@ -137,36 +111,21 @@ static int opp_list_debug_create_dir(struct opp_device *opp_dev, ...@@ -137,36 +111,21 @@ static int opp_list_debug_create_dir(struct opp_device *opp_dev,
/* Create device specific directory */ /* Create device specific directory */
d = debugfs_create_dir(opp_table->dentry_name, rootdir); d = debugfs_create_dir(opp_table->dentry_name, rootdir);
if (!d) {
dev_err(dev, "%s: Failed to create debugfs dir\n", __func__);
return -ENOMEM;
}
opp_dev->dentry = d; opp_dev->dentry = d;
opp_table->dentry = d; opp_table->dentry = d;
return 0;
} }
static int opp_list_debug_create_link(struct opp_device *opp_dev, static void opp_list_debug_create_link(struct opp_device *opp_dev,
struct opp_table *opp_table) struct opp_table *opp_table)
{ {
const struct device *dev = opp_dev->dev;
char name[NAME_MAX]; char name[NAME_MAX];
struct dentry *d;
opp_set_dev_name(opp_dev->dev, name); opp_set_dev_name(opp_dev->dev, name);
/* Create device specific directory link */ /* Create device specific directory link */
d = debugfs_create_symlink(name, rootdir, opp_table->dentry_name); opp_dev->dentry = debugfs_create_symlink(name, rootdir,
if (!d) { opp_table->dentry_name);
dev_err(dev, "%s: Failed to create link\n", __func__);
return -ENOMEM;
}
opp_dev->dentry = d;
return 0;
} }
/** /**
...@@ -177,20 +136,13 @@ static int opp_list_debug_create_link(struct opp_device *opp_dev, ...@@ -177,20 +136,13 @@ static int opp_list_debug_create_link(struct opp_device *opp_dev,
* Dynamically adds device specific directory in debugfs 'opp' directory. If the * Dynamically adds device specific directory in debugfs 'opp' directory. If the
* device-opp is shared with other devices, then links will be created for all * device-opp is shared with other devices, then links will be created for all
* devices except the first. * devices except the first.
*
* Return: 0 on success, otherwise negative error.
*/ */
int opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table) void opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table)
{ {
if (!rootdir) {
pr_debug("%s: Uninitialized rootdir\n", __func__);
return -EINVAL;
}
if (opp_table->dentry) if (opp_table->dentry)
return opp_list_debug_create_link(opp_dev, opp_table); opp_list_debug_create_link(opp_dev, opp_table);
else
return opp_list_debug_create_dir(opp_dev, opp_table); opp_list_debug_create_dir(opp_dev, opp_table);
} }
static void opp_migrate_dentry(struct opp_device *opp_dev, static void opp_migrate_dentry(struct opp_device *opp_dev,
...@@ -252,10 +204,6 @@ static int __init opp_debug_init(void) ...@@ -252,10 +204,6 @@ static int __init opp_debug_init(void)
{ {
/* Create /sys/kernel/debug/opp directory */ /* Create /sys/kernel/debug/opp directory */
rootdir = debugfs_create_dir("opp", NULL); rootdir = debugfs_create_dir("opp", NULL);
if (!rootdir) {
pr_err("%s: Failed to create root directory\n", __func__);
return -ENOMEM;
}
return 0; return 0;
} }
......
...@@ -236,18 +236,17 @@ static inline void _of_opp_free_required_opps(struct opp_table *opp_table, ...@@ -236,18 +236,17 @@ static inline void _of_opp_free_required_opps(struct opp_table *opp_table,
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
void opp_debug_remove_one(struct dev_pm_opp *opp); void opp_debug_remove_one(struct dev_pm_opp *opp);
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);
int opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table); void opp_debug_register(struct opp_device *opp_dev, struct opp_table *opp_table);
void opp_debug_unregister(struct opp_device *opp_dev, struct opp_table *opp_table); void opp_debug_unregister(struct opp_device *opp_dev, struct opp_table *opp_table);
#else #else
static inline void opp_debug_remove_one(struct dev_pm_opp *opp) {} static inline void opp_debug_remove_one(struct dev_pm_opp *opp) {}
static inline int opp_debug_create_one(struct dev_pm_opp *opp, static inline void opp_debug_create_one(struct dev_pm_opp *opp,
struct opp_table *opp_table) struct opp_table *opp_table) { }
{ return 0; }
static inline int opp_debug_register(struct opp_device *opp_dev, static inline void opp_debug_register(struct opp_device *opp_dev,
struct opp_table *opp_table) struct opp_table *opp_table) { }
{ return 0; }
static inline void opp_debug_unregister(struct opp_device *opp_dev, static inline void opp_debug_unregister(struct opp_device *opp_dev,
struct opp_table *opp_table) struct opp_table *opp_table)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment