From patchwork Tue Jul 21 13:50:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6836311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BA462C05AC for ; Tue, 21 Jul 2015 13:56:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBC5B2069A for ; Tue, 21 Jul 2015 13:55:59 +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 1A0982049D for ; Tue, 21 Jul 2015 13:55:59 +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 1ZHXzO-0005RZ-0p; Tue, 21 Jul 2015 13:53:46 +0000 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXy0-0004hY-DL for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2015 13:52:21 +0000 Received: by wicgb10 with SMTP id gb10so56392605wic.1 for ; Tue, 21 Jul 2015 06:51:58 -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=AKwlH3G+hBxW1DzCdZZd1s6S9kbucTl01sq1lBBLlWI=; b=J9Od+0cqlhMSSE9Ko0cMnHbG9tCKqHwLZOtlm0NoIM5BdrwJS7Dt/9w6RAgaZ02rDz dCRSgCgOAjtKuSP11L80IJwwQ3XIM/tYRplXhBHVBWsKJn9G+gMrTZ/a1QwXiGja5GrX y4o51/gaj/X6/GAqTbHMmb5L+JMxhiYW+8WRpT5GfHx9YjZqQ+g2wNw89PcI5hcZc/xu 71wnMyYoKiymiOyee/4FPSmgyR1lW1rNCONiGMLBY/hgMC4EGoK/CS4q1dmoGeAZrqoY XX6lLcE7KqmxikHX3LS/2p1skZ9jHyjc56L7/652CTE9EnxHoIaAGoZb9M4wGfWV0Cgd qk9Q== X-Received: by 10.194.87.102 with SMTP id w6mr66179291wjz.111.1437486718816; Tue, 21 Jul 2015 06:51:58 -0700 (PDT) Received: from cizrna.lan ([109.72.12.178]) by smtp.gmail.com with ESMTPSA id pf4sm37172056wjb.23.2015.07.21.06.51.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:51:57 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 07/16] Add DEVM_FWNODE() Date: Tue, 21 Jul 2015 15:50:49 +0200 Message-Id: <1437486658-28365-8-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_065220_636435_1759A9FC X-CRM114-Status: GOOD ( 12.65 ) 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=ham 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/base/property.c | 17 +++++++++++++++++ include/linux/property.h | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index d88539c31c67..cc823b283f49 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -580,3 +580,20 @@ bool fwnode_is_compatible(struct fwnode_handle *fwnode, const char *compatible) return false; } EXPORT_SYMBOL_GPL(fwnode_is_compatible); + +int devm_acquire_fwnode(struct device *dev, + const struct devm_resource *resource) +{ + struct device_node *np; + struct fwnode_handle **nodep; + + np = of_parse_phandle(dev->of_node, resource->name, 0); + if (IS_ERR(np)) + return PTR_ERR(np); + + nodep = dev_get_drvdata(dev) + resource->offset; + *nodep = &np->fwnode; + + return 0; +} +EXPORT_SYMBOL_GPL(devm_acquire_fwnode); \ No newline at end of file diff --git a/include/linux/property.h b/include/linux/property.h index 3fd5fd58ebe9..1c6d5eb65516 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -17,6 +17,7 @@ #include struct device; +struct devm_resource; enum dev_prop_type { DEV_PROP_U8, @@ -172,4 +173,13 @@ void device_add_property_set(struct device *dev, struct property_set *pset); bool device_dma_is_coherent(struct device *dev); +int devm_acquire_fwnode(struct device *dev, + const struct devm_resource *resource); + +#define DEVM_FWNODE(_struct, _member, _name) { \ + .initfunc = devm_acquire_fwnode, \ + .offset = offsetof_t(struct _struct, _member, struct fwnode_handle *),\ + .name = _name, \ +} + #endif /* _LINUX_PROPERTY_H_ */