From patchwork Wed Jan 17 16:55:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 10170217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 614CC603ED for ; Wed, 17 Jan 2018 17:06:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 499EC28607 for ; Wed, 17 Jan 2018 17:06:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CCBE2860B; Wed, 17 Jan 2018 17:06:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B9F5B28607 for ; Wed, 17 Jan 2018 17:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=thdQS7UuQQ91+KHPr663lYXKY2dhR1oPZ7FuyU9jGJE=; b=Oc/g+MrCNA4GX/ubO5ntCE0alH gb8faLukbcNzVWjGVYi6Loy0bhUod6YXn5lPYjkV48aol5TMFrJ1qTG6Gc+Jm6/UYLKtNkyjj2KdI N9yvRtQQaNMT6Enbk+zjT1LT+T+hOHKm3iFk0qiGEnkER2bv32Pr8+iViY7KKI4jWglFGjyBSub0u scx4nuDtT+M/Ylx3CDMnSRjl7GPzuXyf4L+8i0MwgR7o06vwrpleLPHvgAgKpyStg1jGZLOJ8o7xL K6dKc/Vy3Mo9+09ldQSnLRN+KJx5wuzQTwm04UMN0iX2mTekq3tmUJL+gre7SNx03+t+DASsUbd2D j8MeO3MA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebrAH-00037w-LT; Wed, 17 Jan 2018 17:06:17 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebr0X-0005gw-E1 for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2018 16:56:15 +0000 Received: by mail-lf0-x241.google.com with SMTP id a204so14554087lfa.2 for ; Wed, 17 Jan 2018 08:56:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=21Mi6hIYM3zfmLCRPrLyE3plIUz4Ga5083/xGwgP8HE=; b=DHeOjbkS+zUjewqXHxE3yJqEWbuQdpwAfuUD1HI7J6QuivOHYpWrRu4nN+hesABOAs +xz6kgp6qX8JYOpyZ1bHF0zULulpC6VpF+LVz6n0sD7eSdWpb5fASA1i0ncVLRw5jdiH bb2u56zwgmToZPA/zLRFDLjjaFxsO+5mjCY8UFK1gyq6toyVT7EZKqkB3TqKvYBahaRz PC/+M5mZ8uC/QhPeV6uI3s4V9ADJmV9zMJMb1iXiQ4jX/sejf4bTN7w/FwPEwPShmDsn uSO1pvslzp9mfwesH07RQfkIecrx70MKFpEBEHpMcmmtPmRz6so6N/tP6vpmq3gc2N3J PX3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=21Mi6hIYM3zfmLCRPrLyE3plIUz4Ga5083/xGwgP8HE=; b=pfQ+vu4ddJjeWIjiWjPPu9HDYYeSqXKv6mCVMyLDlgmVl+2kBbMo0k3oFARb3WtNs1 2wGOTc0GOeM+U2F1BtEpPp5+kpckV1Ys/uieDzrkwBoxkLWNqtPRWnA22I6btHnjgDY/ pNcsvkgT+o4MYoyT+1fzonWZc+CxBvs7YFYFu7UbIpfspOwome+JFWjLEE33zcSSZ8Bs uEuCuSGsI/7d8A/F6AYk/67a+AW+S0fUErN47sqAZwHuAh0IdwRf63qrsTtlZ8c4dbNo xz7OZ747Ow3VOjliDqBUD7QyLDaCKuICRMc7KUesTcrSzjoM88ZKkHwEgY5ZDT/Nx7+0 22oQ== X-Gm-Message-State: AKwxytc3CwqA0Vmq4F+IJKwWDKNxuHlh/4KKB3/9pmVDhVX5Q/WXHgtJ 8OMNDc+kLlu53D9dYNb3ZJqiNA== X-Google-Smtp-Source: ACJfBov4pIlPpsHkypuBYouInsS7jh5vcghQ5TBtA+C4nKd0PDdjaFJ5Ljkz8gXn8Cg+juB7deqyfw== X-Received: by 10.46.85.149 with SMTP id g21mr19309252lje.118.1516208162761; Wed, 17 Jan 2018 08:56:02 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id t81sm868347lff.47.2018.01.17.08.56.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:56:02 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [net-next: PATCH v3 3/7] device property: Introduce fwnode_irq_get() Date: Wed, 17 Jan 2018 17:55:42 +0100 Message-Id: <1516208146-4144-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch, f.fainelli@gmail.com, graeme.gregory@linaro.org, ard.biesheuvel@linaro.org, jaz@semihalf.com, antoine.tenart@free-electrons.com, rafael.j.wysocki@intel.com, linux@armlinux.org.uk, nadavh@marvell.com, neta@marvell.com, tn@semihalf.com, gregory.clement@free-electrons.com, stefanc@marvell.com, mw@semihalf.com, davem@davemloft.net MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Until now there were two very similar functions allowing to get Linux IRQ number from ACPI handle (acpi_irq_get()) and OF node (of_irq_get()). The first one appeared to be used only as a subroutine of platform_irq_get(), which (in the generic code) limited IRQ obtaining from _CRS method only to nodes associated to kernel's struct platform_device. This patch introduces new helper routine - fwnode_irq_get(), which allows to get the IRQ number directly from the fwnode to be used as common for OF/ACPI worlds. Signed-off-by: Marcin Wojtas --- drivers/base/property.c | 27 ++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 7c4a53d..adb3893 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1230,6 +1231,32 @@ void *device_get_mac_address(struct device *dev, char *addr, int alen) EXPORT_SYMBOL(device_get_mac_address); /** + * fwnode_irq_get - Get IRQ directly from a fwnode + * @fwnode: Pointer to the firmware node + * @index: Zero-based index of the IRQ + * + * Returns Linux IRQ number on success. Other values are determined + * accordingly to acpi_/of_ irq_get() operation. + */ +int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index) +{ + struct acpi_device *adev = to_acpi_device_node(fwnode); + struct device_node *of_node = to_of_node(fwnode); + struct resource res; + int ret; + + if (IS_ENABLED(CONFIG_OF) && of_node) + return of_irq_get(of_node, index); + + ret = acpi_irq_get(acpi_device_handle(adev), index, &res); + if (ret) + return ret; + + return res.start; +} +EXPORT_SYMBOL(fwnode_irq_get); + +/** * device_graph_get_next_endpoint - Get next endpoint firmware node * @fwnode: Pointer to the parent firmware node * @prev: Previous endpoint node or %NULL to get the first diff --git a/include/linux/property.h b/include/linux/property.h index 9b13332..e05889f 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -103,6 +103,8 @@ struct fwnode_handle *device_get_named_child_node(struct device *dev, struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); void fwnode_handle_put(struct fwnode_handle *fwnode); +int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index); + unsigned int device_get_child_node_count(struct device *dev); static inline bool device_property_read_bool(struct device *dev,