Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1971030imc; Tue, 12 Mar 2019 04:38:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKM4F4Bk53fDb034K3VbJuQuQPOgUCcvmy6AkCNemkP42ewWxa5FBb3+igRR20E0xAzSpM X-Received: by 2002:a17:902:622:: with SMTP id 31mr39657874plg.31.1552390700870; Tue, 12 Mar 2019 04:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552390700; cv=none; d=google.com; s=arc-20160816; b=ucrpbUtVCKWIaBPuLOU03RQ3AKUaTApKliY9LhBIIM2iHkFwnVc5FFyD2AcCOVfJee 1GQa9OtzcmdsnBzcnDUGF/+FFMG3C7q7+KJxrOrNWrVgCDoqNoLojoGrbY1VZPq3qOFD v+QN9K21Enb8Qy/PTCxqVexHlTiSbKKSjfiJ7vtOpZRQOztn1PiaSfI+d0H2/6cgH4j2 RfQYh8rBp2qIzd7wmCvohiKQKL2KzeujmMvHqkkvOlQXuj21H1AtE1QOw1LNo0dRN2vK 3xbSrTfjFQpC/pUQxz/9wQN9wWo5pvwAzo0a21aDffNpBhz/aisww2jJZBX7PPHVdEsx V/0w== 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:dkim-signature; bh=02NJNpf9xftt9Jxg0i5VP4bGJO4Ftj6yP7T1GxfxOPE=; b=NoSfFgShluhwheau3kTDLR/S0zVxBJRX71DcR5PNiMHg8trbqusuzxOhRv3LGKNgX1 xqlBMoIaDM52d5LCq40F6AoiDlH8V9P4FpJebQbzCtfhyZ/8SJsvcftE6HhmUFCLdKm0 +g3MZZoQ2eJwVdXI+vJ37ze0LSRa3kdBsWrRAnFlheudS92Hy4LBW6iJU6Et2UYrKY6u WXXpfl4hmk3KRsVHVTOaQj9btFTzH065VR5Rv0tKorJYTApSzXTe38qOoAleGbBLRLwi rRkrGllgA0LATH0RFKpGrDW0LxDo+OxRMt8q2c8Q+6HlrT4sh6VfVwZ6qhNnRR2jb+Sz LxDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bx4Y47Yj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y4si7996786plk.30.2019.03.12.04.38.03; Tue, 12 Mar 2019 04:38:20 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bx4Y47Yj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726425AbfCLLhj (ORCPT + 99 others); Tue, 12 Mar 2019 07:37:39 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:37004 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbfCLLhi (ORCPT ); Tue, 12 Mar 2019 07:37:38 -0400 Received: by mail-wm1-f68.google.com with SMTP id x10so2216966wmg.2; Tue, 12 Mar 2019 04:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=02NJNpf9xftt9Jxg0i5VP4bGJO4Ftj6yP7T1GxfxOPE=; b=bx4Y47YjIpRBe7OWb9QtvJgqhUob/ITaPZ3DfJ3dLEmnKZm78W3K2Z+BbBfq38jo45 KAXiwiTLGXWYs5zyyEQovUIkx+PWta3mgmVSFTEBq5Vz8etCcTueDXuF9e3M78wo396t NSe43a4FHz/Ha3RFbG3WtIcpr+WKArT0/53e7JDYc3sWAE6wXO3V2bV6dp/y6DFTrAVu MUyLUBirhGRgHWFh74QJ9VR88Hrk7MoCLOBCVSVn4xHf0YQzpqCpA1H8yxJ/qOY68i21 42nmgUjlcftaxi54Ss70s6dwZobrdWzEwvwD5bsr2cpi4+oZpP8+4VaqNbSViOY7AmbT nWNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=02NJNpf9xftt9Jxg0i5VP4bGJO4Ftj6yP7T1GxfxOPE=; b=C2V3TUCcv1Z9gBp3dqNUhSq1FCWyNTU0Nbk0tqK8RPej0+DZhHcXM02ogv6fy9299w KGF9LqGtU7BnpJNh8kfx9lijcNq4iYxys8Dl/Xkgup94AvDYyYPU4UHTz3SRTq6JK3yP +nPSPjfOpGXt3X2XSV2/J2SD3ziw4SEmyTQ43fAlsq20hhhddvGyc0alQ9mY8YqUMsoI /vsjZB8k7V4CM+k2ztJI0yHuiTCNlCYFkzTbHiTI9fbZYwpFhle0IER6z2VkWIpAajmO JPTuqes0HqXeD8JzeJqy69ygjjYEw2XNFfsZzDTpTua4DVRwwDAQlHXf8Wov/LMPYxhm DHWA== X-Gm-Message-State: APjAAAWR6vqBsw/zqSC4+YIKCBSNzKXxoshokUiTXtl98RqX4pzNK5kG eCA0zSRQkT1xD0eirKydzvkQEUeE X-Received: by 2002:a1c:9694:: with SMTP id y142mr2019570wmd.98.1552390655001; Tue, 12 Mar 2019 04:37:35 -0700 (PDT) Received: from localhost (pD9E51D2D.dip0.t-ipconnect.de. [217.229.29.45]) by smtp.gmail.com with ESMTPSA id n6sm12475415wrt.23.2019.03.12.04.37.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 04:37:33 -0700 (PDT) Date: Tue, 12 Mar 2019 12:37:32 +0100 From: Thierry Reding To: "Enrico Weigelt, metux IT consult" Cc: linux-kernel@vger.kernel.org, linus.walleij@linaro.org, bgolaszewski@baylibre.com, andrew@aj.id.au, f.fainelli@gmail.com, sbranden@broadcom.com, bcm-kernel-feedback-list@broadcom.com, hoan@os.amperecomputing.com, orsonzhai@gmail.com, baolin.wang@linaro.org, zhang.lyra@gmail.com, keguang.zhang@gmail.com, vz@mleia.com, matthias.bgg@gmail.com, grygorii.strashko@ti.com, ssantosh@kernel.org, khilman@kernel.org, robert.jarzmik@free.fr, yamada.masahiro@socionext.com, jun.nie@linaro.org, shawnguo@kernel.org, linux-gpio@vger.kernel.org, linux-mips@vger.kernel.org, linux-pwm@vger.kernel.org, linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org Subject: Re: [PATCH 38/42] drivers: gpio: vr41xx: use devm_platform_ioremap_resource() Message-ID: <20190312113732.GG31026@ulmo> References: <1552330521-4276-1-git-send-email-info@metux.net> <1552330521-4276-38-git-send-email-info@metux.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="9Iq5ULCa7nGtWwZS" Content-Disposition: inline In-Reply-To: <1552330521-4276-38-git-send-email-info@metux.net> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --9Iq5ULCa7nGtWwZS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 11, 2019 at 07:55:17PM +0100, Enrico Weigelt, metux IT consult = wrote: > Use the new helper that wraps the calls to platform_get_resource() > and devm_ioremap_resource() together. >=20 > this driver deserves a bit more cleanup, to get rid of the global > variable giu_base, which makes it single-instance-only. >=20 > Signed-off-by: Enrico Weigelt, metux IT consult > --- > drivers/gpio/gpio-vr41xx.c | 19 +++++-------------- > 1 file changed, 5 insertions(+), 14 deletions(-) >=20 > diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c > index b13a49c..98cd715 100644 > --- a/drivers/gpio/gpio-vr41xx.c > +++ b/drivers/gpio/gpio-vr41xx.c > @@ -467,10 +467,9 @@ static int vr41xx_gpio_to_irq(struct gpio_chip *chip= , unsigned offset) > =20 > static int giu_probe(struct platform_device *pdev) > { > - struct resource *res; > unsigned int trigger, i, pin; > struct irq_chip *chip; > - int irq, ret; > + int irq; > =20 > switch (pdev->id) { > case GPIO_50PINS_PULLUPDOWN: > @@ -489,21 +488,14 @@ static int giu_probe(struct platform_device *pdev) > return -ENODEV; > } > =20 > - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); > - if (!res) > - return -EBUSY; > - > - giu_base =3D ioremap(res->start, resource_size(res)); > - if (!giu_base) > - return -ENOMEM; > + giu_base =3D devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(giu_base)) > + return PTR_ERR(giu_base); The driver currently doesn't request the memory described in the resource, so technically you're changing behaviour here and with your change the driver could now fail if somebody else has already claimed the memory. Looking at arch/mips/vr41xx there doesn't seem to be an overlap between the memory region used by the GIU device and any others, so this should be safe. Not sure anyone still has hardware for this around to give it a spin. Thierry > =20 > vr41xx_gpio_chip.parent =3D &pdev->dev; > =20 > - ret =3D gpiochip_add_data(&vr41xx_gpio_chip, NULL); > - if (!ret) { > - iounmap(giu_base); > + if (gpiochip_add_data(&vr41xx_gpio_chip, NULL)) > return -ENODEV; > - } > =20 > giu_write(GIUINTENL, 0); > giu_write(GIUINTENH, 0); > @@ -534,7 +526,6 @@ static int giu_probe(struct platform_device *pdev) > static int giu_remove(struct platform_device *pdev) > { > if (giu_base) { > - iounmap(giu_base); > giu_base =3D NULL; > } > =20 > --=20 > 1.9.1 >=20 --9Iq5ULCa7nGtWwZS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAlyHmfwACgkQ3SOs138+ s6GpPw/+PO40QInzGgfRGJGf5fQ2uQKUwIiH2EQxp0L7tmyvF/ZYodNb2Oy16DM4 ypJlpKtRU8udgnhj6h4Jr+rJ50Ak5Nz26aBltA0XVBpUm7eEfLbA3egfup3BtXDR eERmniHeC83brj+qd2ttpngN0p4RF06BiUtpqWQwYbPaM6ZRhZfqRr5Y3m673vRn Wm/uKpNVXJ+LjqDEbbwuawy9icfTjPK9u4x5W80H1Qw4AnQEH66cB6isB7kXCKNT hVA1AKnc2wor3HEQxNBhGESwg5j1tzBYQK6RJ6fVB9cnpOFQGjPCIjYsyJdNf1wc T27zc3UEL4Sy20crfEzVMaP23khdcdUFlyqLfnPfY3JmUT4NhhZr0FVUGP9iUHPa hLDtXwUEt+Ojol9uIAyT8OePfSm797Xpk6t+WVpt3H8hrXvXdo77NGUUZXG/IInq QAMeV/yN/iNOnUguWe7xjBHQLuVUbm+yuNCgKWFG+DOOKYjN8TLmuju1SeHHj/fx wge65+PnS+SiHzaNz8icRZHaH9VWSGS2qCvEcMuoGJZjGyz3ajaqdzSVfm0TsnIT R87r1B46OZC++ztZicofvfGtc1vInwaE8F1ikjKxa5VJoFofssI0HnzU+WHrgfcs PO9mqyLDHjv569YoyX7NcEWdtXotVJT/GlYdkkI+SN70/7Va+4M= =BSp7 -----END PGP SIGNATURE----- --9Iq5ULCa7nGtWwZS--