Skip to content

Commit a0242c8

Browse files
Krishna chaitanya chundruvireshk
authored andcommitted
OPP: Add dev_pm_opp_find_level_floor()
Add dev_pm_opp_find_level_floor(), as is done for frequency and bandwidth. Signed-off-by: Krishna chaitanya chundru <[email protected]> [ Viresh: Updated commit log and rearranged code ] Signed-off-by: Viresh Kumar <[email protected]>
1 parent 0025ff6 commit a0242c8

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

drivers/opp/core.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,31 @@ struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
813813
}
814814
EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_ceil);
815815

816+
/**
817+
* dev_pm_opp_find_level_floor() - Search for a rounded floor level
818+
* @dev: device for which we do this operation
819+
* @level: Start level
820+
*
821+
* Search for the matching floor *available* OPP from a starting level
822+
* for a device.
823+
*
824+
* Return: matching *opp and refreshes *level accordingly, else returns
825+
* ERR_PTR in case of error and should be handled using IS_ERR. Error return
826+
* values can be:
827+
* EINVAL: for bad pointer
828+
* ERANGE: no match found for search
829+
* ENODEV: if device not found in list of registered devices
830+
*
831+
* The callers are required to call dev_pm_opp_put() for the returned OPP after
832+
* use.
833+
*/
834+
struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
835+
unsigned long *level)
836+
{
837+
return _find_key_floor(dev, level, 0, true, _read_level, NULL);
838+
}
839+
EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_floor);
840+
816841
/**
817842
* dev_pm_opp_find_bw_ceil() - Search for a rounded ceil bandwidth
818843
* @dev: device for which we do this operation

include/linux/pm_opp.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
156156
struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
157157
unsigned int *level);
158158

159+
struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
160+
unsigned long *level);
161+
159162
struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
160163
unsigned int *bw, int index);
161164

@@ -320,6 +323,12 @@ static inline struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
320323
return ERR_PTR(-EOPNOTSUPP);
321324
}
322325

326+
static inline struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
327+
unsigned long *level)
328+
{
329+
return ERR_PTR(-EOPNOTSUPP);
330+
}
331+
323332
static inline struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
324333
unsigned int *bw, int index)
325334
{

0 commit comments

Comments
 (0)