1 From d11d1b439fd20557813154c6d8c92d1f7e21f975 Mon Sep 17 00:00:00 2001
2 From: Thara Gopinath <thara@ti.com>
3 Date: Fri, 29 Oct 2010 20:43:10 +0530
4 Subject: [PATCH 07/19] OMAP: Introduce API in the OPP layer to find the opp entry corresponding to a voltage.
6 This patch adds an API in the opp layer to get the opp table entry
7 corresponding to the voltage passed as the parameter.
9 Signed-off-by: Thara Gopinath <thara@ti.com>
11 drivers/base/power/opp.c | 28 ++++++++++++++++++++++++++++
12 include/linux/opp.h | 8 ++++++++
13 2 files changed, 36 insertions(+), 0 deletions(-)
15 diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
16 index 2bb9b4c..60b4478 100644
17 --- a/drivers/base/power/opp.c
18 +++ b/drivers/base/power/opp.c
19 @@ -354,6 +354,34 @@ struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq)
23 + * opp_find_voltage() - search for an exact voltage
24 + * @dev: device pointer associated with the opp type
25 + * @volt: voltage to search for
27 + * Searches for exact match in the opp list and returns handle to the matching
28 + * opp if found, else returns ERR_PTR in case of error and should be handled
31 +struct opp *opp_find_voltage(struct device *dev, unsigned long volt)
33 + struct device_opp *dev_opp;
34 + struct opp *temp_opp, *opp = ERR_PTR(-ENODEV);
36 + dev_opp = find_device_opp(dev);
37 + if (IS_ERR(dev_opp))
40 + list_for_each_entry_rcu(temp_opp, &dev_opp->opp_list, node) {
41 + if (temp_opp->available && temp_opp->u_volt == volt) {
51 * opp_add() - Add an OPP table from a table definitions
52 * @dev: device for which we do this operation
53 * @freq: Frequency in Hz for this OPP
54 diff --git a/include/linux/opp.h b/include/linux/opp.h
55 index 5449945..4977d5c 100644
56 --- a/include/linux/opp.h
57 +++ b/include/linux/opp.h
58 @@ -34,6 +34,8 @@ struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
60 struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
62 +struct opp *opp_find_voltage(struct device *dev, unsigned long volt);
64 int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt);
66 int opp_enable(struct device *dev, unsigned long freq);
67 @@ -74,6 +76,12 @@ static inline struct opp *opp_find_freq_ceil(struct device *dev,
68 return ERR_PTR(-EINVAL);
71 +static inline struct opp *opp_find_voltage(struct device *dev,
74 + return ERR_PTR(-EINVAL);
77 static inline int opp_add(struct device *dev, unsigned long freq,