From patchwork Thu Oct 12 20:15:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10002785 X-Patchwork-Delegate: geert@linux-m68k.org 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 D9EB660216 for ; Thu, 12 Oct 2017 20:15:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4DED28EA5 for ; Thu, 12 Oct 2017 20:15:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B973E28EA8; Thu, 12 Oct 2017 20:15:43 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 4AB7128EA5 for ; Thu, 12 Oct 2017 20:15:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753003AbdJLUPm (ORCPT ); Thu, 12 Oct 2017 16:15:42 -0400 Received: from mail-lf0-f52.google.com ([209.85.215.52]:48745 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752246AbdJLUPl (ORCPT ); Thu, 12 Oct 2017 16:15:41 -0400 Received: by mail-lf0-f52.google.com with SMTP id a69so7232951lfe.5 for ; Thu, 12 Oct 2017 13:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:user-agent:date:to:cc:subject:mime-version :content-disposition; bh=MKj1wodAx/kEuovPmDXPfiyT+nOJx4Xn2pbdn1AekBU=; b=N9UtGxIihUdXUj/GuSFyA5Mp8r4gc0XwTM5XSg9gpJr0887sKlq17tb98k1z5rhSei wcwJl6X+qqan1L5TPdCqbcXD9I0ipvh1zDSADONSDTsudaBvP2hlsjpSyVxYGqx40n4a lWR5TjwucNv6g38syU0ZqN65SmWzPqWNH4IR0BCfbD295nzuWM89wj6Boy3zVQPy0O1t E/nVuqgl19TCc6lJeaJ9aj7eXlQrushmMDdv6peR6qQVEW15AVU1LJ1hsoBpKK54+EAc 481maxM/HYkgTjOsR6G8lvHMoUPCHx6hfPC6l1HShvXlcIA6jUuuSM1iRrzxZLkljhFi k/vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:user-agent:date:to:cc:subject :mime-version:content-disposition; bh=MKj1wodAx/kEuovPmDXPfiyT+nOJx4Xn2pbdn1AekBU=; b=EEPSlq14o/BMakfl+DYu0vzFzz7lg6p5/5+/UnrgH1VmMdIzmRSnjn8ZTRK5LcECoj iWzwISHZ2l9RdDbqdO5PJ84RwIEsDSF53tJ1JArm0/oCpq9YJJdLAkA3PcMOsC2xzs4u 744iKzM8/xDfCRMuLnLfnCTeoXdUS0xNiXK52Ozm7qfDWtfobITCaCxGXKSnHUMCUwiy tI6Y+/Y0NTKMwpdicYl9fDCuBPY80bVhzxTzWdjxuTzyjKgBbcTgiruGayxVOM+28e/A 3u3pFxURCNQffhO6G7FguPhQwLkONIzMCskIFOk/9l/aAoEu3GFJVGYVrRvRNLtG9Fc/ NZPw== X-Gm-Message-State: AMCzsaXQ6GXC/IsSnp2y7sTcmeAVY0wQe/vasxZS5LxUJkCtfiyaX8bf Tog1JVzS7TDkAKMLJ34E9TvoVntnmAU= X-Google-Smtp-Source: ABhQp+RjkJGnpyHjQMES57arpIWzQX+mhQtRZhBsEp3fDTJd6R4/VXgsyW9X+QSnfE49EhXplHXv+Q== X-Received: by 10.25.17.21 with SMTP id g21mr1126818lfi.170.1507839340552; Thu, 12 Oct 2017 13:15:40 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.83.169]) by smtp.gmail.com with ESMTPSA id b15sm2845850lfl.88.2017.10.12.13.15.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 13:15:39 -0700 (PDT) From: Sergei Shtylyov X-Google-Original-From: "Sergei Shtylyov" Received: by wasted.cogentembedded.com (sSMTP sendmail emulation); Thu, 12 Oct 2017 23:15:37 +0300 Message-Id: <20171012201537.102610518@cogentembedded.com> User-Agent: quilt/0.64 Date: Thu, 12 Oct 2017 23:15:30 +0300 To: Linus Walleij , linux-gpio@vger.kernel.org Cc: Geert Uytterhoeven , linux-renesas-soc@vger.kernel.org, Sergei Shtylyov Subject: [PATCH] gpio-rcar: use devm_ioremap_resource() MIME-Version: 1.0 Content-Disposition: inline; filename=gpio-rcar-use-devm_ioremap_resource.patch Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using devm_ioremap_resource() has several advantages over devm_ioremap(): - it checks the passed resource's validity; - it calls devm_request_mem_region() to check for the resource overlap; - it prints an error message in case of error. We can call devm_ioremap_resource() instead of devm_ioremap_nocache() as ioremap() and ioremap_nocache() are implemented identically on ARM. Doing this saves 2 LoCs and 80 bytes (AArch64 gcc 4.8.5). Signed-off-by: Sergei Shtylyov Reviewed-by: Geert Uytterhoeven --- The patch is against the 'devel' branch of Linus Walleij's 'linux-gpio.git' repo. drivers/gpio/gpio-rcar.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) Index: linux-gpio/drivers/gpio/gpio-rcar.c =================================================================== --- linux-gpio.orig/drivers/gpio/gpio-rcar.c +++ linux-gpio/drivers/gpio/gpio-rcar.c @@ -452,19 +452,17 @@ static int gpio_rcar_probe(struct platfo pm_runtime_enable(dev); - io = platform_get_resource(pdev, IORESOURCE_MEM, 0); irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - - if (!io || !irq) { - dev_err(dev, "missing IRQ or IOMEM\n"); + if (!irq) { + dev_err(dev, "missing IRQ\n"); ret = -EINVAL; goto err0; } - p->base = devm_ioremap_nocache(dev, io->start, resource_size(io)); - if (!p->base) { - dev_err(dev, "failed to remap I/O memory\n"); - ret = -ENXIO; + io = platform_get_resource(pdev, IORESOURCE_MEM, 0); + p->base = devm_ioremap_resource(dev, io); + if (IS_ERR(p->base)) { + ret = PTR_ERR(p->base); goto err0; }