From patchwork Mon Sep 28 16:42:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 7278971 Return-Path: X-Original-To: patchwork-linux-acpi@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 9EAB99F32B for ; Mon, 28 Sep 2015 16:46:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC68620709 for ; Mon, 28 Sep 2015 16:46:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E259120703 for ; Mon, 28 Sep 2015 16:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934088AbbI1Qpz (ORCPT ); Mon, 28 Sep 2015 12:45:55 -0400 Received: from foss.arm.com ([217.140.101.70]:51686 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934399AbbI1Qn1 (ORCPT ); Mon, 28 Sep 2015 12:43:27 -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 6741541D; Mon, 28 Sep 2015 09:43:30 -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 C296C3F2E5; Mon, 28 Sep 2015 09:43:24 -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 3/9] genirq/irqdomain: Add a fwnode_handle allocator Date: Mon, 28 Sep 2015 17:42:56 +0100 Message-Id: <1443458582-7497-4-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 In order to be able to reference an irqdomain from ACPI, we need to be able to create an identifier, which is a struct device_node. This device node does't really fit the ACPI infrastructure, so we cunningly hide it by returning the contained fwnode_handle. This will help a (still hypothetical) further migration of irqdomain from device_node to fwnode_handle. Signed-off-by: Marc Zyngier --- include/linux/irqdomain.h | 2 ++ kernel/irq/irqdomain.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index d3ca792..3193c61 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -162,6 +162,8 @@ enum { }; #ifdef CONFIG_IRQ_DOMAIN +struct fwnode_handle *irq_domain_alloc_fwnode(void *data); +void irq_domain_free_fwnode(struct fwnode_handle *fwnode); struct irq_domain *__irq_domain_add(struct device_node *of_node, int size, irq_hw_number_t hwirq_max, int direct_max, const struct irq_domain_ops *ops, diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index e5c1e4c..5e7214a 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -29,6 +29,36 @@ static int irq_domain_alloc_descs(int virq, unsigned int nr_irqs, static void irq_domain_check_hierarchy(struct irq_domain *domain); /** + * irq_domain_alloc_fwnode - Allocate a OF-backed fwnode_handle suitable for + * identifying an irq domain + * @data: optional user-provided data + * + * Allocate a struct device_node, and return a poiner to the embedded + * fwnode_handle (or NULL on failure). + */ +struct fwnode_handle *irq_domain_alloc_fwnode(void *data) +{ + struct device_node *of_node; + + of_node = of_node_alloc("irqdomain@%p", data); + if (!of_node) + return NULL; + + of_node->data = data; + return &of_node->fwnode; +} + +/** + * irq_domain_free_fwnode - Free a OF-backed fwnode_handle + * + * Free a fwnode_handle allocated with irq_domain_alloc_fwnode. + */ +void irq_domain_free_fwnode(struct fwnode_handle *fwnode) +{ + of_node_put(to_of_node(fwnode)); +} + +/** * __irq_domain_add() - Allocate a new irq_domain data structure * @of_node: optional device-tree node of the interrupt controller * @size: Size of linear map; 0 for radix mapping only