Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1279341pxb; Fri, 21 Jan 2022 14:11:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9f4vR06UgUs5c2hNT2ko5Ok49J54c4hIW/fKjkAffoUjT5y+3WuvpTrQynSkeIlbN3wO1 X-Received: by 2002:a17:903:1211:b0:149:9809:77be with SMTP id l17-20020a170903121100b00149980977bemr5608445plh.133.1642803097404; Fri, 21 Jan 2022 14:11:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1642803097; cv=pass; d=google.com; s=arc-20160816; b=JiwnZ8zkh/JigmJE0//XyZEkj1G66YzqWqMQ7R76ZE/PaZg7hUxDIhdppTX9ya95Dq 6KPlgcijtuQx6NBsPI9bMsKL9xLx/o06GCeGKd/o+4qd1rFK/J2tf0W8TMx06RAbi3QQ TiPBUj/gfoGGGzTwGA2J7gonO5AEaqpmNlvko6LycUPQ+5mxxfvg8ISeLUmPhXUfJPh4 jTdKjdEcuqp5WT7eidsLzKkQeotmwj+Nji2HBdRvO9iL8rN5J5KVJWiGpoWn73BjvqzS SBCbuKejuWyPaxPR1vB14GlP6jdemQkYlgV52HBIN7dHI0GTkOQk17PdTeYdavGvTVDl fv7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rroq+rsrmX/YlTjtXsPZqI++N/QU2HLd9kAmXQDrD5E=; b=ogxossC08phBjbCpeabEOLrQqHlhuHpbUqEzL4E5oJ584QmjWUPXdzmM369AC9BYeB ygM6RpGrzXITi2DFjf/VqyUJtLKAtZbEJ4fm/YyERHwaudHRoxRpdUCZbb88rsNsV8y2 EgoXd3VJIGz+PyUB1tB1MARLqeFCfbcWj1RIDacnHTTgZN9FZ2cBO1Qm9mtf9v2NjfIl 4ansHKPJtPa13CWH75uX0umribdVv4xYBVOuF7YSYdhInTHEqoLU7tv5bxvs0i3N4KBa DRs5NBSVaWtVlnoD+ys5++rXx07ZB2dguCyGKdqWepcJexEQoN25Pxqx8C3wj2dXw5wB hwAA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=MwdAOXp0; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mh3si8386648pjb.126.2022.01.21.14.11.25; Fri, 21 Jan 2022 14:11:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=MwdAOXp0; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244561AbiATNpY (ORCPT + 99 others); Thu, 20 Jan 2022 08:45:24 -0500 Received: from mail-dm6nam10on2080.outbound.protection.outlook.com ([40.107.93.80]:36287 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244616AbiATNpD (ORCPT ); Thu, 20 Jan 2022 08:45:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Do5KuYn30UlQ+y7mVhDJ/m7LeXv9uGr7YW95v7OCWcUB1rcxJC0cTlcsmuDlWh8QyyGcmKHXwGkDpfkuebK+xY+zYe7ADHAxplgKIu4q/TRStk2cGZmQKyV9ZigdXAg7zuhyyMflZFdWYjbtKXmMET0p3eWini1OfHpLJHX9qYKx1elIhQa+HN+7g4bXuk8aZBjJ6Jc8Rj0PEUhcVzXWCnlgXIdrQCmY3lAtN37TBZsbrUeZ6I+5K5mnhLNTkT7Ri0wJPExkFTqcPDskzVhEnkadSKNMlyp/BgH9f+YLaySpNQmFV/wcvQkinmHhGLKudwYyT28EHsrKN2FZRvYa0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rroq+rsrmX/YlTjtXsPZqI++N/QU2HLd9kAmXQDrD5E=; b=ZndS1hAy+ZUePeT687VLKAPg3Rx3QXynHO37tqgbCiQIWtgE/J2nGfxlRMDhmbUUWXFMuR3Q2gQMRSN+f3Hqg3R7zkRvnTYmYx/TzypPLd/3dV7AC+yK7c3BQkAiPwN8WoDPdngm3F0K3Nfud6SzgG6ur6bKbmKmfg5GfHRZWegZ0QoIVnTfmntLWoEG18M3FVNiWY07bIddUqgx7/HfSi99lMLZsGBjGdowC1z7cXJSa46jzamu6Fjx3i41JQdIJgHfn1M9Siw8yafCamP1StN4ZR98zu6RfZL5qIvNFhqvqTdVydVApMinVl8z5r/4MIGDtsenYhY9dnQetTze1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rroq+rsrmX/YlTjtXsPZqI++N/QU2HLd9kAmXQDrD5E=; b=MwdAOXp0UibWIb9wl00tKKjHDefTpE0CSyiVq/ohiRIklMQ65w2c2CimllwwXUQn6KrsgfsG7MZHvnGixvs/nD9T7b9PBii7xdEofkcV+fVcvKO61EdXkMMpKVk81nnEGBSLsIeuI6zV1G6kTViFTCWG3xUAbcaxdFZs8xw4KtEUHCXSYcdYQsVjpnB3WxHXB11i28wFf7m5b3ckOKqhZIBA0aywxb2O1NCyzdMVLygOXQE40zemABdoN2QSvltoPlO/3nG6kAfneow+9rRreG1bTiwAIAaFMOYnp0fb29/WFFvQ+LeN8Obi2RSuHItvEMX28nGvf1x0Ttnuc+h9nA== Received: from DS7P222CA0029.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::28) by BN7PR12MB2627.namprd12.prod.outlook.com (2603:10b6:408:25::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 20 Jan 2022 13:45:01 +0000 Received: from DM6NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::52) by DS7P222CA0029.outlook.office365.com (2603:10b6:8:2e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Thu, 20 Jan 2022 13:45:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT067.mail.protection.outlook.com (10.13.172.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4909.7 via Frontend Transport; Thu, 20 Jan 2022 13:45:00 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 20 Jan 2022 13:45:00 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 20 Jan 2022 05:44:59 -0800 Received: from kyarlagadda-linux.nvidia.com (10.127.8.10) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 20 Jan 2022 05:44:51 -0800 From: Akhil R To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v3 1/3] device property: Add device_irq_get_byname Date: Thu, 20 Jan 2022 19:14:13 +0530 Message-ID: <1642686255-25951-2-git-send-email-akhilrajeev@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1642686255-25951-1-git-send-email-akhilrajeev@nvidia.com> References: <1642686255-25951-1-git-send-email-akhilrajeev@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ca838049-da7b-48f8-38a8-08d9dc1b0e22 X-MS-TrafficTypeDiagnostic: BN7PR12MB2627:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5HGGPfhU0CcuXd8pQ9DrKyT+obuc6zil6ugze5RkRDd5fuMTTkmTdY73ZulEUthZwXar2XLvfbNDur90J0ZIX5gs/MQWrwoDOk1RaSRNiGpuuLduIhMsf+O/Rdsrw0G2CrUPU4f4KqYVETkjMPA3DNDB4SUkwC1mvv3cS+i5buH8XYBTMhDHLfvdv4s7nikARiA1PkrJd1klyUkMrQ2py0lAbcqrWy5UTxlnU+KU8MUv+YIy6udRChEwcqGBA1luk87CX2DlN6BAY6yIfDLc7LxJvykGLW4a1jlsbznqU9w3xzm1KyxC2KCwP9jGXABFALXV129DjE9PCULnm1SW7+MdH3GNgyV2f5SB7oKQpQfXzCOfBiGt3uwwDXCZwzXsyp87rgDRoAGAcVueA2Lh3TtAeJF20PFrD+qIjJh+bcAyyj6oNxmLGtHxj5WyD1fFhUVP+OkY9z7o4Fxp+EDcS8vUCEwTPLCH710HbOCXJPLbj9PVKGkAh1e0GiBYdH7pnc303fXuNtZE5i/gsORd/FxD4bSkAf5ll0nGVGfey/YKvHw+CF5TpYH65mKm+dN+2ofOEXvgNHFsWchNnmScmEJrMZasK3iNkJQ+atfigDS0AWPKLKbNBGSyEGgaoH/P2bbKcggG482kokOgVTV3rCv5RcKx7Nhw7mhX4mM/Ok1GzXmc2JX0AWkju1wKuGIho3TvrKzqeeZ344Q3IDFLWHKE6tEcXWyl9Dox3r005mPx7tnhe5PD6I4kaDLIKPw7X0JVZTbBEJxc4FLezfBL8qIN7TnXO5ayE1RZsk+ltZXMLa3Q1OpDsq/O3pWGY3ZOGE/xHMjF9yQ50Bs/cibD+mKNfkWi4BY9AL5SGwpTkwk= X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(40470700002)(8936002)(186003)(82310400004)(36860700001)(8676002)(316002)(336012)(47076005)(70586007)(110136005)(4326008)(921005)(26005)(6666004)(86362001)(36756003)(5660300002)(508600001)(7416002)(81166007)(356005)(7696005)(107886003)(426003)(40460700001)(2616005)(70206006)(2906002)(83996005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 13:45:00.7737 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca838049-da7b-48f8-38a8-08d9dc1b0e22 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2627 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add device_irq_get_byname() to get an interrupt by name from both the ACPI table and the Device Tree. This will allow to use 'interrupt-names' in _DSD which can be mapped to Interrupt() resource by index. The implementation is similar to 'interrupt-names' in the Device Tree. Signed-off-by: Akhil R --- drivers/base/property.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/property.h | 3 +++ 2 files changed, 54 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index e6497f6..962a645 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -936,6 +936,57 @@ void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index) EXPORT_SYMBOL(fwnode_iomap); /** + * fwnode_irq_get_byname - Get IRQ from a fwnode using its name + * @fwnode: Pointer to the firmware node + * @name: IRQ name + * + * Description: + * Find a match to the string 'name' in the 'interrupt-names' string array + * in _DSD for ACPI, or of_node for device tree. Then get the Linux IRQ + * number of the IRQ resource corresponding to the index of the matched + * string. + * + * Return: + * Linux IRQ number on success + * Negative errno otherwise. + */ +int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name) +{ + int index; + + if (!name) + return -EINVAL; + + index = fwnode_property_match_string(fwnode, "interrupt-names", name); + if (index < 0) + return index; + + return fwnode_irq_get(fwnode, index); +} +EXPORT_SYMBOL(fwnode_irq_get_byname); + +/** + * device_irq_get_byname - Get IRQ of a device using interrupt name + * @dev: Device to get the interrupt + * @name: IRQ name + * + * Description: + * Find a match to the string 'name' in the 'interrupt-names' string array + * in _DSD for ACPI, or of_node for device tree. Then get the Linux IRQ + * number of the IRQ resource corresponding to the index of the matched + * string. + * + * Return: + * Linux IRQ number on success + * Negative errno otherwise. + */ +int device_irq_get_byname(struct device *dev, const char *name) +{ + return fwnode_irq_get_byname(dev_fwnode(dev), name); +} +EXPORT_SYMBOL_GPL(device_irq_get_byname); + +/** * fwnode_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 7399a0b..3123b75 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -121,6 +121,9 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); void fwnode_handle_put(struct fwnode_handle *fwnode); int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); +int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name); + +int device_irq_get_byname(struct device *dev, const char *name); void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index); -- 2.7.4