Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3070553pxb; Tue, 12 Jan 2021 05:45:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUTkmvvLGieDs4s7MlWa0bOwo5a0tUuKIfeq9M9oVSghuHuGu0eum35ixH38vQKQzENfLz X-Received: by 2002:aa7:d3c5:: with SMTP id o5mr2007612edr.122.1610459120601; Tue, 12 Jan 2021 05:45:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1610459120; cv=pass; d=google.com; s=arc-20160816; b=ZPNctcyY9sY02W/DSZ0H5yVjdG5gEYarojsap8pjuzu15JP835kP1CObyLSaDvejYR J/vyYyJ6dx6L3zYzM1gI3cCWX5QCsfYopjZ2M3ouMM0pwDy35Z7HupitzF8OShTEz2gJ D34Ue7bVsWhNkrkP3mhwmEWaPftQEqDyC23L6qlOVmUS8nc31BB7sVTnV3pfafT9xCVl oqP9BMaq/Yf6INa69ULVNwFNa1MebKm9DvIpreSOwR71FOi7mkilIWTCJqUD0vvP0yqp m7HzlY6hzcv4Mh74bnhzSHIOvDEVQnFi7ME47LQcPimM5fpcU0inO66lBDKBCJYbX8kw DRaw== 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=ouGFRpLMuIbmZVMl5ZYy3uKZqeV45JbADIdapydMn1w=; b=tSKs+n4DqUNzx/tVMU6UiJw2AU2colkDNC2MNg2pJzpN2XmmEMwanshn4G9WF0jnr8 A4hgUjI1jbDqRh1C/gyNeMPKeSp2YlsE5jZGGURxNuAxp6I67IIguAuptIsdQJLp3lS0 id8056g14fJdV3XwmciNjoD+fQJ7J+vP+m8Tz7DCqCF+0MjyoL4vcHghQy4FpBTF/6j4 aVXZ/1DzoWb3dOWmV2q7fJJDqe3S0998tSq/idhOlTvseCK1boa5aV2HjT4Wq8fGsvLD V4l92r8GJpxjuqyZl3wzAi37TmGAuQVTK85cigfjyylM4I9aXceRaRf887TNxURjcmrJ gORQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=OA7GpZSD; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si1428205edj.194.2021.01.12.05.44.56; Tue, 12 Jan 2021 05:45:20 -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=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=OA7GpZSD; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387709AbhALNnc (ORCPT + 99 others); Tue, 12 Jan 2021 08:43:32 -0500 Received: from mail-eopbgr00079.outbound.protection.outlook.com ([40.107.0.79]:33088 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387542AbhALNn2 (ORCPT ); Tue, 12 Jan 2021 08:43:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxIUEtaa0Tsh+cyPeEqLnzdXS2yTjct01pEVLDjlQQLDd1E+maRVtPFJ6VS/5G0CnaSoxNTHPqH1jgAYGqVMeKmcg9dRkaCyjGr6nQjIPf86JbvKeIw3VUbTGAswpRZi77B5gOOiUObap9sdh1UFeyRGzNQHbY3WIT5fACIZiywKMYxWzAMV3wbsPJs3dK1IT/yKpoBCKPP8b09Heu51ezBB9LNVdCImNO/xjHnimMSCbg9qFyWxSdOD1SBhvR2KHvFR4H4Z2cA6AbjcmMdTzGyRxEombukuNNZDsD5lkUy22JWP7NC5T7XS13IOevzJjletFMkHE8BTbaAcH4+cRQ== 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-SenderADCheck; bh=ouGFRpLMuIbmZVMl5ZYy3uKZqeV45JbADIdapydMn1w=; b=PxFrTw6tl/Fe+CbTMFh8YGflIB7HPmxMagkLKU2yP6rMiojbEpcjvVB9jVdPuchHksrcxJfxXiOpQwCJ8WL3UTeFWDn73J2vvheagRtgaSxSgclTxWfuWxUD0jEm+4mVzKI3RMe2+B0o3dNGjHkPYiJPj2LoIsFCBTc1TmpMqUjSc8z3dkTBhWEkLqc+Ir78N+SPz7cR99AeqYuQugHeiC+qcBm5t94GIhntYb542FksvAekkM+9mw+mqoOKHQc7dF80sDwGJbUK+R46hpsmX2rnkxNtEBq39qAfVBC36acT1ZIvxIohu8KegHhT1HD6Q3Adqt1jJAG62mTXfG6DZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ouGFRpLMuIbmZVMl5ZYy3uKZqeV45JbADIdapydMn1w=; b=OA7GpZSD7oBfKReg9dhM+9QWBXsufs32pthgegDoyiGsSPgRz8Ruo5BPIAIHm2antXX3y+OWiqAZGPVPoaRyR5QyUNnGTRK9CnKBOKCGxc8kVmQcimvlpdCslX6HFybEqrMslMADwp4cZlRiqy/SlyBCeIH9RDav0VlgyHiAq64= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM0PR04MB6436.eurprd04.prod.outlook.com (2603:10a6:208:16b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Tue, 12 Jan 2021 13:42:38 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::a891:518d:935c:30dd%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 13:42:38 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon Cc: Diana Madalina Craciun , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Laurentiu Tudor , linux-acpi@vger.kernel.org, linux.cj@gmail.com, linux-arm-kernel@lists.infradead.org, Calvin Johnson , Andy Shevchenko , Bartosz Golaszewski , Greg Kroah-Hartman , Laurent Pinchart , Randy Dunlap , Saravana Kannan Subject: [net-next PATCH v3 09/15] device property: Introduce fwnode_get_id() Date: Tue, 12 Jan 2021 19:10:48 +0530 Message-Id: <20210112134054.342-10-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112134054.342-1-calvin.johnson@oss.nxp.com> References: <20210112134054.342-1-calvin.johnson@oss.nxp.com> Content-Type: text/plain X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:3:18::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 13:42:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f3a8946f-1c03-40b0-1095-08d8b6ffece7 X-MS-TrafficTypeDiagnostic: AM0PR04MB6436: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gyrK0owDepij9K57ilP+mXejBPVRnnmZsc7YwkoNZ6M+pudQ3gPPubzRnh3PuLNvpzYb/w5fo38MWxcbDnP1PCY/g7wcUygtY2Z7WImPGz8r/UXc5ymH7I6wj7/SBOO8iTkcZhhYuBtqxNbfGvDTrBb16zRB/iTPllNdwKIGl0VjGvlAR+Npi6dpEDrPQMjFvW3omP33J1eGTkMuXGREj5Wrj/paEW0Kc3pWoX+Vt8wmPhpQKPr0rPWqNS/YQxjvWUROEbjGP3Nq1/gy0YK7Lb66QN55MTsgCPhFTfC17xxNQR5N4C6mUopfwZERCeM1yVxHd2G3Kik8YboOnDlBhVTZhXSvr+d09lgqQ01SBLQZ5bLaM350mBST2FjYgx4XG3Pk4CnpdGxVON8hrQRM4wHMnCAHpP/9vs5WhoYt3OLT75cs4zvYxEVEBMl4G57avHWBuHCOx3YoDZC+rc7gbg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5636.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(376002)(39850400004)(366004)(8676002)(956004)(83380400001)(921005)(6506007)(66556008)(478600001)(66476007)(66946007)(6486002)(8936002)(55236004)(26005)(2616005)(52116002)(16526019)(44832011)(4326008)(316002)(5660300002)(1076003)(54906003)(2906002)(186003)(6666004)(1006002)(86362001)(110136005)(6512007)(7416002)(110426009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?l28qWYgE38+sUJcGLODE7liYlQllDCn4sUB2nWEmSEsS8K8EpCyrb9sdnFRl?= =?us-ascii?Q?Uyclyo+O1Q0t7/eQ7XDdian4dgxCJm8rCWDlDtLlRflhWbrpTqG0JnuvsrW+?= =?us-ascii?Q?1yqnX46I7rAoZpPegdmk5eSxQiNDmWAZy4cpA5uvI7RrzEG7IJXgVZ1jft6N?= =?us-ascii?Q?YB80C+agkEJApgDCbmkT/VJ4e29aegP1hqTEoNHMXaIv0UVj3X2W4C9Ka1zN?= =?us-ascii?Q?0r3uJqOkgV4c/A9yGM+I940uakRpkWqD5larCI2aRJ5JfGOI+0RiEZ7aBx9y?= =?us-ascii?Q?TrASgkSkv6nas3ECeIWvae3VVtOn1qn2yEGSBNHkV4j2W7XSGnD3DgFQm9wB?= =?us-ascii?Q?167cxh+o+y0ZnyjhQtxZFOso+3nrfhDVx26C9NM1ZyXT2huKjg96H8Kzft1X?= =?us-ascii?Q?yQrJ720grahrxQURwKh4KyJZXL/eoFp4FPwnD3OU0HfnQBENuWstmiqytTal?= =?us-ascii?Q?Uwumc8kcRoEDFkzUq8ujT/3UvuKZ9sYiMMSP+kuxBvCNBRTMPvKUdQfG8CnF?= =?us-ascii?Q?4LqIiMh3zXtp3pSFqg5o0dVi8MtFeRocdLklbVa1DQj/POTeSPLz9OIP+GvL?= =?us-ascii?Q?a56VJhHAF/nMcFLVumHVPLHd+jZ/sdDSOS/qAvM190yLYtwVexFKaMr+VaoI?= =?us-ascii?Q?M0MOCWRASLbCvyD4090aF4e+bXRxeKsoh6VnRYTRkkDLvF2lWH5Dg6Wco6Jy?= =?us-ascii?Q?hnVNLSo3YKZhmZiAVsFoitGXYncCpGXpngOkpyG3ZGxBINH8DOGTU6QoTAHz?= =?us-ascii?Q?apYYg4/0Yo9KJSsTNr9dNcMs7kkMge7Z87RGpRo8VYVpKqG1+M4nhMuJ0ILt?= =?us-ascii?Q?jN5QQZcZbWc6sA9B7XQCAwSF0Muf0ThtCX7oNfkwZhxbBrukAeqG0KKULjNh?= =?us-ascii?Q?MEQy0qfERjJtmQa4L+IERg7ZIW7EtufdLKK4JCvPs2KS7RT/ODRbfDUr/OPq?= =?us-ascii?Q?b20IdpIP6egTSJagiKyxu+b81yUNLqIxeJivYHUkDhDPAiGfETB1oKzmoiHE?= =?us-ascii?Q?rjRz?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2021 13:42:37.9337 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: f3a8946f-1c03-40b0-1095-08d8b6ffece7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FbTZc7H8tilziRCeOzE9HTh1vfkWdhnfBiMuQbKAqBnD+YekZsTx5olsD7NXcmzIrCZ1aMRrrnTAC0KfQTCLZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6436 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using fwnode_get_id(), get the reg property value for DT node or get the _ADR object value for ACPI node. Signed-off-by: Calvin Johnson --- Changes in v3: - Modified to retrieve reg property value for ACPI as well - Resolved compilation issue with CONFIG_ACPI = n - Added more info into documentation Changes in v2: None drivers/base/property.c | 33 +++++++++++++++++++++++++++++++++ include/linux/property.h | 1 + 2 files changed, 34 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 35b95c6ac0c6..2d51108cb936 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -580,6 +580,39 @@ const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode) return fwnode_call_ptr_op(fwnode, get_name_prefix); } +/** + * fwnode_get_id - Get the id of a fwnode. + * @fwnode: firmware node + * @id: id of the fwnode + * + * This function provides the id of a fwnode which can be either + * DT or ACPI node. For ACPI, "reg" property value, if present will + * be provided or else _ADR value will be provided. + * Returns 0 on success or a negative errno. + */ +int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id) +{ +#ifdef CONFIG_ACPI + unsigned long long adr; + acpi_status status; +#endif + int ret; + + ret = fwnode_property_read_u32(fwnode, "reg", id); + if (!(ret && is_acpi_node(fwnode))) + return ret; + +#ifdef CONFIG_ACPI + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwnode), + METHOD_NAME__ADR, NULL, &adr); + if (ACPI_FAILURE(status)) + return -EINVAL; + *id = (u32)adr; +#endif + return 0; +} +EXPORT_SYMBOL_GPL(fwnode_get_id); + /** * fwnode_get_parent - Return parent firwmare node * @fwnode: Firmware whose parent is retrieved diff --git a/include/linux/property.h b/include/linux/property.h index 0a9001fe7aea..3f41475f010b 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -82,6 +82,7 @@ struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode, const char *fwnode_get_name(const struct fwnode_handle *fwnode); const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode); +int fwnode_get_id(struct fwnode_handle *fwnode, u32 *id); struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); struct fwnode_handle *fwnode_get_next_parent( struct fwnode_handle *fwnode); -- 2.17.1