Received: by 10.223.176.46 with SMTP id f43csp549298wra; Wed, 24 Jan 2018 02:15:47 -0800 (PST) X-Google-Smtp-Source: AH8x227PZPAH9YvQA1g/wKnenuEY7ff3gLbfaruC+UULhWt/MCo74Ec0kkyxokxyUvFTmWaqtZNR X-Received: by 10.98.57.27 with SMTP id g27mr12731287pfa.128.1516788947025; Wed, 24 Jan 2018 02:15:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516788946; cv=none; d=google.com; s=arc-20160816; b=Nto5pg9cOyPJpnMniP5a/fP1kJ1tevt3dx0bSQh5VYh5MpQ7v5J7Xbph7XyJjaz+ET NI+nu+rRlzhCOizGHuqyOGxrUUz0BuBJ8H0zwGiyUyCV/oAupDFwH7lWPy7l2GuoFGIX iteWP29v20NLq8xSqpQVDK7Ikib6giGu/R5mtYMZhW29ZwX1UadX6JGuPbcs82TTs1nm k0X+OMa0d4g0ZDgIrIhl11YcEqwVAVNoQxC7int9+ub5Sl9pybEh3PDrqZVnhEOaS701 LstXNBouMfisOMuZUr3n8RWvwLFuoQPd/kJdrkzYU/2IbNPFr0tc3adDMU8CqdE7je72 N24A== 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=2YnBJd8IbCYh/pK/ZYuhC2DnRSVMag4PGbWQlsXGZqY=; b=z7jsVngxxxX6an7CsYBZ/u6NWLR2hJQxackXLDf3kBfQz5zIYoNe7CDUR75oaDvzeX MQtnXCMsqY2z1KAQSeRJ4iH1/BlU2Zxp7H6ySLLw1yCG0zdtbUDqCDcHKZxfBAt0U4MW NAGuyo4BHTt34Zra49M/p3M2FziTUpQqBw4yYNkbiVwD8ouoa9bCQspgbGUzs4Op2IVQ kdUbVSscgNj6Eb97LQcMsQxKS9UOM6g8671tBj/Vtwi0XGBnX2hu8rd7vp6SVbWxbvRr SNbo+eS7Rp99GXMTbcq8tsmVjKsekwQcO4XBh6QVnGv0uEtHzyhfsru9QyMAC2dg32RK BnbQ== 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 v85si15800736pgb.353.2018.01.24.02.15.32; Wed, 24 Jan 2018 02:15:46 -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 S933026AbeAXKPH (ORCPT + 99 others); Wed, 24 Jan 2018 05:15:07 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:60430 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932973AbeAXKPF (ORCPT ); Wed, 24 Jan 2018 05:15:05 -0500 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23992821AbeAXKIaWZvDV (ORCPT ); Wed, 24 Jan 2018 11:08:30 +0100 Date: Wed, 24 Jan 2018 11:08:28 +0100 From: Ladislav Michl To: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Cc: Thomas Gleixner , Tom Lendacky , Borislav Petkov , Ingo Molnar , Lorenzo Pieralisi , Philippe Ombredanne , Kate Stewart , Greg Kroah-Hartman , Boris Brezillon , Dmitry Torokhov , Bjorn Helgaas , Wei Yongjun Subject: [PATCH v2 3/3] mtd: nand: davinci: Use devm_ioremap_shared_resource() Message-ID: <20180124100828.GD19593@lenoch> References: <20180124100604.GA19593@lenoch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180124100604.GA19593@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 --- Changes: - v2: None 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