From patchwork Sun Jan 21 21:17:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 10177131 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0DA69601E7 for ; Sun, 21 Jan 2018 21:17:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 019D826E5D for ; Sun, 21 Jan 2018 21:17:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA7AD26E74; Sun, 21 Jan 2018 21:17:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B51626E5D for ; Sun, 21 Jan 2018 21:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751187AbeAUVRE (ORCPT ); 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-Disposition: inline In-Reply-To: <20180121211432.GA15151@lenoch> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);