From patchwork Thu Sep 26 14:31:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Stefanescu X-Patchwork-Id: 13813423 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 74659CDE00B for ; Thu, 26 Sep 2024 14:35:43 +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=n6PY6768ZdL3bCTpVR2WM+LDAQ DqVQiJ8qe2sbj6riewn6dAoXTKAToUIrB00VSc8MGCHu5hq2Rz3CbkoBEODF1W0Rkxpcab4uvaO1v yJTbT1rwzJMQVuT5Le+jdgbeL6i57vYEB+8NBwT3w9k9zsEGkJ5ZzbMVkOwHY22ZKwMNpIw7EvRkB 2UFUWcN3ki3/RG2htbx9LvqDL3mOL2RglWWP29QtP2InlWpF5o6/NdAJD6SvioQCd8erFhAZjEJCT Yx8Y34JUvKq6HD4y/u5YLU+f7oAOg4V0mwTYpPUTDfFwIeyS8G8SBsKSBrnnTD9Xf7QT6Tit+VKcP ma+PJ3Vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stpaf-00000008cZv-2Qa4; Thu, 26 Sep 2024 14:35:33 +0000 Received: from mail-db5eur02on20603.outbound.protection.outlook.com ([2a01:111:f403:2608::603] helo=EUR02-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stpXJ-00000008btR-0GT0 for linux-arm-kernel@lists.infradead.org; Thu, 26 Sep 2024 14:32:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EE7p91owIunjYham61i3wuc8vLQkJ06ENzIwjCdD33i3X5/rI1g6Wd7RbecOFy80KxxDj1ehELI+8qM4TcdG0EwB4rDWXcXpCYPtaylzBLQMqt7XQoLxFLurRJuCMeoMo6z30U9ahhCWSpwLMCN5qnUu9IE2C4sNtsQznGjUpaXwypjxor67aQsN0Zn9Mb4wPvdcMUdZxtjSPqnAFP3a7awIB/FXid3uilteGUa2fE0U/SwWejQ55Q9ZwcyT4BQ6WtobBDLjZDG5enMNjQRw2irhXHWl/pclFsBHOBT78JojvCf5NDVAWj91e9TFi4Hr6BI26q4EiOta1EQlesXB4Q== 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=b/KSQwKbycKb8HI8OSkpvNTv6PgipAqoVxUPG+i8Al7AriwjDWdpOI37ZEoZfZ4iokIdK1wKSfey2tYaig/639fyMHYkqzMcAHg98T/Jna9cpdQEaMN8JgqPbzzGIglQvI+0ZIN/9uq81yr7PEI/2CbSF14E7t2/lonjZHcPIyuMgDrZIwfbv1CnR5YlBr5YBk+4wRAQBhde2ua0vq9f+V1qXkPPPtIj+FFqpePQK5PR6e3ykdGreuJ5HnwfsyZDxp+uTLUraIvLYkvXvjTW8OXQOTbQw7Kj1eu+x/bS7f2Mj+NYCMOxOu1wEAqGcI9bs1GYQsmYsxSNqljoj1nrNQ== 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=JRC5ROS7l8dw/uBRp8lwMgaoZZ13ZLmkTikgpHQXwEod/eKLJNw0clX9m5V8ZPrc72/GrGt2qzJFQe0yoQ0EoJLmmlQR3XpEB2QLrd9uCQSK7V1Hu0zT+I+KyEnQ1fAhFQwO/LUEUR55u1FVPiRFa1T/yEHpgcnYQ41kS38EchyWjcK00XrP4elCDDl2BkdZCJ/+iICFNoZbMwW6rNOxG8i0Q4p9WvjSQOh0oL7xbw63eZzj8Cg6rVxsYZND4MRlR463cRwes5sIBP/L8BeWFtXxxXDpln/D/A2QLPd1ef7d0UQxXvyKf9ovYfY3wkpjnNDhurs0NRSTLdY+9dJgTw== 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 GV1PR04MB10485.eurprd04.prod.outlook.com (2603:10a6:150:1d4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Thu, 26 Sep 2024 14:31:49 +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, 26 Sep 2024 14:31:49 +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 , Christophe Lizzi , Alberto Ruiz , Enric Balletbo , Andrei Stefanescu , Krzysztof Kozlowski Subject: [PATCH v4 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Date: Thu, 26 Sep 2024 17:31:18 +0300 Message-ID: <20240926143122.1385658-2-andrei.stefanescu@oss.nxp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240926143122.1385658-1-andrei.stefanescu@oss.nxp.com> References: <20240926143122.1385658-1-andrei.stefanescu@oss.nxp.com> X-ClientProxiedBy: AM0PR02CA0101.eurprd02.prod.outlook.com (2603:10a6:208:154::42) 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_|GV1PR04MB10485:EE_ X-MS-Office365-Filtering-Correlation-Id: b47601cf-143f-4d45-3fa9-08dcde37f4e7 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|366016|7416014|1800799024|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Zx6ZfeX0HAv4FYokkZz+IoQaskERXS8?= =?utf-8?q?RyNGhU5EOMiQG0BNYqAwrVwfp/cUcRZDZNJjILDEezTKiMef7CTonQOhko7pNMGpW?= =?utf-8?q?bkojXFFTdiqF6l6z16LvvNHH4P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rc8ofuFaOv10ewlTkeIjD55YOiVof5Wt2WFTim+fdMpafRFW?= =?utf-8?q?G9f14Z6tDYG20me7AwjlijI+lpj2MdHWPi4t2oHkvqejrk7u455aWX9rBgFJpxOMJ?= =?utf-8?q?FOmX2uHQZ21JTpGvNkn9r1ULDON13gbuTBGE48UvGQCmUXdDZnhKHL75cWzGWVSFr?= =?utf-8?q?Sqd7TI774+I0yOsWjW9m5PwdnL5Wb8yCvayehDft66T7YpOeybpjldBprCm6AdEja?= =?utf-8?q?BtSvoqjphXX8y8LqI4o2IUfi+R1xep2BR/mYgtMsivAWug+dqkPAXz/X8sjDAcW/5?= =?utf-8?q?2TZP0tbSUejWPJRrhfNtx3yXs/GWFU35T+vEbzB/XkMbwxDr6hvd21TRrLachQWg+?= =?utf-8?q?ISMwBEAVQc6L+GTkoeLgl6YVdsmEarqS2Q=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)(366016)(7416014)(1800799024)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?1h230QhbSjY9seyc8kM7deinIEGI?= =?utf-8?q?xS/dCstWsXDRhFSzyCkYlUWf4FisRnqRxZ3d1YUXb4vpOm4GCuu0C25rkLdX4Y61k?= =?utf-8?q?DuzJUraOn9ClZvPqNgOcwg8fx0wKH8qx0ItQv8BaXlR+4PDnQ3VL0WnhOKajIqRuN?= =?utf-8?q?BWdWLdzDKGpfUeUULdz2ZRJ3flUbeQQ/yocpV6wSYzi7rRFxiK9DwZUVVx0ulGJdD?= =?utf-8?q?pfUK3kGAAPWupuwf/uFmX9BN/gM4G4PeSRK4c870/oFyTYysBSPiMRWfXy/tKxSNw?= =?utf-8?q?gjkP9b7ysQmtjyq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6KmwB2sdWAlZwNXc0W0ZalJXRIEjME/IkL4zhZubjtAvKI6mJuRyZvk/?= =?utf-8?q?PD/MZb5zmiem7vEGK7HB3h9X9Ji0K6+1BUtkA4dc6QQkaw0/2d4p9JHCuC6wJ7xdG?= =?utf-8?q?lqk/n1+ehUKA6o/zH2Gxeu1lqxRI9rgQ88wnkstA6+sIz+UqRsGR+v8O8LMH/mpJ5?= =?utf-8?q?n7a16JkemWyHMGtxxeB1jarFp/M4lHxm0SKAesxn8bg4wfCWBp4ATY/9k21EfnURY?= =?utf-8?q?9XpkLEOjM95Z7XegSinNzqKQsPq9FWdN6bWdurcHeOsIB6sUroHbIJ+cpauzhgb/C?= =?utf-8?q?v0XpJ6WfXQZoQU4V7tc4AV+tQ0T9JOhUVmkmW+hg81CBSdamM9uDHDlinIESnibCq?= =?utf-8?q?+n6+3SR37bDajV+TbQNi7fhmK3Q/pwI7Fg=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b47601cf-143f-4d45-3fa9-08dcde37f4e7 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8487.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2024 14:31:49.5412 (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: J6dh7ApVk6bfBmGDmHtAMwk8x3rRxVQF1grl/stalq3eiNF0ugYzF132S8l0HrqTXuN2MYqF/P0q2UyXpw651TxAI5S2AI+zuKiOf7vXoLU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10485 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_073205_135204_231E9C00 X-CRM114-Status: GOOD ( 14.42 ) 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,