Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5850727ybl; Tue, 10 Dec 2019 12:32:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxgiFBmAx6nezmcKYI+cbDgae99wXq1MJIMGC6zSY9f+DKMfA4vb8QXr7gaId3ytZCqt68q X-Received: by 2002:a54:4788:: with SMTP id o8mr747999oic.32.1576009961978; Tue, 10 Dec 2019 12:32:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576009961; cv=none; d=google.com; s=arc-20160816; b=mdhyYLz7n8p2L5oi55zIvRRgSLZh2PYDCAxMTWpbjNDEE2iY4+6ij45qFbSYo5gZok BlLadAGapHZhNBZtg5mn+pEqDe8LlX3oeWQ2UoL2mI3c366gzzRY54okPAeVeQcmbkyY mApuxd5/ZmF/yYwVEQfuTPS56Si59fyXNine2Z2Fp4EjqteGDYwEoQZoKPaF75/N0fIL 0Lysn8hZyIlE0HJ7TY9d+/b1twLHGAA/gGYCOW1DUGZrMo+SifpXWIoFbKrDJ3wj3vyV wtJG1Md5lpuoPHvRYpeMOh7GF93cawtVLJ/Dg7GHbYTmKzsaW4otF0zAMJCXiG5yTxAf sVzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=AXdgRPOupq8mpOVW9fDaoE7i0os1nP349i6MmUYJbLw=; b=DP75TKoX6ieIwk2X1KjMf7cpW8oC8/fbc+xrQvLDSYnBUQcdR+eM/NM0D1MoEIlfbg t/bwu8J8Ssj7ilN4wBXP9Vh2PardiCzYCs1p3JIxn8pJYUVr/o+uA0bKjQNhI7+Attka YgTPASlkYzpSj4jtsv+Y77dBPA2dUY3bpYU941b09ZmC8g5AY/mgE/E54M9KgldArr1c nZ2D+JH30GV2JI4b9RsGAV6zJn9RJ64yZm1mgiPNIVYu/5bEG1IZSBPnqFt02dCiNO/3 i8cchp/G7HSJj6HwjloyxmEn6NN9kSfj56ZI2jSy9Hsx2qbwyQ9Foq9C52tCLsei9ZoE ishg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U47CDhuz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si2598247otj.82.2019.12.10.12.32.29; Tue, 10 Dec 2019 12:32:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U47CDhuz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726930AbfLJUb5 (ORCPT + 99 others); Tue, 10 Dec 2019 15:31:57 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34333 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbfLJUb5 (ORCPT ); Tue, 10 Dec 2019 15:31:57 -0500 Received: by mail-pg1-f193.google.com with SMTP id r11so9450157pgf.1 for ; Tue, 10 Dec 2019 12:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=AXdgRPOupq8mpOVW9fDaoE7i0os1nP349i6MmUYJbLw=; b=U47CDhuz0r/IRPYg0nOXL/3oQEygnoHNuYbU416HhjOKsXQBiAh+ym1mFxz/CLQKm5 PAVLw4SDABvaWmZ6bDTz999xnkwov7EtfUtskkLSFlFlTOTXZ48HnONY5r+XacqxAKbd e4orxhyQU+VQR1rtMO9s9kf40rm/F46gVN2XfWisUUBCx5FZAv2/cKL9APa/XGbuMcLj YrBY7CV0GV3tSsguNm5eZkG6axi5HxyKGuXGYLQtKtZxVp4Hx/n7cWGME6g5Zwul9k3A zU0r7xiXBLYg6HK48jJ/YaRswjyf0ppp2QCqkioiri5++NRLEcL34BqwDMkr+uoLZ7GT AM9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=AXdgRPOupq8mpOVW9fDaoE7i0os1nP349i6MmUYJbLw=; b=Uz+4+G54Zov7uFEThAMpoJCeQVbJubwvzQCLr7wf5jZghEvb1+5AAAK3v9OX6S4SZX qUhWrI4jpOjAmFw38oVMQSjTrbLikHu73CI2ucdlZL5f846/RyOxTKU+Hoq1o8sodukW M7uIdLVhNZ7/AAOvIIIPkydnDtGfcsXPP+LxWbu3KM0PaTPqzuyBt+us8eCWLr7jHu2/ 5FBu62ShNtjasQfNPyykLuo63XGfyobSn3/9TJdX1UNbp/WkO2zUZLx6VOhZU26WQXYu SwGUZ0pov/qdFdaOO8eMEJokJHan7/aU6z8Je0Xl0fkHflrZ79oVVLqTvb1l0bNMavwh 8bCA== X-Gm-Message-State: APjAAAVPaUWXqDVRZm0i8SQe3vs2lEIbQtVquGW1700l7Ea7v3Eb32GQ Jaeq1dA4Qa7Rvo7KK+/qPEw= X-Received: by 2002:aa7:8b55:: with SMTP id i21mr37408207pfd.249.1576009916862; Tue, 10 Dec 2019 12:31:56 -0800 (PST) Received: from localhost ([2001:19f0:6001:12c8:5400:2ff:fe72:6403]) by smtp.gmail.com with ESMTPSA id b21sm4604086pfp.0.2019.12.10.12.31.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Dec 2019 12:31:56 -0800 (PST) From: Yangtao Li To: gregkh@linuxfoundation.org, rafael@kernel.org, srinivas.kandagatla@linaro.org, vz@mleia.com, khilman@baylibre.com, mripard@kernel.org, wens@csie.org, andriy.shevchenko@linux.intel.com, mchehab+samsung@kernel.org, mans@mansr.com, treding@nvidia.com, suzuki.poulose@arm.com, bgolaszewski@baylibre.com, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, Yangtao Li Subject: [PATCH] drivers: add devm_platform_ioremap_resource_byname() helper Date: Tue, 10 Dec 2019 20:31:45 +0000 Message-Id: <20191210203149.7115-1-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are currently 300+ instances of using platform_get_resource_byname() and devm_ioremap_resource() together in the kernel tree. This patch wraps these two calls in a single helper. Signed-off-by: Yangtao Li --- drivers/base/platform.c | 22 +++++++++++++++++++++- include/linux/platform_device.h | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index b6c6c7d97d5b..9c4f5e229600 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -60,6 +60,7 @@ struct resource *platform_get_resource(struct platform_device *dev, } EXPORT_SYMBOL_GPL(platform_get_resource); +#ifdef CONFIG_HAS_IOMEM /** * devm_platform_ioremap_resource - call devm_ioremap_resource() for a platform * device @@ -68,7 +69,7 @@ EXPORT_SYMBOL_GPL(platform_get_resource); * resource management * @index: resource index */ -#ifdef CONFIG_HAS_IOMEM + void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, unsigned int index) { @@ -78,6 +79,25 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev, return devm_ioremap_resource(&pdev->dev, res); } EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource); + +/** + * devm_platform_ioremap_resource_byname - call devm_ioremap_resource() for + * a platform device + * + * @pdev: platform device to use both for memory resource lookup as well as + * resource managemend + * @name: resource name + */ +void __iomem * +devm_platform_ioremap_resource_byname(struct platform_device *pdev, + const char *name) +{ + struct resource *res; + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); + return devm_ioremap_resource(&pdev->dev, res); +} +EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource_byname); #endif /* CONFIG_HAS_IOMEM */ static int __platform_get_irq(struct platform_device *dev, unsigned int num) diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 1b5cec067533..24ff5da9c532 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -63,6 +63,9 @@ extern int platform_irq_count(struct platform_device *); extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, const char *); +extern void __iomem * +devm_platform_ioremap_resource_byname(struct platform_device *pdev, + const char *name); extern int platform_get_irq_byname(struct platform_device *, const char *); extern int platform_add_devices(struct platform_device **, int); -- 2.17.1