Commit 2c361684 authored by Ulf Hansson's avatar Ulf Hansson Committed by Rafael J. Wysocki

PM / Domains: Don't treat zero found compatible idle states as an error

Instead of returning -EINVAL from of_genpd_parse_idle_states() in case none
compatible states was found, let's return 0 to indicate success. Assign
also the out-parameter *states to NULL and *n to 0, to indicate to the
caller that zero states have been found/allocated.

This enables the caller of of_genpd_parse_idle_states() to easier act on
the returned error code.
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Reviewed-by: default avatarLina Iyer <ilina@codeaurora.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 35a7f35a
...@@ -2478,8 +2478,8 @@ static int genpd_iterate_idle_states(struct device_node *dn, ...@@ -2478,8 +2478,8 @@ static int genpd_iterate_idle_states(struct device_node *dn,
* *
* Returns the device states parsed from the OF node. The memory for the states * Returns the device states parsed from the OF node. The memory for the states
* is allocated by this function and is the responsibility of the caller to * is allocated by this function and is the responsibility of the caller to
* free the memory after use. If no domain idle states is found it returns * free the memory after use. If any or zero compatible domain idle states is
* -EINVAL and in case of errors, a negative error code. * found it returns 0 and in case of errors, a negative error code is returned.
*/ */
int of_genpd_parse_idle_states(struct device_node *dn, int of_genpd_parse_idle_states(struct device_node *dn,
struct genpd_power_state **states, int *n) struct genpd_power_state **states, int *n)
...@@ -2488,8 +2488,14 @@ int of_genpd_parse_idle_states(struct device_node *dn, ...@@ -2488,8 +2488,14 @@ int of_genpd_parse_idle_states(struct device_node *dn,
int ret; int ret;
ret = genpd_iterate_idle_states(dn, NULL); ret = genpd_iterate_idle_states(dn, NULL);
if (ret <= 0) if (ret < 0)
return ret < 0 ? ret : -EINVAL; return ret;
if (!ret) {
*states = NULL;
*n = 0;
return 0;
}
st = kcalloc(ret, sizeof(*st), GFP_KERNEL); st = kcalloc(ret, sizeof(*st), GFP_KERNEL);
if (!st) if (!st)
......
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