Skip to content

Commit 15d6248

Browse files
committed
OPP: Add dev_pm_opp_find_freq_exact_indexed()
JIRA: https://issues.redhat.com/browse/RHEL-81432 commit a589392 Author: Viresh Kumar <[email protected]> Date: Fri Jul 21 13:41:20 2023 +0530 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]> Signed-off-by: Jared Kangas <[email protected]>
1 parent bfd80b5 commit 15d6248

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
@@ -623,6 +623,34 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
623623
}
624624
EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact);
625625

626+
/**
627+
* dev_pm_opp_find_freq_exact_indexed() - Search for an exact freq for the
628+
* clock corresponding to the index
629+
* @dev: Device for which we do this operation
630+
* @freq: frequency to search for
631+
* @index: Clock index
632+
* @available: true/false - match for available opp
633+
*
634+
* Search for the matching exact OPP for the clock corresponding to the
635+
* specified index from a starting freq for a device.
636+
*
637+
* Return: matching *opp , else returns ERR_PTR in case of error and should be
638+
* handled using IS_ERR. Error return values can be:
639+
* EINVAL: for bad pointer
640+
* ERANGE: no match found for search
641+
* ENODEV: if device not found in list of registered devices
642+
*
643+
* The callers are required to call dev_pm_opp_put() for the returned OPP after
644+
* use.
645+
*/
646+
struct dev_pm_opp *
647+
dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq,
648+
u32 index, bool available)
649+
{
650+
return _find_key_exact(dev, freq, index, available, _read_freq, NULL);
651+
}
652+
EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact_indexed);
653+
626654
static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table,
627655
unsigned long *freq)
628656
{

include/linux/pm_opp.h

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

145+
struct dev_pm_opp *
146+
dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq,
147+
u32 index, bool available);
148+
145149
struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
146150
unsigned long *freq);
147151

@@ -284,6 +288,13 @@ static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
284288
return ERR_PTR(-EOPNOTSUPP);
285289
}
286290

291+
static inline struct dev_pm_opp *
292+
dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq,
293+
u32 index, bool available)
294+
{
295+
return ERR_PTR(-EOPNOTSUPP);
296+
}
297+
287298
static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
288299
unsigned long *freq)
289300
{

0 commit comments

Comments
 (0)