Received: by 10.223.176.46 with SMTP id f43csp2180545wra; Sun, 21 Jan 2018 13:18:16 -0800 (PST) X-Google-Smtp-Source: AH8x226LwnySUyTVIf1Xkk5Q0d0cyjQXvYRnquiJx4QjAYTJqCmsPaaiFsORVSakOfK1wJ3A/ln4 X-Received: by 10.98.198.2 with SMTP id m2mr6226404pfg.113.1516569496312; Sun, 21 Jan 2018 13:18:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516569496; cv=none; d=google.com; s=arc-20160816; b=usOYNPiOoQOTMcdvqNxvw4u/W5HRJrJQDk7wkwdz2GrESvIT+pMV/mJYiFmpBnMq0S k+Q5pTXVvS+fBJ4w9WJA/Xot4/seGyY1nRVIUyZFpbv9gJlWyjlbkwTrTMpeWhBwsuIS uQDTsSHZWIwS2fqJRl02/6HE5qw9DoRJupgYrzEB1B6PCefqxoAklIWEq3Lwv8Fe6W60 59/3lwSFi2GANKW+DVMXd/fFMJ7p6DsoG99YdRZ8qLiKfbILa77aIe/AY8WHLUsBXkJG GMi3U4SpjRDMlm5a1J9kiRD61lGxvfhKHT2jGgf1gStbojY0WlM0fP07cgtQAXZWA94j WkeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=PKTs2bzqj4q4qad81ZqWjlF3qc9V5hrXHlFW+0BVVKY=; b=Gd9QskPC3yTWxRQS6ZZve/y6BwjUuvL/dHtVImRl4IFI0KYA9QJwNj4KhEoYOPr8U+ bjz31Ccs+edSnCsjPnl+AdZC2b/LjrrMVQBo58uQHYQeGArrmA1QV0dFcQFimIoXp2C1 Qh1fHjqr14g2fErAcUoqvmCt7auQL3htLaaf1c8W06oEhj/jwxL/2GQz90ocTniqLFI4 WuQ1+WopXZt1fVVQS6mJ0jFjlpU5e6OQ30GxyKhcjFY6sEYSChbI0mCrtDXq+jlQoKrm P2oF4Mu72zb/tJThHAQYxDiktYVetWK6kBz2fvtAdlqyQ5lh3Bnab6PkRMt/I9cd/7eD VOnQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si989962plh.549.2018.01.21.13.18.02; Sun, 21 Jan 2018 13:18:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751280AbeAUVRE (ORCPT + 99 others); Sun, 21 Jan 2018 16:17:04 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:39738 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751104AbeAUVRD (ORCPT ); Sun, 21 Jan 2018 16:17:03 -0500 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23992604AbeAUVRCgQRqG (ORCPT + 1 other); Sun, 21 Jan 2018 22:17:02 +0100 Date: Sun, 21 Jan 2018 22:17:01 +0100 From: Ladislav Michl To: Bjorn Helgaas , Wei Yongjun Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Dmitry Torokhov Subject: [PATCH 5/5] mtd: nand: davinci: Use devm_ioremap_shared_resource() Message-ID: <20180121211701.GF15151@lenoch> References: <20180121211432.GA15151@lenoch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180121211432.GA15151@lenoch> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Simplify error handling by using devm_ioremap_shared_resource(). Signed-off-by: Ladislav Michl --- drivers/mtd/nand/davinci_nand.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c index ccc8c43abcff..9b6f06b177b9 100644 --- a/drivers/mtd/nand/davinci_nand.c +++ b/drivers/mtd/nand/davinci_nand.c @@ -612,10 +612,8 @@ static int nand_davinci_probe(struct platform_device *pdev) { struct davinci_nand_pdata *pdata; struct davinci_nand_info *info; - struct resource *res1; - struct resource *res2; + struct resource *res; void __iomem *vaddr; - void __iomem *base; int ret; uint32_t val; struct mtd_info *mtd; @@ -638,14 +636,8 @@ static int nand_davinci_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); - res1 = platform_get_resource(pdev, IORESOURCE_MEM, 0); - res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (!res1 || !res2) { - dev_err(&pdev->dev, "resource missing\n"); - return -EINVAL; - } - - vaddr = devm_ioremap_resource(&pdev->dev, res1); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + vaddr = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(vaddr)) return PTR_ERR(vaddr); @@ -655,14 +647,12 @@ static int nand_davinci_probe(struct platform_device *pdev) * by AEMIF, so we cannot request it twice, just ioremap. * The AEMIF and NAND drivers not use the same registers in this range. */ - base = devm_ioremap(&pdev->dev, res2->start, resource_size(res2)); - if (!base) { - dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res2); - return -EADDRNOTAVAIL; - } + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + info->base = devm_ioremap_shared_resource(&pdev->dev, res); + if (IS_ERR(info->base)) + return PTR_ERR(info->base); info->dev = &pdev->dev; - info->base = base; info->vaddr = vaddr; mtd = nand_to_mtd(&info->chip); -- 2.15.1