Skip to content

Commit

Permalink
PM / Domains: Don't treat zero found compatible idle states as an error
Browse files Browse the repository at this point in the history
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: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Lina Iyer <ilina@codeaurora.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Ulf Hansson authored and Rafael J. Wysocki committed Oct 18, 2018
1 parent 35a7f35 commit 2c36168
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
* 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
* -EINVAL and in case of errors, a negative error code.
* free the memory after use. If any or zero compatible domain idle states is
* 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,
struct genpd_power_state **states, int *n)
Expand All @@ -2488,8 +2488,14 @@ int of_genpd_parse_idle_states(struct device_node *dn,
int ret;

ret = genpd_iterate_idle_states(dn, NULL);
if (ret <= 0)
return ret < 0 ? ret : -EINVAL;
if (ret < 0)
return ret;

if (!ret) {
*states = NULL;
*n = 0;
return 0;
}

st = kcalloc(ret, sizeof(*st), GFP_KERNEL);
if (!st)
Expand Down

0 comments on commit 2c36168

Please sign in to comment.