Message ID | 852a47c0e7a795bdf6424519ab7fadfdeb5b4a3c.1689932341.git.viresh.kumar@linaro.org |
---|---|
State | Accepted |
Commit | a5893928bb179d67ca1d44a8f66c990480ba541d |
Headers | show |
Series | OPP: Indexed searching based on frequency | expand |
On Fri, Jul 21, 2023 at 03:10:57PM +0530, Viresh Kumar wrote: > The indexed version of the API is added for other floor and ceil, add > the same for exact as well for completeness. > Well, "completeness" makes sense to me but I always heard that you should add an API when there is a user. That was the reason I didn't add it in my patch. - Mani > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > --- > drivers/opp/core.c | 28 ++++++++++++++++++++++++++++ > include/linux/pm_opp.h | 11 +++++++++++ > 2 files changed, 39 insertions(+) > > diff --git a/drivers/opp/core.c b/drivers/opp/core.c > index 00638d40353f..7b1d5724b3d8 100644 > --- a/drivers/opp/core.c > +++ b/drivers/opp/core.c > @@ -648,6 +648,34 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, > } > EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact); > > +/** > + * dev_pm_opp_find_freq_exact_indexed() - Search for an exact freq for the > + * clock corresponding to the index > + * @dev: Device for which we do this operation > + * @freq: frequency to search for > + * @index: Clock index > + * @available: true/false - match for available opp > + * > + * Search for the matching exact OPP for the clock corresponding to the > + * specified index from a starting freq for a device. > + * > + * Return: matching *opp , else returns ERR_PTR in case of error and should be > + * handled using IS_ERR. Error return values can be: > + * EINVAL: for bad pointer > + * ERANGE: no match found for search > + * ENODEV: if device not found in list of registered devices > + * > + * The callers are required to call dev_pm_opp_put() for the returned OPP after > + * use. > + */ > +struct dev_pm_opp * > +dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, > + u32 index, bool available) > +{ > + return _find_key_exact(dev, freq, index, available, _read_freq, NULL); > +} > +EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact_indexed); > + > static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table, > unsigned long *freq) > { > diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h > index a13a1705df57..23e4e4eaaa42 100644 > --- a/include/linux/pm_opp.h > +++ b/include/linux/pm_opp.h > @@ -124,6 +124,10 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, > unsigned long freq, > bool available); > > +struct dev_pm_opp * > +dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, > + u32 index, bool available); > + > struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, > unsigned long *freq); > > @@ -268,6 +272,13 @@ static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, > return ERR_PTR(-EOPNOTSUPP); > } > > +static inline struct dev_pm_opp * > +dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, > + u32 index, bool available) > +{ > + return ERR_PTR(-EOPNOTSUPP); > +} > + > static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, > unsigned long *freq) > { > -- > 2.31.1.272.g89b43f80a514 >
On 24-07-23, 11:54, Manivannan Sadhasivam wrote: > On Fri, Jul 21, 2023 at 03:10:57PM +0530, Viresh Kumar wrote: > > The indexed version of the API is added for other floor and ceil, add > > the same for exact as well for completeness. > > > > Well, "completeness" makes sense to me but I always heard that you should add > an API when there is a user. That was the reason I didn't add it in my patch. Yes that is true for any new API I guess. But since we support multiple clocks, it made sense to support all three variants here.
diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 00638d40353f..7b1d5724b3d8 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -648,6 +648,34 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact); +/** + * dev_pm_opp_find_freq_exact_indexed() - Search for an exact freq for the + * clock corresponding to the index + * @dev: Device for which we do this operation + * @freq: frequency to search for + * @index: Clock index + * @available: true/false - match for available opp + * + * Search for the matching exact OPP for the clock corresponding to the + * specified index from a starting freq for a device. + * + * Return: matching *opp , else returns ERR_PTR in case of error and should be + * handled using IS_ERR. Error return values can be: + * EINVAL: for bad pointer + * ERANGE: no match found for search + * ENODEV: if device not found in list of registered devices + * + * The callers are required to call dev_pm_opp_put() for the returned OPP after + * use. + */ +struct dev_pm_opp * +dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, + u32 index, bool available) +{ + return _find_key_exact(dev, freq, index, available, _read_freq, NULL); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact_indexed); + static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table, unsigned long *freq) { diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index a13a1705df57..23e4e4eaaa42 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -124,6 +124,10 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, bool available); +struct dev_pm_opp * +dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, + u32 index, bool available); + struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq); @@ -268,6 +272,13 @@ static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, return ERR_PTR(-EOPNOTSUPP); } +static inline struct dev_pm_opp * +dev_pm_opp_find_freq_exact_indexed(struct device *dev, unsigned long freq, + u32 index, bool available) +{ + return ERR_PTR(-EOPNOTSUPP); +} + static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq) {
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 <viresh.kumar@linaro.org> --- drivers/opp/core.c | 28 ++++++++++++++++++++++++++++ include/linux/pm_opp.h | 11 +++++++++++ 2 files changed, 39 insertions(+)