From patchwork Mon Sep 28 16:42:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 7278991 Return-Path: X-Original-To: patchwork-linux-acpi@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 C343DBEEA4 for ; Mon, 28 Sep 2015 16:46:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E24EA2075A for ; Mon, 28 Sep 2015 16:46:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04E452070D for ; Mon, 28 Sep 2015 16:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934283AbbI1QnX (ORCPT ); Mon, 28 Sep 2015 12:43:23 -0400 Received: from foss.arm.com ([217.140.101.70]:51662 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933867AbbI1QnV (ORCPT ); Mon, 28 Sep 2015 12:43:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 31C0E49; Mon, 28 Sep 2015 09:43:24 -0700 (PDT) Received: from approximate.cambridge.arm.com (unknown [10.1.209.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D0393F2E5; Mon, 28 Sep 2015 09:43:18 -0700 (PDT) From: Marc Zyngier To: Thomas Gleixner , Jiang Liu , Jason Cooper , "Rafael J. Wysocki" , Mark Rutland , Rob Herring , Frank Rowand Cc: , , , devicetree@vger.kernel.org, Lorenzo Pieralisi , Tomasz Nowicki , Hanjun Guo , Suravee Suthikulpanit , Graeme Gregory , Jake Oshins Subject: [PATCH v4 1/9] drivers/of: Introduce of_node_alloc Date: Mon, 28 Sep 2015 17:42:54 +0100 Message-Id: <1443458582-7497-2-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443458582-7497-1-git-send-email-marc.zyngier@arm.com> References: <1443458582-7497-1-git-send-email-marc.zyngier@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 We want to be able to generate "fake" device nodes that can be used as an identifier for irq domains. For that, we reuse the dynamic DT layer in order to generate DT nodes in a detached state (so that it doesn't interfere with the rest of the tree). Signed-off-by: Marc Zyngier --- drivers/of/dynamic.c | 22 ++++++++++++++++++++++ include/linux/of.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 53826b8..709d363 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -445,6 +445,28 @@ struct device_node *__of_node_dup(const struct device_node *np, const char *fmt, return NULL; } +/** + * of_node_alloc() - Allocate an empty device node dynamically. + * @fmt: Format string (plus vargs) for new full name of the device node + * + * Create an device tree node, either by by allocating an empty one + * suitable for further modification. The node data are dynamically + * allocated and all the node flags have the OF_DYNAMIC & OF_DETACHED + * bits set. Returns the newly allocated node or NULL on out of memory + * error. + */ +struct device_node *of_node_alloc(const char *fmt, ...) +{ + struct device_node *np; + va_list vargs; + + va_start(vargs, fmt); + np = __of_node_dup(NULL, fmt, vargs); + va_end(vargs); + + return np; +} + static void __of_changeset_entry_destroy(struct of_changeset_entry *ce) { of_node_put(ce->np); diff --git a/include/linux/of.h b/include/linux/of.h index 2194b8c..f7f11f7 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -104,6 +104,7 @@ static inline int of_node_is_attached(struct device_node *node) #ifdef CONFIG_OF_DYNAMIC extern struct device_node *of_node_get(struct device_node *node); extern void of_node_put(struct device_node *node); +extern struct device_node *of_node_alloc(const char *fmt, ...); #else /* CONFIG_OF_DYNAMIC */ /* Dummy ref counting routines - to be implemented later */ static inline struct device_node *of_node_get(struct device_node *node) @@ -111,6 +112,10 @@ static inline struct device_node *of_node_get(struct device_node *node) return node; } static inline void of_node_put(struct device_node *node) { } +static inline struct device_node *of_node_alloc(const char *fmt, ...) +{ + return NULL; +} #endif /* !CONFIG_OF_DYNAMIC */ /* Pointer for first entry in chain of all nodes. */