From patchwork Fri Oct 31 04:27:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 5202171 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6D7569F318 for ; Fri, 31 Oct 2014 04:30:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FF6120176 for ; Fri, 31 Oct 2014 04:30:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A9BDD20172 for ; Fri, 31 Oct 2014 04:30:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xk3oc-0006KZ-8H; Fri, 31 Oct 2014 04:27:58 +0000 Received: from mail-pd0-f174.google.com ([209.85.192.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xk3oK-0006FF-FW for linux-arm-kernel@lists.infradead.org; Fri, 31 Oct 2014 04:27:40 +0000 Received: by mail-pd0-f174.google.com with SMTP id p10so6496439pdj.33 for ; Thu, 30 Oct 2014 21:27:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6B1Kd4FzTsld3gHK8C7VdYgq//jQz1+kq4QQ84HZJF0=; b=JiUn2Z/8o0MRtUQKIq8EkVoYLGBFeuoyfCC1zFRUFJ3n4BjVdB7qPZwGoG7bXtHnot qADDzDaGBbUrwuq3wfWAba+Jj4grzqcgqI0gZPzSwQqKQccryFNBcnyKgHlyihFJYrF0 8DsZvwnYIJ18mJuPjjqwcmHFC9W4uLzHI0DMZuCoGgp9MjH+gTQVx/sJr7u81Pfjgb7n veUM6HK6NbWeu/a9aCwQONf9pNFDILSRWcqWzxkT2Tqf0Z0Qlb/0NqLxynnx2522dGZj afjNlN23CwPABx+vlEvgiI7mo2szL2nHcwFTqm8P9qP2zXO+3q8GlDa6fQrKZ13xDW9Q gQRQ== X-Gm-Message-State: ALoCoQn27pk0o3k+2UV4264RDjAIVn9HQdPxXcTONCnthjvrijr0X7vaQOfH3RSRSjS77/QkiiXO X-Received: by 10.68.57.199 with SMTP id k7mr22060675pbq.80.1414729639490; Thu, 30 Oct 2014 21:27:19 -0700 (PDT) Received: from tharvey-gw.gw (68-189-91-139.static.snlo.ca.charter.com. [68.189.91.139]) by mx.google.com with ESMTPSA id mp5sm8542239pbc.33.2014.10.30.21.27.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Oct 2014 21:27:18 -0700 (PDT) From: Tim Harvey To: linux-kernel@vger.kernel.org Subject: [PATCH 1/5] regulator: add function to determine if 2 regulators are the same Date: Thu, 30 Oct 2014 21:27:07 -0700 Message-Id: <1414729631-11005-2-git-send-email-tharvey@gateworks.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1414729631-11005-1-git-send-email-tharvey@gateworks.com> References: <1414729631-11005-1-git-send-email-tharvey@gateworks.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141030_212740_559432_2A1998C8 X-CRM114-Status: GOOD ( 13.06 ) X-Spam-Score: -0.7 (/) Cc: linux-pm@vger.kernel.org, Silvio F , linux-arm-kernel@lists.infradead.org, Philipp Zabel , Christian Hemp , Russell King , Iain Paton , Fabio Estevam , Shawn Guo , Lucas Stach X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Regulator structures can point to the same internal regulator dev's but as that information is private we need to expose a function to determine if two regulators do so. Cc: linux-pm@vger.kernel.org Signed-off-by: Tim Harvey --- drivers/regulator/core.c | 17 +++++++++++++++++ include/linux/regulator/consumer.h | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index cd87c0c..6d4a627 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2184,6 +2184,23 @@ int regulator_is_enabled(struct regulator *regulator) EXPORT_SYMBOL_GPL(regulator_is_enabled); /** + * regulator_is_same - are two regulators the same + * @regulator1: regulator source + * @regulator2: regulator source + * + * Returns positive if both regulators point to the same regulator_dev. + */ +int regulator_is_same(struct regulator *regulator1, + struct regulator *regulator2) +{ + if (!regulator1 || !regulator2) + return -EINVAL; + + return (regulator1->rdev == regulator2->rdev) ? 1 : 0; +} +EXPORT_SYMBOL_GPL(regulator_is_same); + +/** * regulator_can_change_voltage - check if regulator can change voltage * @regulator: regulator source * diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index d347c80..972090a 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -200,6 +200,8 @@ int __must_check regulator_enable(struct regulator *regulator); int regulator_disable(struct regulator *regulator); int regulator_force_disable(struct regulator *regulator); int regulator_is_enabled(struct regulator *regulator); +int regulator_is_same(struct regulator *regulator1, + struct regulator *regulator2); int regulator_disable_deferred(struct regulator *regulator, int ms); int __must_check regulator_bulk_get(struct device *dev, int num_consumers, @@ -387,6 +389,12 @@ static inline int regulator_is_enabled(struct regulator *regulator) return 1; } +static inline int regulator_is_same(struct regulator *regulator1, + struct regulator *regulator2) +{ + return 0; +} + static inline int regulator_bulk_get(struct device *dev, int num_consumers, struct regulator_bulk_data *consumers)