From patchwork Tue Jul 21 13:50:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6836371 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B00819F380 for ; Tue, 21 Jul 2015 13:56:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6ACF206A4 for ; Tue, 21 Jul 2015 13:56:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D31B820670 for ; Tue, 21 Jul 2015 13:56:55 +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 1ZHY0B-00069Q-7S; Tue, 21 Jul 2015 13:54:35 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXy7-0004nZ-14 for linux-arm-kernel@bombadil.infradead.org; Tue, 21 Jul 2015 13:52:27 +0000 Received: from mail-wg0-x232.google.com ([2a00:1450:400c:c00::232]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXy4-00074B-IF for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2015 13:52:25 +0000 Received: by wgkl9 with SMTP id l9so156900141wgk.1 for ; Tue, 21 Jul 2015 06:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=DPBcEPE76CQ3FyMKQwomvOPDC8fk1hnfvIn725KC71U=; b=FBPDuuaqjVUDIDExLfN+F7Qdup40fjU2X/FGVTSmikwaDou8YYHdQpJPKv2ka/+NOX w0Enmcfw35+/ahozFLHk4QZx9BrGf6r0DQSS+YHvignOg6MqBUO8e20H/bHRW5jafAZe j41+TyjH8M5L1qBK3G2t+3m+ZHtp7vF08QPcwSMk54KRq/ll5gl20iLust/xpEA4mXLI G77bg6KEZ/DGI5UMiT6F3dru/3Ckzf31NEATq0ii/tWozz4Ecj1ezwQwF4Gh6SQnfMGp hZVVgOCSd1p+NajaDJ5TzoZeBU2fHEANtksS0pIHmntO2L9+cRYXuXbVn/5Z0JZB8+HD Q3gg== X-Received: by 10.194.108.5 with SMTP id hg5mr71039405wjb.25.1437486723054; Tue, 21 Jul 2015 06:52:03 -0700 (PDT) Received: from cizrna.lan ([109.72.12.178]) by smtp.gmail.com with ESMTPSA id pf4sm37172056wjb.23.2015.07.21.06.52.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:52:02 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 10/16] Add DEVM_REGULATOR() Date: Tue, 21 Jul 2015 15:50:52 +0200 Message-Id: <1437486658-28365-11-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> References: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150721_145224_654036_DE5A8D05 X-CRM114-Status: GOOD ( 13.37 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Tomeu Vizoso , Stephen Warren , "Rafael J. Wysocki" , Mark Brown , linux-arm-kernel@lists.infradead.org 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=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Signed-off-by: Tomeu Vizoso --- drivers/regulator/devres.c | 18 ++++++++++++++++++ include/linux/regulator/consumer.h | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c index 6ec1d400adae..ff1328ca8fd6 100644 --- a/drivers/regulator/devres.c +++ b/drivers/regulator/devres.c @@ -15,7 +15,9 @@ #include #include #include +#include #include +#include #include "internal.h" @@ -498,3 +500,19 @@ void devm_regulator_unregister_notifier(struct regulator *regulator, WARN_ON(rc); } EXPORT_SYMBOL_GPL(devm_regulator_unregister_notifier); + +int devm_acquire_regulator(struct device *dev, + const struct devm_resource *resource) +{ + struct regulator *regulator, **regulatorp; + + regulator = devm_regulator_get(dev, resource->name); + if (IS_ERR(regulator)) + return PTR_ERR(regulator); + + regulatorp = dev_get_drvdata(dev) + resource->offset; + *regulatorp = regulator; + + return 0; +} +EXPORT_SYMBOL(devm_acquire_regulator); diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 2ba4a40919c8..ece4f076f7e3 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -38,6 +38,7 @@ #include struct device; +struct devm_resource; struct notifier_block; struct regmap; @@ -173,6 +174,15 @@ struct regulator *__must_check devm_regulator_get_optional(struct device *dev, void regulator_put(struct regulator *regulator); void devm_regulator_put(struct regulator *regulator); +int devm_acquire_regulator(struct device *dev, + const struct devm_resource *resource); + +#define DEVM_REGULATOR(_struct, _member, _name) { \ + .initfunc = devm_acquire_regulator, \ + .offset = offsetof_t(struct _struct, _member, struct regulator *),\ + .name = _name, \ +} + int regulator_register_supply_alias(struct device *dev, const char *id, struct device *alias_dev, const char *alias_id);