Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3559228pxk; Mon, 28 Sep 2020 23:23:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHU91I9/HqZqXjVDaAgFOU6j3A5MznwktI4fSjGeSmfaofdMZ9d6qEypVXxOTAZ8lJ2BBf X-Received: by 2002:a05:6402:718:: with SMTP id w24mr1569322edx.294.1601360621852; Mon, 28 Sep 2020 23:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601360621; cv=none; d=google.com; s=arc-20160816; b=wtg61w9vvHHXj0vYo89iMmtmvLq0bD3x1gLPGRibtHM3VsRxiIs0hml94e4rwmsOiY W7GjqYP/IIbrAr+JV2bvlEYWhJmn8zeYVK4kLZBktqU9nDDjmp1dNCINuQIkquxjdFdD oU3qJcY+7YRkd4BcP5nS1ShgG3oVAuNaILhCPy5PFzVnCcj3oD3mWf+EnBFfEMg7bhAD 6ePxyUgokIHwgO/mjBjmxrTSXpcar8QIKWu6Qi3HA7wp/yp08z77K6OPllqdA3reXunF LuuwaHwXr4J4tNVwlMoMCLK48h58SsgInYJ0reYcZDn4ZWytPbcZdgfURQ7op36W3J47 lyew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xScgugWUI7XPriw4lHg9Y3x0ePJygxK+gWE0slOgaQw=; b=KveTPrhNfbepEfmkwC/v9R3UaUr4jpozLhAVc5K94MLfnyxCfrO44uXqvgqITw06VG so7grO6a3qg1Ka8w+gepEca4Q0vSeJxvdbV1hv5xCGnQ5S3SXeysYEUoa9gs5uJP2S9g F9v9RKeHJwk9MiXyiA/jqiChcpVgTk2P30PUuYs5w21UMChnt/GnMvpf9Z0BvBRPAFF4 7GP8N/Hde2rM+zzGgCcuXGFBrXe28laGikE+gFyCjCJGKRRiiejWyOMOeotk6rK3+PDI ysnsSL1N+tQf+li9u7rSQJO9AnQSrSwW3wN7feB9hyM82YTXTVu1qSYpH0EWW+P0XoUf p63A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LAl5lvFQ; 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 ds2si2064190ejc.117.2020.09.28.23.23.18; Mon, 28 Sep 2020 23:23:41 -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=LAl5lvFQ; 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 S1727495AbgI2GVv (ORCPT + 99 others); Tue, 29 Sep 2020 02:21:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgI2GVv (ORCPT ); Tue, 29 Sep 2020 02:21:51 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1C12C061755 for ; Mon, 28 Sep 2020 23:21:50 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id u4so3004750ljd.10 for ; Mon, 28 Sep 2020 23:21:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xScgugWUI7XPriw4lHg9Y3x0ePJygxK+gWE0slOgaQw=; b=LAl5lvFQchm49TQAHMsx3c1dikcC7cb3THCmfMsDrigijcL/jG9L1vZ29VZlXg3xZp X8Gw/VBPkU/1+wB6IQBAtZFpPoZ2n+mQIwhPmnmLZ/ZUxT78TF1hsit5ieR4j103gpKF RTTz3W14zq4MGly44cIBGCShuQzCF/7avtyjpWLR7MlGVl06pS1hdAaj07ZOyuRuaxaz WTt6j1xzAxNGWl13glCcT3Qkw8tc/uctxi1iLV1/OaqgOAWGRlzZV/4lA5lYg5+i/m+a Omz5q3ejnPsU1axVJ0wVsCGqbXjZowZDj8XMemktnp3tgZ23p0ItbCSXR162kTvoEbGO WtNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xScgugWUI7XPriw4lHg9Y3x0ePJygxK+gWE0slOgaQw=; b=YlnhQoemEEpQumzybL05DfX58C9z1SKd9BxSM2fxOspCp1m+AROKXgUPRZSemJ5/Qo /uV6m5xY4TUGrSuxlSDwF67uEydzZ5Xh4buR+yBTFW+DvY5eSDQIWLC1yufU4hWiYuoA wO2QIAeYVIlnMjo97rBCa5Zfw610caBZ8tmDVvKj1n9t1kVEMEuThaV6tPMPX3cBxpIh F8O1hsc2yCX2HL4IAP9hwP9VwBtYHaFty6VqiAQJa9929fV9+83g+GvFBtGQppmtilfr jwegid4decxeInndh0sIsC5oXDw+KWXeUWiDpLCuXTimyqK+2wc4xMTLPeomlI9Bfkis uvgA== X-Gm-Message-State: AOAM533pvPH5CccCSvFKMyL6wmhr98UHThIMhC0WXvUHVVRshoMb57dz yv5CTB31eHIgnHYCn0SS4QnsPgVqu/8Tdaeu4jo= X-Received: by 2002:a05:651c:28c:: with SMTP id b12mr682984ljo.293.1601360509052; Mon, 28 Sep 2020 23:21:49 -0700 (PDT) MIME-Version: 1.0 References: <20200920113808.22223-1-vichy.kuo@gmail.com> <20200920113808.22223-2-vichy.kuo@gmail.com> In-Reply-To: <20200920113808.22223-2-vichy.kuo@gmail.com> From: pierre kuo Date: Tue, 29 Sep 2020 14:21:37 +0800 Message-ID: Subject: Re: [PATCH 2/2] driver core: platform: provide devm_platform_iounremap_resource To: Greg KH , rafael@kernel.org Cc: Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg and Rafael: Would you please help to review these 2 patches? https://lkml.org/lkml/2020/9/20/112 https://lkml.org/lkml/2020/9/20/113 Appreciate ur help in advance. > > 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 >