aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/devfreq/devfreq.c
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2012-10-24 16:00:12 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-14 18:36:10 -0500
commit0779726cc265805d0f7c7dd1d791fa4076b31a9a (patch)
treea43a115b9b701dfa275566002cc2ad3d227792fe /drivers/devfreq/devfreq.c
parent80126ce7aeb4e187429681ef8a7785b7dcd7a348 (diff)
PM / OPP: predictable fail results for opp_find* functions, v2
Currently the opp_find* functions return -ENODEV when: a) it cant find a device (e.g. request for an OPP search on device which was not registered) b) When it cant find a match for the search strategy used This makes life a little in-efficient for users such as devfreq to make reasonable judgement before switching search strategies. So, standardize the return results as following: -EINVAL for bad pointer parameters -ENODEV when device cannot be found -ERANGE when search fails This has the following benefit for devfreq implementation: The search fails when an unregistered device pointer is provided. This is a trigger to change the search direction and search for a better fit, however, if we cannot differentiate between a valid search range failure Vs an unregistered device, second search goes through the same fail return condition. This can be avoided by appropriate handling of error return code. With this change, we also fix devfreq for the improved search strategy with updated error code. Signed-off-by: Nishanth Menon <nm@ti.com> Reviewed-by: Kevin Hilman <khilman@ti.com> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/devfreq/devfreq.c')
-rw-r--r--drivers/devfreq/devfreq.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index b146d76f04cf..4fa1a22c55ea 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -656,14 +656,14 @@ struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq,
656 opp = opp_find_freq_floor(dev, freq); 656 opp = opp_find_freq_floor(dev, freq);
657 657
658 /* If not available, use the closest opp */ 658 /* If not available, use the closest opp */
659 if (opp == ERR_PTR(-ENODEV)) 659 if (opp == ERR_PTR(-ERANGE))
660 opp = opp_find_freq_ceil(dev, freq); 660 opp = opp_find_freq_ceil(dev, freq);
661 } else { 661 } else {
662 /* The freq is an lower bound. opp should be higher */ 662 /* The freq is an lower bound. opp should be higher */
663 opp = opp_find_freq_ceil(dev, freq); 663 opp = opp_find_freq_ceil(dev, freq);
664 664
665 /* If not available, use the closest opp */ 665 /* If not available, use the closest opp */
666 if (opp == ERR_PTR(-ENODEV)) 666 if (opp == ERR_PTR(-ERANGE))
667 opp = opp_find_freq_floor(dev, freq); 667 opp = opp_find_freq_floor(dev, freq);
668 } 668 }
669 669