OPP: Use generic key finding helpers for bandwidth key
Use the recently added generic key findings helpers to find bandwidth key values. Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
parent
c2ab2cb637
commit
add1dc094a
1 changed files with 15 additions and 68 deletions
|
@ -438,6 +438,11 @@ static unsigned long _read_level(struct dev_pm_opp *opp, int index)
|
||||||
return opp->level;
|
return opp->level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned long _read_bw(struct dev_pm_opp *opp, int index)
|
||||||
|
{
|
||||||
|
return opp->bandwidth[index].peak;
|
||||||
|
}
|
||||||
|
|
||||||
/* Generic comparison helpers */
|
/* Generic comparison helpers */
|
||||||
static bool _compare_exact(struct dev_pm_opp **opp, struct dev_pm_opp *temp_opp,
|
static bool _compare_exact(struct dev_pm_opp **opp, struct dev_pm_opp *temp_opp,
|
||||||
unsigned long opp_key, unsigned long key)
|
unsigned long opp_key, unsigned long key)
|
||||||
|
@ -711,42 +716,14 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_ceil);
|
||||||
* The callers are required to call dev_pm_opp_put() for the returned OPP after
|
* The callers are required to call dev_pm_opp_put() for the returned OPP after
|
||||||
* use.
|
* use.
|
||||||
*/
|
*/
|
||||||
struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
|
struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev, unsigned int *bw,
|
||||||
unsigned int *bw, int index)
|
int index)
|
||||||
{
|
{
|
||||||
struct opp_table *opp_table;
|
unsigned long temp = *bw;
|
||||||
struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
|
struct dev_pm_opp *opp;
|
||||||
|
|
||||||
if (!dev || !bw) {
|
|
||||||
dev_err(dev, "%s: Invalid argument bw=%p\n", __func__, bw);
|
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
opp_table = _find_opp_table(dev);
|
|
||||||
if (IS_ERR(opp_table))
|
|
||||||
return ERR_CAST(opp_table);
|
|
||||||
|
|
||||||
if (index >= opp_table->path_count)
|
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
|
|
||||||
mutex_lock(&opp_table->lock);
|
|
||||||
|
|
||||||
list_for_each_entry(temp_opp, &opp_table->opp_list, node) {
|
|
||||||
if (temp_opp->available && temp_opp->bandwidth) {
|
|
||||||
if (temp_opp->bandwidth[index].peak >= *bw) {
|
|
||||||
opp = temp_opp;
|
|
||||||
*bw = opp->bandwidth[index].peak;
|
|
||||||
|
|
||||||
/* Increment the reference count of OPP */
|
|
||||||
dev_pm_opp_get(opp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_unlock(&opp_table->lock);
|
|
||||||
dev_pm_opp_put_opp_table(opp_table);
|
|
||||||
|
|
||||||
|
opp = _find_key_ceil(dev, &temp, index, true, _read_bw);
|
||||||
|
*bw = temp;
|
||||||
return opp;
|
return opp;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(dev_pm_opp_find_bw_ceil);
|
EXPORT_SYMBOL_GPL(dev_pm_opp_find_bw_ceil);
|
||||||
|
@ -773,41 +750,11 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_bw_ceil);
|
||||||
struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev,
|
struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev,
|
||||||
unsigned int *bw, int index)
|
unsigned int *bw, int index)
|
||||||
{
|
{
|
||||||
struct opp_table *opp_table;
|
unsigned long temp = *bw;
|
||||||
struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
|
struct dev_pm_opp *opp;
|
||||||
|
|
||||||
if (!dev || !bw) {
|
|
||||||
dev_err(dev, "%s: Invalid argument bw=%p\n", __func__, bw);
|
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
opp_table = _find_opp_table(dev);
|
|
||||||
if (IS_ERR(opp_table))
|
|
||||||
return ERR_CAST(opp_table);
|
|
||||||
|
|
||||||
if (index >= opp_table->path_count)
|
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
|
|
||||||
mutex_lock(&opp_table->lock);
|
|
||||||
|
|
||||||
list_for_each_entry(temp_opp, &opp_table->opp_list, node) {
|
|
||||||
if (temp_opp->available && temp_opp->bandwidth) {
|
|
||||||
/* go to the next node, before choosing prev */
|
|
||||||
if (temp_opp->bandwidth[index].peak > *bw)
|
|
||||||
break;
|
|
||||||
opp = temp_opp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Increment the reference count of OPP */
|
|
||||||
if (!IS_ERR(opp))
|
|
||||||
dev_pm_opp_get(opp);
|
|
||||||
mutex_unlock(&opp_table->lock);
|
|
||||||
dev_pm_opp_put_opp_table(opp_table);
|
|
||||||
|
|
||||||
if (!IS_ERR(opp))
|
|
||||||
*bw = opp->bandwidth[index].peak;
|
|
||||||
|
|
||||||
|
opp = _find_key_floor(dev, &temp, index, true, _read_bw);
|
||||||
|
*bw = temp;
|
||||||
return opp;
|
return opp;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(dev_pm_opp_find_bw_floor);
|
EXPORT_SYMBOL_GPL(dev_pm_opp_find_bw_floor);
|
||||||
|
|
Loading…
Add table
Reference in a new issue