Skip to content

Commit a589392

Browse files
committed
OPP: Add dev_pm_opp_find_freq_exact_indexed()
The indexed version of the API is added for other floor and ceil, add the same for exact as well for completeness. Signed-off-by: Viresh Kumar <[email protected]>
1 parent 5f756d0 commit a589392

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

drivers/opp/core.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,34 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
646646
}
647647
EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact);
648648

649+
/**
650+
* dev_pm_opp_find_freq_exact_indexed() - Search for an exact freq for the
651+
* clock corresponding to the index
652+
* @dev: Device for which we do this operation
653+
* @freq: frequency to search for
654+
* @index: Clock index
655+
* @available: true/false - match for available opp
656+
*
657+
* Search for the matching exact OPP for the clock corresponding to the
658+
* specified index from a starting freq for a device.
659+
*
660+
* Return: matching *opp , else returns ERR_PTR in case of error and should be
661+
* handled using IS_ERR. Error return values can be:
662+
* EINVAL: for bad pointer
663+
* ERANGE: no match found for search
664+
* ENODEV: if device not found in list of registered devices
665+
*
666+
* The callers are required to call dev_pm_opp_put() for the returned OPP after
667+
* use.
668+
*/
669+
struct dev_pm_opp *
670+
dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq,
671+
u32 index, bool available)
672+
{
673+
return _find_key_exact(dev, freq, index, available, _read_freq, NULL);
674+
}
675+
EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact_indexed);
676+
649677
static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table,
650678
unsigned long *freq)
651679
{

include/linux/pm_opp.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
124124
unsigned long freq,
125125
bool available);
126126

127+
struct dev_pm_opp *
128+
dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq,
129+
u32 index, bool available);
130+
127131
struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
128132
unsigned long *freq);
129133

@@ -268,6 +272,13 @@ static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
268272
return ERR_PTR(-EOPNOTSUPP);
269273
}
270274

275+
static inline struct dev_pm_opp *
276+
dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq,
277+
u32 index, bool available)
278+
{
279+
return ERR_PTR(-EOPNOTSUPP);
280+
}
281+
271282
static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
272283
unsigned long *freq)
273284
{

0 commit comments

Comments
 (0)