Skip to content

Commit 22079af

Browse files
committed
opp: Reorder definition of ceil/floor helpers
Reorder the helpers to keep all freq specific ones, followed by level and bw. No functional change. Signed-off-by: Viresh Kumar <[email protected]>
1 parent 00ce387 commit 22079af

File tree

2 files changed

+108
-108
lines changed

2 files changed

+108
-108
lines changed

drivers/opp/core.c

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -456,103 +456,6 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
456456
}
457457
EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact);
458458

459-
/**
460-
* dev_pm_opp_find_level_exact() - search for an exact level
461-
* @dev: device for which we do this operation
462-
* @level: level to search for
463-
*
464-
* Return: Searches for exact match in the opp table and returns pointer to the
465-
* matching opp if found, else returns ERR_PTR in case of error and should
466-
* be handled using IS_ERR. Error return values can be:
467-
* EINVAL: for bad pointer
468-
* ERANGE: no match found for search
469-
* ENODEV: if device not found in list of registered devices
470-
*
471-
* The callers are required to call dev_pm_opp_put() for the returned OPP after
472-
* use.
473-
*/
474-
struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
475-
unsigned int level)
476-
{
477-
struct opp_table *opp_table;
478-
struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
479-
480-
opp_table = _find_opp_table(dev);
481-
if (IS_ERR(opp_table)) {
482-
int r = PTR_ERR(opp_table);
483-
484-
dev_err(dev, "%s: OPP table not found (%d)\n", __func__, r);
485-
return ERR_PTR(r);
486-
}
487-
488-
mutex_lock(&opp_table->lock);
489-
490-
list_for_each_entry(temp_opp, &opp_table->opp_list, node) {
491-
if (temp_opp->level == level) {
492-
opp = temp_opp;
493-
494-
/* Increment the reference count of OPP */
495-
dev_pm_opp_get(opp);
496-
break;
497-
}
498-
}
499-
500-
mutex_unlock(&opp_table->lock);
501-
dev_pm_opp_put_opp_table(opp_table);
502-
503-
return opp;
504-
}
505-
EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_exact);
506-
507-
/**
508-
* dev_pm_opp_find_level_ceil() - search for an rounded up level
509-
* @dev: device for which we do this operation
510-
* @level: level to search for
511-
*
512-
* Return: Searches for rounded up match in the opp table and returns pointer
513-
* to the matching opp if found, else returns ERR_PTR in case of error and
514-
* should be handled using IS_ERR. Error return values can be:
515-
* EINVAL: for bad pointer
516-
* ERANGE: no match found for search
517-
* ENODEV: if device not found in list of registered devices
518-
*
519-
* The callers are required to call dev_pm_opp_put() for the returned OPP after
520-
* use.
521-
*/
522-
struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
523-
unsigned int *level)
524-
{
525-
struct opp_table *opp_table;
526-
struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
527-
528-
opp_table = _find_opp_table(dev);
529-
if (IS_ERR(opp_table)) {
530-
int r = PTR_ERR(opp_table);
531-
532-
dev_err(dev, "%s: OPP table not found (%d)\n", __func__, r);
533-
return ERR_PTR(r);
534-
}
535-
536-
mutex_lock(&opp_table->lock);
537-
538-
list_for_each_entry(temp_opp, &opp_table->opp_list, node) {
539-
if (temp_opp->available && temp_opp->level >= *level) {
540-
opp = temp_opp;
541-
*level = opp->level;
542-
543-
/* Increment the reference count of OPP */
544-
dev_pm_opp_get(opp);
545-
break;
546-
}
547-
}
548-
549-
mutex_unlock(&opp_table->lock);
550-
dev_pm_opp_put_opp_table(opp_table);
551-
552-
return opp;
553-
}
554-
EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_ceil);
555-
556459
static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table,
557460
unsigned long *freq)
558461
{
@@ -729,6 +632,103 @@ struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev,
729632
}
730633
EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil_by_volt);
731634

635+
/**
636+
* dev_pm_opp_find_level_exact() - search for an exact level
637+
* @dev: device for which we do this operation
638+
* @level: level to search for
639+
*
640+
* Return: Searches for exact match in the opp table and returns pointer to the
641+
* matching opp if found, else returns ERR_PTR in case of error and should
642+
* be handled using IS_ERR. Error return values can be:
643+
* EINVAL: for bad pointer
644+
* ERANGE: no match found for search
645+
* ENODEV: if device not found in list of registered devices
646+
*
647+
* The callers are required to call dev_pm_opp_put() for the returned OPP after
648+
* use.
649+
*/
650+
struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
651+
unsigned int level)
652+
{
653+
struct opp_table *opp_table;
654+
struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
655+
656+
opp_table = _find_opp_table(dev);
657+
if (IS_ERR(opp_table)) {
658+
int r = PTR_ERR(opp_table);
659+
660+
dev_err(dev, "%s: OPP table not found (%d)\n", __func__, r);
661+
return ERR_PTR(r);
662+
}
663+
664+
mutex_lock(&opp_table->lock);
665+
666+
list_for_each_entry(temp_opp, &opp_table->opp_list, node) {
667+
if (temp_opp->level == level) {
668+
opp = temp_opp;
669+
670+
/* Increment the reference count of OPP */
671+
dev_pm_opp_get(opp);
672+
break;
673+
}
674+
}
675+
676+
mutex_unlock(&opp_table->lock);
677+
dev_pm_opp_put_opp_table(opp_table);
678+
679+
return opp;
680+
}
681+
EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_exact);
682+
683+
/**
684+
* dev_pm_opp_find_level_ceil() - search for an rounded up level
685+
* @dev: device for which we do this operation
686+
* @level: level to search for
687+
*
688+
* Return: Searches for rounded up match in the opp table and returns pointer
689+
* to the matching opp if found, else returns ERR_PTR in case of error and
690+
* should be handled using IS_ERR. Error return values can be:
691+
* EINVAL: for bad pointer
692+
* ERANGE: no match found for search
693+
* ENODEV: if device not found in list of registered devices
694+
*
695+
* The callers are required to call dev_pm_opp_put() for the returned OPP after
696+
* use.
697+
*/
698+
struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
699+
unsigned int *level)
700+
{
701+
struct opp_table *opp_table;
702+
struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
703+
704+
opp_table = _find_opp_table(dev);
705+
if (IS_ERR(opp_table)) {
706+
int r = PTR_ERR(opp_table);
707+
708+
dev_err(dev, "%s: OPP table not found (%d)\n", __func__, r);
709+
return ERR_PTR(r);
710+
}
711+
712+
mutex_lock(&opp_table->lock);
713+
714+
list_for_each_entry(temp_opp, &opp_table->opp_list, node) {
715+
if (temp_opp->available && temp_opp->level >= *level) {
716+
opp = temp_opp;
717+
*level = opp->level;
718+
719+
/* Increment the reference count of OPP */
720+
dev_pm_opp_get(opp);
721+
break;
722+
}
723+
}
724+
725+
mutex_unlock(&opp_table->lock);
726+
dev_pm_opp_put_opp_table(opp_table);
727+
728+
return opp;
729+
}
730+
EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_ceil);
731+
732732
/**
733733
* dev_pm_opp_find_bw_ceil() - Search for a rounded ceil bandwidth
734734
* @dev: device for which we do this operation

include/linux/pm_opp.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev);
117117
struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
118118
unsigned long freq,
119119
bool available);
120-
struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
121-
unsigned int level);
122-
struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
123-
unsigned int *level);
124-
125120
struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
126121
unsigned long *freq);
127122
struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev,
128123
unsigned long u_volt);
129124

125+
struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
126+
unsigned int level);
127+
struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
128+
unsigned int *level);
129+
130130
struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
131131
unsigned long *freq);
132132

@@ -250,12 +250,6 @@ static inline unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev)
250250
return 0;
251251
}
252252

253-
static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
254-
unsigned long freq, bool available)
255-
{
256-
return ERR_PTR(-EOPNOTSUPP);
257-
}
258-
259253
static inline struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
260254
unsigned int level)
261255
{
@@ -268,6 +262,12 @@ static inline struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
268262
return ERR_PTR(-EOPNOTSUPP);
269263
}
270264

265+
static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
266+
unsigned long freq, bool available)
267+
{
268+
return ERR_PTR(-EOPNOTSUPP);
269+
}
270+
271271
static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
272272
unsigned long *freq)
273273
{

0 commit comments

Comments
 (0)