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: 13807775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11D9CCF3942 for ; Thu, 19 Sep 2024 13:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HEHYVemPzQDfpMdhfbuzyQ4zV5E9zOILEQA8q0JwEiU=; b=bxbXJ1DcVbuU6ml5U141n0/9xg u7/jg3RUjVX0sJNe/tZzzvi9Tc3afcVnGCAyHoKjSIVp+lUJ8rofSIxQLQnZKVfjlvcqTaBWr+kIs YcfMtb1+UPhNKrs5qjV6Ab+JbRGudeOLP5NQAvyQagqEHkJxlXSD/Ufa/+vnLdSsYI1mIQiHuO8Fz M0NybDIBEo7c7kpVRsWeSZz9ysk38gI/Dld8ZNiRXiXpb2EDxArnHJsR7jdAKgghqcC2TXaT03QAo T8xp/cuQwtgXflvmMqiZDtdQjLkPiTuKyZsD2lxvrhDJAq07/u2ttDpBnXOgRBFnZ1THEBHScfPqT R4UnRb7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1srHZ5-0000000ANcN-1Hen; Thu, 19 Sep 2024 13:51:23 +0000 Received: from mail-westeuropeazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c201::] helo=AM0PR83CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1srHWp-0000000AN8m-3Spn for linux-arm-kernel@lists.infradead.org; Thu, 19 Sep 2024 13:49:05 +0000 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) 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?bxXrqR7CQlm3KOsGRwxHQl6BuOUCs+enZ9PQydxu8COVqfEMxVS6npItskWO2iaIL?= =?utf-8?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B4+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?iV3YImf4CI8TuB4ARCLSDwDQQjorUf4RV0IF28JJBFYCsJWOtaB2CiZzzphTMbOzF?= =?utf-8?q?DT4AUunP8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675OrD0cu3VCaEz/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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240919_064903_906194_0F26009D X-CRM114-Status: GOOD ( 15.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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,