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: 830854 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2082.outbound.protection.outlook.com [40.107.249.82]) (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 18D0A7BB15; Thu, 26 Sep 2024 14:31:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727361118; cv=fail; b=ixvctvm26dAAHsh8CWug5HOG8+7Vj3u7Qd209prEM9l0BoA3XqZYf2tikio+AyH9djWTx7/Xia+cW6hhKy4ceZrezfCC27zJKKbetXrngXEGJKdn5I5qemibzG38uQZ5pa/vhNppA9HIUuPgKswCdncbGR29BpKhou34SqJoncM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727361118; c=relaxed/simple; bh=WK4Owj4Y4Cm9P4MpXmjHW4vYZ5KrqTdjByDfuUp5bwk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=So+cnFELSk/q7cTs/pVHiWcqTlgdN1XSgfrhpeWzHOlp3J+5gSNiXuJlfTtmqGsUVBgyA61BUSVNdFrwqu3RH+EOZSgCEutSrWl/9HqJy359Z3INNIV+q/4ZhfSb2vR7lw1dkd8AMp5HcAlCjf9DGIEKN+zvugrrvG8ZUN6NspE= 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=JRC5ROS7; arc=fail smtp.client-ip=40.107.249.82 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="JRC5ROS7" 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) 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_|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?=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ZqRuEP?= =?utf-8?q?VURGrvo8D3M7YlGRTrc8ofuFaOv10ewlTkeIjD55YOiVof5Wt2WFTim+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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fIRyJSYGhatpw?= =?utf-8?q?Mcxjc+0eW6KmwB2sdWAlZwNXc0W0ZalJXRIEjME/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 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,