Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 336741
b: refs/heads/master
c: 0779726
h: refs/heads/master
i:
  336739: fe34c54
v: v3
  • Loading branch information
Nishanth Menon authored and Rafael J. Wysocki committed Nov 14, 2012
1 parent fcebb45 commit 2de441d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 80126ce7aeb4e187429681ef8a7785b7dcd7a348
refs/heads/master: 0779726cc265805d0f7c7dd1d791fa4076b31a9a
27 changes: 19 additions & 8 deletions trunk/drivers/base/power/opp.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ EXPORT_SYMBOL(opp_get_opp_count);
*
* Searches for exact match in the opp list and returns pointer to the matching
* opp if found, else returns ERR_PTR in case of error and should be handled
* using IS_ERR.
* using IS_ERR. Error return values can be:
* EINVAL: for bad pointer
* ERANGE: no match found for search
* ENODEV: if device not found in list of registered devices
*
* Note: available is a modifier for the search. if available=true, then the
* match is for exact matching frequency and is available in the stored OPP
Expand All @@ -254,7 +257,7 @@ struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq,
bool available)
{
struct device_opp *dev_opp;
struct opp *temp_opp, *opp = ERR_PTR(-ENODEV);
struct opp *temp_opp, *opp = ERR_PTR(-ERANGE);

dev_opp = find_device_opp(dev);
if (IS_ERR(dev_opp)) {
Expand Down Expand Up @@ -284,7 +287,11 @@ EXPORT_SYMBOL(opp_find_freq_exact);
* for a device.
*
* Returns matching *opp and refreshes *freq accordingly, else returns
* ERR_PTR in case of error and should be handled using IS_ERR.
* ERR_PTR in case of error and should be handled using IS_ERR. Error return
* values can be:
* EINVAL: for bad pointer
* ERANGE: no match found for search
* ENODEV: if device not found in list of registered devices
*
* Locking: This function must be called under rcu_read_lock(). opp is a rcu
* protected pointer. The reason for the same is that the opp pointer which is
Expand All @@ -295,7 +302,7 @@ EXPORT_SYMBOL(opp_find_freq_exact);
struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq)
{
struct device_opp *dev_opp;
struct opp *temp_opp, *opp = ERR_PTR(-ENODEV);
struct opp *temp_opp, *opp = ERR_PTR(-ERANGE);

if (!dev || !freq) {
dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq);
Expand All @@ -304,7 +311,7 @@ struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq)

dev_opp = find_device_opp(dev);
if (IS_ERR(dev_opp))
return opp;
return ERR_CAST(dev_opp);

list_for_each_entry_rcu(temp_opp, &dev_opp->opp_list, node) {
if (temp_opp->available && temp_opp->rate >= *freq) {
Expand All @@ -327,7 +334,11 @@ EXPORT_SYMBOL(opp_find_freq_ceil);
* for a device.
*
* Returns matching *opp and refreshes *freq accordingly, else returns
* ERR_PTR in case of error and should be handled using IS_ERR.
* ERR_PTR in case of error and should be handled using IS_ERR. Error return
* values can be:
* EINVAL: for bad pointer
* ERANGE: no match found for search
* ENODEV: if device not found in list of registered devices
*
* Locking: This function must be called under rcu_read_lock(). opp is a rcu
* protected pointer. The reason for the same is that the opp pointer which is
Expand All @@ -338,7 +349,7 @@ EXPORT_SYMBOL(opp_find_freq_ceil);
struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq)
{
struct device_opp *dev_opp;
struct opp *temp_opp, *opp = ERR_PTR(-ENODEV);
struct opp *temp_opp, *opp = ERR_PTR(-ERANGE);

if (!dev || !freq) {
dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq);
Expand All @@ -347,7 +358,7 @@ struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq)

dev_opp = find_device_opp(dev);
if (IS_ERR(dev_opp))
return opp;
return ERR_CAST(dev_opp);

list_for_each_entry_rcu(temp_opp, &dev_opp->opp_list, node) {
if (temp_opp->available) {
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/devfreq/devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,14 +656,14 @@ struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq,
opp = opp_find_freq_floor(dev, freq);

/* If not available, use the closest opp */
if (opp == ERR_PTR(-ENODEV))
if (opp == ERR_PTR(-ERANGE))
opp = opp_find_freq_ceil(dev, freq);
} else {
/* The freq is an lower bound. opp should be higher */
opp = opp_find_freq_ceil(dev, freq);

/* If not available, use the closest opp */
if (opp == ERR_PTR(-ENODEV))
if (opp == ERR_PTR(-ERANGE))
opp = opp_find_freq_floor(dev, freq);
}

Expand Down

0 comments on commit 2de441d

Please sign in to comment.