From patchwork Fri Sep 13 08:29:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Stefanescu X-Patchwork-Id: 13803101 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 84B6CFA372B for ; Fri, 13 Sep 2024 08:32:54 +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=2azDZqodn8AAhlAQVoBzAcvBGio6aTaqiLcdDGJ007E=; b=wzP6Q5u1wA91ISfXlttfAKskgV jpU9CV1khyqQH30PXPb7G/xBIk2rVMs0D5Qld3NV8Jtb872f+ywLKkbZe+bTbOKRbmpmR//tyAuXC z3813+oNBV+cgddrc/7NVs0dcuEipY5gNgQreSW2yIjEq4k2np0MKqq6cY+5gzIBF8+hH3As1fIyo 7I8tUUF1C6dIkH0V3ROrwJaSmLbWyp8yMF+U7GJx3TSUuyBGO7vrAo1qYMRbPIZff5r7sSEhE+YFF U1F9dGXCQD2+TEv9nrSkDBp5QXo9iF3tGdlrVgMFpdmolZ0gmpW0RMVbQfRVeSrpTuWDa1Rh1RXxl D5AsmDBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sp1jL-0000000FLmZ-1DI5; Fri, 13 Sep 2024 08:32:39 +0000 Received: from mail-am6eur05on20616.outbound.protection.outlook.com ([2a01:111:f403:2612::616] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sp1hI-0000000FLF5-2Tnu for linux-arm-kernel@lists.infradead.org; Fri, 13 Sep 2024 08:30:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u57hf/hok5Uzu+ptxvjoTeKAuB4+hRiUlt82HOmC6+SQPfmF/gWzXv9IIkoO1uzR1SeHBW34ET4GpQIOLB1Y6k3UHAs8zCszcI1IWUaKjTILzeVd/vu9tPleaN/3z1RVlpLdTMYdG5XHEyBeKoqyhIouAhbdGz5POkoojcvZM2t5eWrpzCipWoe7/Sdfpv/lWjUFpBUFaV+mItB4HMI7/0d+BFO/YIVl8c6BoyFqcs2oq205bLnM0zsgbItbL1eGvi+NDf+KyTchT2AqER+AZHXUhg3zKHF2ApL7chS5ixMEfqUw3oM8vwr1WmIWjNpFOylQxhIPaRNraBDcPvKcog== 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=2azDZqodn8AAhlAQVoBzAcvBGio6aTaqiLcdDGJ007E=; b=R67aC3I8rRet9H9mVLO4W9F7kKTdt3G7KnAKdDRjJf+GkQptcZkGNhssYyVza39sjcb8bfCT+8om/PWpFmbh0HJqU4yYaaftj+yecoBNkUa1ckzfISyOMsbN/OCARmFKpM/P9C/dA42E0nMKB99bFQ7UgzYVXTgjsis5eMmKZrKioSy0F5ugo0mf8FWFqBlMA60nro0JHIPsEdcMv61Gqg9CkuaTPYugnHjseATjUJBC/qxACepy95EAAtPoKEjHwNeeAiBuYQQtE5vyzMjjLxyzE+C50legQMV7eR+M6H0vWdSV21JqBxaiMiXZg9IMTCh2EYKWOsJXJvMLIV/xkg== 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=2azDZqodn8AAhlAQVoBzAcvBGio6aTaqiLcdDGJ007E=; b=REffQhBtfuo2iX7Ra6TtHFJECszgacgZoRJ5nKOJMO6ydbNSr4JVi5sjcwWX2JXaYRPh2GzGtj3mYtu1zaTSOrLuIBr1jA0eyMIq+TYtk3sh9KzOTog8WhQIggkP1IPcyHty1h61H/6Lrx6o+KUDMdopEpFMtdRWARFj2nD1UOvKVCjv8gZtY8rt1e7C7Gio3XR5we5ywdqn/9bXWwhGYdwE45XJKWoDZjUwEswpr9EkccX0Q36BB9iZglpw9JrvWZFRKR4ASRum+1GmHneU3JEnBm+XOPoL3BxMO3aqpzKZYuu++a7qdhkNa5OAMT9ew57QJbIuyB6VeQkRwTHAVw== 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 AS8PR04MB8403.eurprd04.prod.outlook.com (2603:10a6:20b:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Fri, 13 Sep 2024 08:30:27 +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.018; Fri, 13 Sep 2024 08:30:27 +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 v2 1/4] drivers: provide devm_platform_get_and_ioremap_resource_byname() Date: Fri, 13 Sep 2024 11:29:32 +0300 Message-ID: <20240913082937.444367-2-andrei.stefanescu@oss.nxp.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240913082937.444367-1-andrei.stefanescu@oss.nxp.com> References: <20240913082937.444367-1-andrei.stefanescu@oss.nxp.com> X-ClientProxiedBy: AM0PR02CA0134.eurprd02.prod.outlook.com (2603:10a6:20b:28c::31) 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_|AS8PR04MB8403:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d70aecf-562f-4401-c174-08dcd3ce51e3 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|52116014|376014|7416014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Ctfl9c9Sn1O64LJFIoETVtVChcb7H80?= =?utf-8?q?4btr6tzsZ74z7zJu7KY44PuvQmg0uPnr8Yb9NIm6zflsPAAwg1i/Hvm0Pwl1uj9wF?= =?utf-8?q?aWG4iEMeqwDHod56OTLPERwhYo4JJV5XLl8tGQs2YCz9Hax6xyFopqbANwPpZ2MYZ?= =?utf-8?q?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8dHqHGOMaVrsnAv3dqNRgIvnjs43NmynbMyOY80dYSGjl?= =?utf-8?q?UkIa1LEjAQPHqKLgKXcgNvpvy/dEzQzuqAjDPKq3F3WfOpX9JwhgVdR5+0MLPhpyU?= =?utf-8?q?735VORrmXK8AqM+OblcJE/rWZ5kw1GSUVYtdWrKP37gZ6Mb29J1D7AwZHmnzChCjR?= =?utf-8?q?Bge3GRS+omIv5sH+aOXdnZrcMJh+aUrD2l/HHcn563R+0cNYjXIr6MLESzafDpxur?= =?utf-8?q?ClF0BwxU4M2VVs8ydij2Swt8u+YJcopWkQqTC6udu+7BnBYsZhNQXq8fbRjEHnvPW?= =?utf-8?q?We9UV7tYenYw9QdCan4IDiuQ0Etv5VGq4w=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)(52116014)(376014)(7416014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?dijk7M+I2MWmsShmPy94vc8ZSfhh?= =?utf-8?q?8a0F9NchJxxCpJZiwIOGYAO2PN0eP276jzbTxL8ZwMSVJdn8N7yZg0AUVhaWHCIzw?= =?utf-8?q?JWIFzYe1QS1fLfB0RtQKHIwm6rRpDa0Tf3mSxsgv4g4l96fVnty8P1w7b47ub9g9A?= =?utf-8?q?Pfk+VZAg0rao8qOSdwc9IFtPCUQScd+ctrPbziFs2X93Ps03WfHT1O+YtfRQOzWzg?= =?utf-8?q?ei0JizoBtPVphF2FxZWgaOULgT2ZYPIPtWrDFv6ec34pWmKgTWuaivDfw6HpcfOXp?= =?utf-8?q?s21jLW+TuAnssVvl0uVyL1NNLHOCh9ojM6FWTNoyCO4Utnv7kU7xm/xW++Go5MVx5?= =?utf-8?q?ak34SO5folDEZ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/Bq630pGPx5jb+5IbrEbgsVqXGjzJ4Fp2B0Z1zNL1ZU9ZnqdWz3sC0krzmyhx?= =?utf-8?q?qiZmGjW3qaXrveAbZmbbesyvOWuEBumNz7J4onroWoIEkQ04BrqJ5Ci9QJQ+RaDKF?= =?utf-8?q?RgEsBXwgNIpK6qWRGSsVbDpDraDt0Af7p2+rmY8dOZUppk5E5l/IAPVZWtjZL7HKZ?= =?utf-8?q?zsOiMIg5IHl5ikdou04biYosS5g4aPpLeBpZaC6fG5G8gJLWoWlDOt+kYcnPV8R5m?= =?utf-8?q?0nyyNmIh30pkAP4lKOm8emhy65u+P/+fEUcnCWV3edR0tZgBNXSUTZC84n9qF//0p?= =?utf-8?q?DAxt/N1ndXczPM/VRDJpwpEb0ugX9YZKeQ=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d70aecf-562f-4401-c174-08dcd3ce51e3 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8487.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 08:30:27.2310 (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: 3jJrLIKY/8Q2qBU3t8bfbIvUnwCW9dffIpkBGoCowRPVYoxTn0MDqNJaZLeEZbs3p2EE2K9OLCRaYP9kHYAhZ2RrrddZKn+tiU/RIkDOfOI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8403 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240913_013032_682947_071051EC X-CRM114-Status: GOOD ( 14.97 ) 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 Signed-off-by: Andrei Stefanescu Reviewed-by: Matthias Brugger --- drivers/base/platform.c | 28 ++++++++++++++++++++++++++++ include/linux/platform_device.h | 13 +++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4c3ee6521ba5..ab48c02fcb2c 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -108,6 +108,34 @@ 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 instead + * of the index + * + * @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,