From patchwork Thu Sep 19 13:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Stefanescu X-Patchwork-Id: 829711 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013022.outbound.protection.outlook.com [52.101.67.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B67619CD17; Thu, 19 Sep 2024 13:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.22 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726753745; cv=fail; b=eGZl0sCi3eWPUZWjO9JBc3kJBnOAEQnTpDwV7ud2FE/0IeP6bjv5FCuveN0EORDbmyRcUHluX13CttC2LgDAkSjSF25hcz5ijxflB/Dc/nJKN98eUsNe+9wa3gQpeis9Ya0XxIlO0MYoHNa5MzPBoFLwDRT+p9sxk1eVUZg7H9w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726753745; c=relaxed/simple; bh=WK4Owj4Y4Cm9P4MpXmjHW4vYZ5KrqTdjByDfuUp5bwk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=d+qDmyGPqgjLmA4T0L0lP2fyvjMZNsBSb4LiK7ih5eOId6twS+tjV3yx7BmnaJsSAeLheA6FGl1MC5s3cMMSh33o3++I9lyj2LGQ05DIVWwR/7Hxhd8OrMaVMmdZOkR3yCWrUWWBqz0Cxb396H0u8yQPFjYk1rgcz/bcq+LDFG8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=LAulT4G9; arc=fail smtp.client-ip=52.101.67.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="LAulT4G9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h3RTtupFJhDBM5slP9UfkwO8XkY2GekZeQ171kDvc/BX44yVys1CMYyD0Bp7L0FXt/hKeclPO0p4URT8YnZqCuXjdVMRjqMC7nA2SCDbJUwLjthdX3tNQmelzRAW0SEm4b+jmVEtpwE+PwjBT9goe62+lOyjP7V9sZO0DxzQ7UaFlg1uc1eQSyTAVj6OijuBrXVg5Az7SyQdhF9guZ8OJPeSgRZHccMOZ8f72wwiQzZMYjommFOlbRwZDULdfnYC70uSsvaua+cppl5ya7U96WbQp2BEmUhwBiJfyVlp7M3TUiRxfjarDhCwp7N0LEZttzu6BV7qXnBeNcTaVKL6BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HEHYVemPzQDfpMdhfbuzyQ4zV5E9zOILEQA8q0JwEiU=; b=GBl22elodIIPnPrOGf7yhuAzioodqVBfhuXV/1C2ZvuOmgJJF12qBwV9qq8GuxV6wCII5oTtepbYTTP/qTHQbRz6J6J5TCu97tQpiIYhsxG7W25VF9sWZed8wr4Er4gNWQ/gd+nUJR5ovQFbkTBm/rAqKJPUZKoaOiMkA2OXxz2Wq11DYp8T+WqHFVAnCnNKucGE6LgKvmBvhmpYIckihvhShicxYH3Ya5Kjg86m0frgaBISsamiMFplPusSpmsgCWRbsAvvHUM+qCMYemu3SyYNdX/AQ0rTGque71NrTXiFR7b5VhsKjc+TDjhwjxZwpJ6TuebygOtpTetl1z0OYw== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HEHYVemPzQDfpMdhfbuzyQ4zV5E9zOILEQA8q0JwEiU=; b=LAulT4G9v1KEzUWcvfStcaEZjMsl6ugV8dSWuyn8uHknzWq5mBcFy3wQI3ukLxyYn+AzZBYTyp6Gb7gy7IMoA59es77Spzufd6QWikX9BuVMEylJSbYZS3jV6yN1lj1uaRUFVhmEKI0bPr/zZxvI548JKOn0b4fCyE0tfQpEUgTlBGOAEyA5KE8P/vd1zWsJVCcYF03h1rV0BlkspMiL+m7THS2HO8jYwlOseL7uLEPQJZg+B2h+eecpyeQRoNIs15COzLNF/pziBup42Rm5Z/wNgnuu2+5+ksNp9Jx2w4XpqYoy6a4FmNtt4G6fuuugR3z6tBotv4ervrXIH9HlQg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM9PR04MB8487.eurprd04.prod.outlook.com (2603:10a6:20b:41a::6) by VI2PR04MB10267.eurprd04.prod.outlook.com (2603:10a6:800:225::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Thu, 19 Sep 2024 13:48:51 +0000 Received: from AM9PR04MB8487.eurprd04.prod.outlook.com ([fe80::6d7a:8d2:f020:455]) by AM9PR04MB8487.eurprd04.prod.outlook.com ([fe80::6d7a:8d2:f020:455%5]) with mapi id 15.20.7962.022; Thu, 19 Sep 2024 13:48:50 +0000 From: Andrei Stefanescu To: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chester Lin , Matthias Brugger , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, NXP S32 Linux Team , Andrei Stefanescu , Krzysztof Kozlowski Subject: [PATCH v3 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Date: Thu, 19 Sep 2024 16:47:21 +0300 Message-ID: <20240919134732.2626144-2-andrei.stefanescu@oss.nxp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240919134732.2626144-1-andrei.stefanescu@oss.nxp.com> References: <20240919134732.2626144-1-andrei.stefanescu@oss.nxp.com> X-ClientProxiedBy: AM0PR10CA0109.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::26) To AM9PR04MB8487.eurprd04.prod.outlook.com (2603:10a6:20b:41a::6) Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8487:EE_|VI2PR04MB10267:EE_ X-MS-Office365-Filtering-Correlation-Id: 43152e2d-79fa-4372-2929-08dcd8b1cb04 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|7416014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?yEg/CjfDZ6i6d0DUME00GYcrt9Def4l?= =?utf-8?q?EyycLChiPPNOHMPEb0y7UDwskCUbpkSo3/VkYYs6imYbPgypy6efKJIa8/+anmEtE?= =?utf-8?q?bxXrqR7CQlm3KOsGRwxHQl6Bu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uoPNDqT1KmhhDZ4URSlYrNsH?= =?utf-8?q?soDFrDeeMDB4+2jlQgtUboDPUFPErwMhMy0F0JMoaugd5m2MnsXUYysczMAAL8LUY?= =?utf-8?q?oGAf0ndeoHeaU5WH4S9WisJapUUQE0P5ZPnXPPIjWEcg+EplYrG2tsVM6etU3MSa9?= =?utf-8?q?qsd/vF0rf5ONs2oj2gCtp+XY7WA9kIMcvCjC4lanG+u5ZXlmqxGOlTbShSmHk736V?= =?utf-8?q?RlhCboazN6y1FsViDtDvHtSJ9brQG5I1M2xMteX/iz439nyFSS1UwRyuG9Gc7IbsG?= =?utf-8?q?OJ+2sUhYoExcwKoQUbnTjeDYqq2gmM8nFKGGyaJcipV18aRrWeS1s54nCfd0p/Cjj?= =?utf-8?q?ld8UXIdYP9DpSctjUjQ+XRWoaxlxNVEqiA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8487.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?gCLlUU+k76f+yBs7UM73Bm9hc7f0?= =?utf-8?q?Ore/jEJqJ7lhMWXivRqmmTy+pb42RndHCsgEKEdDATz6cG78Bv8+BeEOcV42G8yBX?= =?utf-8?q?DmOmYehpp0M9BaTY1C8LYfT/v8JWWs1QF42hSy5NXBsliN56BNJXVaufpQNkApQcW?= =?utf-8?q?1akKt4t0DKJzRFHgnwhby5varuz7iv3FOeLbqQ7wwignhTkf7nf33ODZ2WqfAUsXO?= =?utf-8?q?5eqZfAmO+YkFSt2AqgztSVC/TAJXnQDu2UgEXstryyNOi5vbsW00gi5h2hB5f/cyX?= =?utf-8?q?iV3YImf4CI8TuB4ARCLSDwDQQjorUf4RV0IF28J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dD3rZ2StA1fcE7iq?= =?utf-8?q?iQ/QmDqQa9Wkj5U675OrD0cu3VCaEz/hdXITLVolgc0r7Ac8g5nILIKTFlOUg0P5M?= =?utf-8?q?S8EZ4lm9u6iJkfm9iC021SdddSwRcRL717pxr/X6b7Kk3YbtWepNLW3anfa/N7CJu?= =?utf-8?q?IFwgE8z8hgdysTgOzsi6FU616S6SRyPJrdUropWbtW2UuIT2RzRQe6AloGW/wSfb3?= =?utf-8?q?pCLxFd3++BCo7Wz2RgM8/Rsb7V4sMjUy+TFy0dYOFjV5AV3xGMaPi7GN9KYOuTTOA?= =?utf-8?q?xg+njsUVlGzj/yR/CRKyOPuV3ostJtOnmAvGxjD0PaXeYZME5PkEyaGoik4FzKx28?= =?utf-8?q?dvR3KaUs0omCHYE3p4T49dm3YwXVoQNi8w=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43152e2d-79fa-4372-2929-08dcd8b1cb04 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8487.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 13:48:50.8422 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Md9XLRUwzCxo7ePUyx4nV86hJZb+0NzUWMcNYQINp2hG1LTn/eFp+VuEp0GI+qyfTjmxegFfecnFd7xWu3qQ5yUO9OLzU93LIUFrADcvLwE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10267 Similar to commit 890cc39a879906b63912482dfc41944579df2dc6 ("drivers: provide devm_platform_get_and_ioremap_resource()") add a wrapper for "platform_get_resource_byname" and "devm_ioremap_resource". This new wrapper also returns the resource, if any, via a pointer. Suggested-by: Krzysztof Kozlowski Reviewed-by: Matthias Brugger Signed-off-by: Andrei Stefanescu --- drivers/base/platform.c | 27 +++++++++++++++++++++++++++ include/linux/platform_device.h | 13 +++++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4c3ee6521ba5..da6827f9462a 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -108,6 +108,33 @@ devm_platform_get_and_ioremap_resource(struct platform_device *pdev, } EXPORT_SYMBOL_GPL(devm_platform_get_and_ioremap_resource); +/** + * devm_platform_get_and_ioremap_resource_byname - call devm_ioremap_resource() + * for a platform device and get + * a resource by its name + * + * @pdev: platform device to use both for memory resource lookup as well as + * resource management + * @name: resource name + * @res: optional output parameter to store a pointer to the obtained resource. + * + * Return: a pointer to the remapped memory or an ERR_PTR() encoded error code + * on failure. + */ +void __iomem * +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev, + const char *name, + struct resource **res) +{ + struct resource *r; + + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); + if (res) + *res = r; + return devm_ioremap_resource(&pdev->dev, r); +} +EXPORT_SYMBOL_GPL(devm_platform_get_and_ioremap_resource_byname); + /** * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform * device diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index d422db6eec63..ab7f33f3c426 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -68,6 +68,12 @@ platform_find_device_by_driver(struct device *start, extern void __iomem * devm_platform_get_and_ioremap_resource(struct platform_device *pdev, unsigned int index, struct resource **res); + +extern void __iomem * +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev, + const char *name, + struct resource **res); + extern void __iomem * devm_platform_ioremap_resource(struct platform_device *pdev, unsigned int index); @@ -83,6 +89,13 @@ devm_platform_get_and_ioremap_resource(struct platform_device *pdev, return ERR_PTR(-EINVAL); } +static inline void __iomem * +devm_platform_get_and_ioremap_resource_byname(struct platform_device *pdev, + const char *name, + struct resource **res) +{ + return ERR_PTR(-EINVAL); +} static inline void __iomem * devm_platform_ioremap_resource(struct platform_device *pdev,