Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2451069pxk; Sun, 20 Sep 2020 04:40:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIYIO1FUYhDeHSoiU+SVWzeP6NVlQXbheQYF/rZfwg8eA9ELwUJhd3RgDCO4iQJMjf9rMA X-Received: by 2002:a17:907:2168:: with SMTP id rl8mr44727852ejb.308.1600602020673; Sun, 20 Sep 2020 04:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600602020; cv=none; d=google.com; s=arc-20160816; b=iTjc6xETOuSokoG0TKNq6Wt36juc1WzFdmgpbw35dGfMkMAJ/SIfcCCbWQi5ZWroFG FeeayYolEENqkHw5aowiQOPJAuIRD0OujSBr9KaneJOhM45uiD3dXDmmOAJc7DJ/m0JD A3R7PxiSDEt3iesKijNTLeNsB6A742YYqfb0QOh2Zd60C+az863oCVYmWtwR01mB92kS o9c5ci9jkScFM1ynmkpVY6t9wB4l0fWXZBFeqN3TRM1fKvPbprqDwN1MxK0piQyZteju /qGeN4fPTQiOYfZ/+1a/iX1adFhM/zHYKpSMz1YoM8DdvlSNPusNRwnBzt1h4M7yROv/ ESHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=ANleZeOYhNX2PwcGe2hR4y8/iDJy+Siy+8LNKjoAFWM=; b=tD/FVUSESbMgM269N7sbNH9b0ndJ6I4bnSCChb47EiI/uz5P4Hh9/FuaWdhK6gror6 ELmCE1Y3LxyY4XVwNcaNXcLL186y/8v9Ku7BBGNShOUMO2Uga4pB8Nxqjfp4Mb+dEgWj vHWTlSJI0k3jOPVi+xBxxIbcEbRvH7cd7n7epPS4X5E61jrV/dMrtdqSOuQsUpJBFqYC VM7kHkGumIIo9zPUuaLZOmDD2FPZ1b8aggEdfDabJuNp7OhNC0Kpi056hDGBLXqvTY2R YnlcO3/EA8JcqazldjlHU0p2SMhTxw8qblJqku8Oc9q1Rl82hWdztJlhMxs4X3PGISYS EXMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TDYwtJdo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id ng3si5759713ejb.720.2020.09.20.04.39.57; Sun, 20 Sep 2020 04:40:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TDYwtJdo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726552AbgITLih (ORCPT + 99 others); Sun, 20 Sep 2020 07:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbgITLih (ORCPT ); Sun, 20 Sep 2020 07:38:37 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBAD7C061755 for ; Sun, 20 Sep 2020 04:38:36 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id o25so1427870pgm.0 for ; Sun, 20 Sep 2020 04:38:36 -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; bh=ANleZeOYhNX2PwcGe2hR4y8/iDJy+Siy+8LNKjoAFWM=; b=TDYwtJdoXExlobJAwY1B1EwfjhYRYAljmbB7f+aSrKc/M+z6ArjPGi7u6bjxJF+bkQ WRgxcXRUiGHhZo8mghxgAUIQ1bX3qEAG3asMhsPr4Y1oMH66zsA9N3nmtaXfOnEKgDvE TAgfMZOAkgD2cjcaqxjj+y4gW3a7PWwZPyeyz51JILuKb+w33xX2NqplnB4K52IiGAab pMDGmsibuZ+goC8Hcdp+cxfpxZNYEoMjOOOynPuTRzbOz6LeqRN4ETxRjlW/Ge1c3qNU SASm7pgKnLMVZgICreGQGQZy2o5yGuta5YZaFJgjRxzpBpslv5iGjy4xWlLekAiiPetg 5/BA== 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; bh=ANleZeOYhNX2PwcGe2hR4y8/iDJy+Siy+8LNKjoAFWM=; b=YylxUyH2O7qr71Lzc5p7T9G+BjsTkUc2HL3j6cvzN2W2oTw+l1/ltPRErsvmNVdzD2 KbtRR5S4Si1jQAVj1fBxudWGf9wwf6q7M0/6j5LTuoTq9WKTlgnXewvdNVH2o067kNgw uy2rwSTNk/VJN+VjvXHOcfSHmuX8D2laPxVeXgg/bmA7NCRwpojdLLMAov6ajoGeBouR 9eXdkCQU8uQ0LcjJNQ3Y9IHmYnbLt/OFAymGmIf4MINWzQY2XnWuZgOw2PjwyLgSo59V mLZmDo15nOtkeq5nopqjft9BVq7cfP0Z3pdLRieV04r+Dec3Yms8uiz2oN13tzScCxIC poZQ== X-Gm-Message-State: AOAM531xTxe8OievA4cPmabrfPZ7RNmgL+zYuY26YLEbUOQWvEUMHEIQ Ey4AefGoSb4j2ZRdHMhtCzlZDKiEyugQqA== X-Received: by 2002:a63:490d:: with SMTP id w13mr13064818pga.24.1600601916537; Sun, 20 Sep 2020 04:38:36 -0700 (PDT) Received: from localhost.localdomain ([1.200.101.36]) by smtp.gmail.com with ESMTPSA id y24sm9041702pfn.161.2020.09.20.04.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2020 04:38:35 -0700 (PDT) From: pierre Kuo To: gregkh@linuxfoundation.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, pierre Kuo Subject: [PATCH 2/2] driver core: platform: provide devm_platform_iounremap_resource Date: Sun, 20 Sep 2020 19:38:08 +0800 Message-Id: <20200920113808.22223-2-vichy.kuo@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200920113808.22223-1-vichy.kuo@gmail.com> References: <20200920113808.22223-1-vichy.kuo@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Combine platform_get_resource() and devm_iounremap_resource() to release the iomem allocated by devm_platform_get_and_ioremap_resource(). Signed-off-by: pierre Kuo --- drivers/base/platform.c | 24 ++++++++++++++++++++++++ include/linux/platform_device.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index e5d8a0503b4f..e2655c00873f 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -84,6 +84,30 @@ devm_platform_get_and_ioremap_resource(struct platform_device *pdev, } EXPORT_SYMBOL_GPL(devm_platform_get_and_ioremap_resource); +/** + * devm_platform_iounremap_resource - call devm_iounremap_resource() for a + * platform device with memory that addr points to. + * + * @pdev: platform device to use both for memory resource lookup as well as + * resource management + * @index: resource index + * @addr: address to be unmap. + */ +void +devm_platform_iounremap_resource(struct platform_device *pdev, + unsigned int index, void __iomem *addr) +{ + struct resource *r; + + r = platform_get_resource(pdev, IORESOURCE_MEM, index); + if (!r) + dev_err(&pdev->dev, + "MEM resource index %d not found\n", index); + else + devm_iounremap_resource(&pdev->dev, r, addr); +} +EXPORT_SYMBOL_GPL(devm_platform_iounremap_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 77a2aada106d..75da15937679 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -67,6 +67,10 @@ devm_platform_ioremap_resource_wc(struct platform_device *pdev, extern void __iomem * devm_platform_ioremap_resource_byname(struct platform_device *pdev, const char *name); +extern void +devm_platform_iounremap_resource(struct platform_device *pdev, + unsigned int index, + void __iomem *addr); extern int platform_get_irq(struct platform_device *, unsigned int); extern int platform_get_irq_optional(struct platform_device *, unsigned int); extern int platform_irq_count(struct platform_device *); -- 2.17.1