Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3866487ybb; Mon, 23 Mar 2020 09:07:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsg8Hg6bUI3gQpkJe+ZpTvssU8NYdAAw6yrMcdZKCjyzBmfRRTh/9ybbHn+knc+z6j5qdld X-Received: by 2002:aca:724f:: with SMTP id p76mr53228oic.112.1584979647120; Mon, 23 Mar 2020 09:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584979647; cv=none; d=google.com; s=arc-20160816; b=JAFDJenGvo4MwZSu/YK3ybEXAAZ3wmXuvRuL5ZuItq8gox9b4I98aMoxKUR2HZN7i3 QYS26KaJVZS5jMYQY8Z03VkcpGCo3KO2OiheL2BLqvq0ixHD00H6m24XNtCTVX8r7eD0 LdnEFujF3K7tQrBlL80JpFMiLp0VmXnm1Z6VP6KK/7dz01quMQ9MMdSejIFEz6xuurBe N+AcquDL9N0lN3PYckaB88lapap5l6YiPrKNA7M+xRwuhMzkRvqzT25sN/Zh4NpvSxHX hf+oNfLo8Lc7E7syRpBzk958MFfKrw/MngfTM0eK9Bd+r+q2yS+cFNB3W52R4nWfHnNG Ej/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+vadeapgvAVIS4ucGk0m/TsoQZJykoxM6aQhRpzbLpw=; b=gX+k+4nb7MfQ0HvSP6JY7M7ehPldbtvLIsoAsdbnWqt1rkE5acqZ3+Z86qskynaelA jYOYpIaYeVSqwehmZK9xSIN6q30/zO7Efh102CqvwkC6gJHER7mkj4Xn+5ugdrYWzFcq I6iiL6heQi7Z80h1RTdAyiNCVoEi7b74rbXGFZxd0Gg+WE0dMJNjfOOu56fXajz3ZRZx FiaeJPB0+9K67+zz43CgxQI8ktVKk5prRV+ar7Gp0kKA0/PfxMHYYcD/XMWDk2I6jXdk wop80TuIY+aGL0sJt7Vdp9/I4xYLofP5P7kx6wrGBAek/P2WIm7kV2y/a9sLypJZFCaH 5pjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=soYPO72n; 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 s1si8106428otp.81.2020.03.23.09.07.11; Mon, 23 Mar 2020 09:07:27 -0700 (PDT) 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=soYPO72n; 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 S1727511AbgCWQG2 (ORCPT + 99 others); Mon, 23 Mar 2020 12:06:28 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33745 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727499AbgCWQG2 (ORCPT ); Mon, 23 Mar 2020 12:06:28 -0400 Received: by mail-pg1-f193.google.com with SMTP id d17so6846130pgo.0; Mon, 23 Mar 2020 09:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+vadeapgvAVIS4ucGk0m/TsoQZJykoxM6aQhRpzbLpw=; b=soYPO72n5SO8kgJCLxgG8itEzeFgkOfpEXVZxPLFCzKRDrbdeJx1GcM8Dm5Chce4uX CqtHHc3BPOecv71LBZ7J543GBadGiOi758/nbdK23igXDSYorWRLUeaD7tnXnLxc6XmJ WtEkSIYWe3LgANdjX9wCaITuqQanE4YG/InEHtc7S5DFdxFZYi5C2/qFgBHnqNWj/iLi 4PsiqmfJuaZEaxQIH3Cp+/j0tPqi3J6aEJccVrv1E+GswGryK1nV5h1UdRB2FNRHAlGK /EXFuf8cNFMpmaISK+XlrWmXHnzBNRenB0Hmw+DcD86fvjf7kc3Iy26QCwfjO8U+Hacw 99gA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=+vadeapgvAVIS4ucGk0m/TsoQZJykoxM6aQhRpzbLpw=; b=b8L73q0PW4tL1dEgmOlqr9FyuFzgWBzLhYqoUF94RKisjyqp5MJkJ4TsIyqLDl+asf aTYuVZ1N4SGoD8vGT2enXl0YN5fudYt9VuzdJDS+wCFwFwKgGtNX7qK4MrOsUxtVBgmy i+P1NIny6c5E0yV7YImTJWdTwQKz951rMiw5iQrbgOhFMuNjKKNrDf5eNdVgHloT8rm6 yN9p7YjHuzJansRzxs3N0naTmRNPGIrJLL75qV4UIfZsiHSm8TfPckSrqWCBjvrq7Ezv DvFTbVVvIghzr2SI+qczPTS6XKMV+oLkm9H5U5BOidlQBTk0S873/Y84EUv1F6hWDqQj UZHw== X-Gm-Message-State: ANhLgQ07C73q8Z0uigGqFU7Fw+tNqAymDk8s6ZMy5lk2pD82gNZ7qTKP 0+MeJ7VaZLPWcadA+NvqHuI= X-Received: by 2002:a63:7e1a:: with SMTP id z26mr22236847pgc.226.1584979587402; Mon, 23 Mar 2020 09:06:27 -0700 (PDT) Received: from localhost (176.122.158.203.16clouds.com. [176.122.158.203]) by smtp.gmail.com with ESMTPSA id a13sm20660pjh.7.2020.03.23.09.06.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Mar 2020 09:06:26 -0700 (PDT) From: Dejin Zheng To: gregkh@linuxfoundation.org, rafael@kernel.org, hminas@synopsys.com, mathias.nyman@intel.com, bgolaszewski@baylibre.com, arnd@arndb.de, geert+renesas@glider.be, tomas.winkler@intel.com, tglx@linutronix.de, hdegoede@redhat.com, treding@nvidia.com, suzuki.poulose@arm.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Dejin Zheng , Geert Uytterhoeven , Sergei Shtylyov Subject: [PATCH v4 1/5] drivers: provide devm_platform_get_and_ioremap_resource() Date: Tue, 24 Mar 2020 00:06:08 +0800 Message-Id: <20200323160612.17277-2-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200323160612.17277-1-zhengdejin5@gmail.com> References: <20200323160612.17277-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit "drivers: provide devm_platform_ioremap_resource()", it was wrap platform_get_resource() and devm_ioremap_resource() as single helper devm_platform_ioremap_resource(). but now, many drivers still used platform_get_resource() and devm_ioremap_resource() together in the kernel tree. The reason can not be replaced is they still need use the resource variables obtained by platform_get_resource(). so provide this helper. Suggested-by: Geert Uytterhoeven Suggested-by: Sergei Shtylyov Reviewed-by: Geert Uytterhoeven Signed-off-by: Dejin Zheng --- v3 -> v4: - modified the description of the parameter res in this patch. v2 -> v3: - rename the function to devm_platform_get_and_ioremap_resource() by Sergei's suggestion. - make the last parameter res as optional by Geert's suggestion. v1 -> v2: - No change. drivers/base/platform.c | 22 ++++++++++++++++++++++ include/linux/platform_device.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 7fa654f1288b..3e8a9fb91dcd 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -62,6 +62,28 @@ struct resource *platform_get_resource(struct platform_device *dev, EXPORT_SYMBOL_GPL(platform_get_resource); #ifdef CONFIG_HAS_IOMEM +/** + * devm_platform_get_and_ioremap_resource - call devm_ioremap_resource() for a + * platform device and get resource + * + * @pdev: platform device to use both for memory resource lookup as well as + * resource management + * @index: resource index + * @res: optional output parameter to store a pointer to the obtained resource. + */ +void __iomem * +devm_platform_get_and_ioremap_resource(struct platform_device *pdev, + unsigned int index, struct resource **res) +{ + struct resource *r; + + r = platform_get_resource(pdev, IORESOURCE_MEM, index); + if (res) + *res = r; + return devm_ioremap_resource(&pdev->dev, r); +} +EXPORT_SYMBOL_GPL(devm_platform_get_and_ioremap_resource); + /** * 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 8e83c6ff140d..8aa6b448450f 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -55,6 +55,9 @@ extern struct device * platform_find_device_by_driver(struct device *start, const struct device_driver *drv); extern void __iomem * +devm_platform_get_and_ioremap_resource(struct platform_device *pdev, + unsigned int index, struct resource **res); +extern void __iomem * devm_platform_ioremap_resource(struct platform_device *pdev, unsigned int index); extern void __iomem * -- 2.25.0