From patchwork Fri Oct 29 15:38:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 290552 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9TFcho6012993 for ; Fri, 29 Oct 2010 15:38:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932683Ab0J2Pim (ORCPT ); Fri, 29 Oct 2010 11:38:42 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:34604 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932704Ab0J2Pij (ORCPT ); Fri, 29 Oct 2010 11:38:39 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o9TFcZ8Q020193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 29 Oct 2010 10:38:37 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o9TFcTYm012648; Fri, 29 Oct 2010 21:08:32 +0530 (IST) From: Thara Gopinath To: linux-omap@vger.kernel.org Cc: paul@pwsan.com, khilman@deeprootsystems.com, b-cousson@ti.com, vishwanath.bs@ti.com, sawant@ti.com, Thara Gopinath Subject: [PATCH v2 02/14] OMAP: Introduce API in the OPP layer to find the opp entry corresponding to a voltage. Date: Fri, 29 Oct 2010 21:08:16 +0530 Message-Id: <1288366708-32302-3-git-send-email-thara@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1288366708-32302-1-git-send-email-thara@ti.com> References: <1288366708-32302-1-git-send-email-thara@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Oct 2010 15:38:44 +0000 (UTC) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 2bb9b4c..60b4478 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -354,6 +354,34 @@ struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq) } /** + * opp_find_voltage() - search for an exact voltage + * @dev: device pointer associated with the opp type + * @volt: voltage to search for + * + * Searches for exact match in the opp list and returns handle to the matching + * opp if found, else returns ERR_PTR in case of error and should be handled + * using IS_ERR. + */ +struct opp *opp_find_voltage(struct device *dev, unsigned long volt) +{ + struct device_opp *dev_opp; + struct opp *temp_opp, *opp = ERR_PTR(-ENODEV); + + dev_opp = find_device_opp(dev); + if (IS_ERR(dev_opp)) + return opp; + + list_for_each_entry_rcu(temp_opp, &dev_opp->opp_list, node) { + if (temp_opp->available && temp_opp->u_volt == volt) { + opp = temp_opp; + break; + } + } + + return opp; +} + +/** * opp_add() - Add an OPP table from a table definitions * @dev: device for which we do this operation * @freq: Frequency in Hz for this OPP diff --git a/include/linux/opp.h b/include/linux/opp.h index 5449945..4977d5c 100644 --- a/include/linux/opp.h +++ b/include/linux/opp.h @@ -34,6 +34,8 @@ struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq); struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq); +struct opp *opp_find_voltage(struct device *dev, unsigned long volt); + int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt); int opp_enable(struct device *dev, unsigned long freq); @@ -74,6 +76,12 @@ static inline struct opp *opp_find_freq_ceil(struct device *dev, return ERR_PTR(-EINVAL); } +static inline struct opp *opp_find_voltage(struct device *dev, + unsigned long volt) +{ + return ERR_PTR(-EINVAL); +} + static inline int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) {