Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6032399ybe; Tue, 17 Sep 2019 18:31:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeMvnOC+Oz2UvIQCVkoAh76XRskQysmZXhDPfd49JeKjtt5wJRccLm77OjwC011J4i4ptm X-Received: by 2002:a17:906:ecf9:: with SMTP id qt25mr7266340ejb.249.1568770304031; Tue, 17 Sep 2019 18:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568770304; cv=none; d=google.com; s=arc-20160816; b=igFzyLe+T50WSSfw+VsUJNtDBHdVTM+CudD+BAniLO4BZly69iUILlqLzDimeka5bJ Vjue4QmCqglsPv+Pl+0LES1VgOhQRuhcVG8K9m7XhTUmGlyyrZTquGrHhelFh+hMH1jn yQMPO0El4YoIJyK9k/cww+mvb5k2wCFZqZdP87yM5EQa0ZqUjdx6FfcFFqGFpCXeAnDo /P4GcSs6O/DBDqLOwO9+V+8bHDsAM5XAeQ73tIaQ7nQ3hc+ZG6yVbE7tNgaKa2/MgDTP 4uMCzgpyCJk7NuyrPtEd1KA69g+0f/bHTsm24TENI8o5q5G9b/X5lzGMSuPDDwHsX8va 4ERg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:reply-to:cc :from:to:dkim-signature:date; bh=IzxXyf9LUqJRZ0W8vp8MTxeBb0vPHdEwkUasYCPeF90=; b=g74h0lyQ1NWoB8u8Q9/dMsJEIkT1+gn4/hJ7FbvHX+L99fjTzW4kN5fCgHj4sZqOqN R7wR6QJivZv9yB8F+iA1LStFSaiEi7gxpoK2/l1DwmtEDMGrrwAFA4Xbf5i5BFgft3vi skx8bUKMiQZzAI5ORumWq9DdJF/Ns5ZEL0Q+SOnVfMY2QutOPimn/BgElHabgKws42bM zFVrOaOZPQv2gwCxspgij/2ry/a3rkJ0Y77dTO5Nbt3WSHB9dfltRIo31JlrF9wheOPm ou4YqX97cBfW3EuMCApM/Z9sJwFgQYPgKFjo0qu6j3vMdj4Gl/hVh/+2nqyazHQhaNpR z8Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aurabindo.in header.s=protonmail header.b=CFMJ9hdK; 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=NONE dis=NONE) header.from=aurabindo.in Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l22si2066765ejz.239.2019.09.17.18.31.18; Tue, 17 Sep 2019 18:31:44 -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=@aurabindo.in header.s=protonmail header.b=CFMJ9hdK; 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=NONE dis=NONE) header.from=aurabindo.in Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726819AbfIQOGy (ORCPT + 99 others); Tue, 17 Sep 2019 10:06:54 -0400 Received: from mail2.protonmail.ch ([185.70.40.22]:13667 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbfIQOGy (ORCPT ); Tue, 17 Sep 2019 10:06:54 -0400 Date: Tue, 17 Sep 2019 14:06:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aurabindo.in; s=protonmail; t=1568729209; bh=IzxXyf9LUqJRZ0W8vp8MTxeBb0vPHdEwkUasYCPeF90=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References: Feedback-ID:From; b=CFMJ9hdKjn2aCG9YQCmmp71v8ZTD11TwZDi5LFDlbLfg6t3IFfSAePNh+sipGs7XN Hm4SEN4SazYKJFhWytWwStqkkSXK8DZGWtY1tGwZtRimoSqUU7Y/Wwaj1WG6RhsOUx wEAjEB1dU9dwC7y7HaRIgyFD1NvImDLS30YSqxw8= To: Paul Walmsley From: Aurabindo Jayamohanan Cc: Baolin Wang , Mark Brown , "palmer@sifive.com" , linux-spi , "linux-riscv@lists.infradead.org" , LKML Reply-To: Aurabindo Jayamohanan Subject: Re: [PATCH] spi: sifive: check return value for platform_get_resource() Message-ID: In-Reply-To: References: <20190917085627.4562-1-mail@aurabindo.in> Feedback-ID: D1Wwva8zb0UdpJtanaReRLGO3iCsewpGmDn8ZDKmpao-Gnxd2qXPmwwrSQ99r5Q15lmK-D8x6vKzqhUKCgzweA==:Ext:ProtonMail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=3.8 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: *** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Tuesday, September 17, 2019 5:45 PM, Paul Walmsley wrote: > On Tue, 17 Sep 2019, Baolin Wang wrote: > > > On Tue, 17 Sep 2019 at 17:12, Aurabindo Jayamohanan mail@aurabindo.in w= rote: > > > > > platform_get_resource() may return NULL. If it is so, return -ENXIO > > > > > > Signed-off-by: Aurabindo Jayamohanan mail@aurabindo.in > > > > > > ------------------------------------------------------- > > > > > > drivers/spi/spi-sifive.c | 6 ++++++ > > > 1 file changed, 6 insertions(+) > > > diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c > > > index 93ec2c6cdbfd..67485067a694 100644 > > > --- a/drivers/spi/spi-sifive.c > > > +++ b/drivers/spi/spi-sifive.c > > > @@ -308,6 +308,12 @@ static int sifive_spi_probe(struct platform_devi= ce *pdev) > > > platform_set_drvdata(pdev, master); > > > > > > res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); > > > > > > > > > - if (!res) { > > > > > > > > > - dev_err(&pdev->dev, "no IOMEM resource found\\n"); > > > > > > > > > - ret =3D -ENXIO; > > > > > > > > > - goto put_master; > > > > > > > > > - } > > > > > > > > > > Seems unnecessary, the devm_ioremap_resource() already validated if > > the resource is available. > > Just doublechecked lib/devres.c and I agree with you. > > Aurobindo, is this a patch for a real problem that you've encountered? > > - Paul Geert is right. I was just breezing through the source and found it odd sin= ce I noticed other instances checking for return value. Apparently none of tho= se use the managed api. If you didnt already do Geert's suggestion, here is a patch: ____ spi: sifive: use device managed api to get plaform resource calls to devm_ioremap_resource() preceeded by platform_get_resource() may be replaced by devm_platform_ioremap_resource(). Signed-off-by: Aurabindo Jayamohanan --- drivers/spi/spi-sifive.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c index 93ec2c6cdbfd..c0925aa98aad 100644 --- a/drivers/spi/spi-sifive.c +++ b/drivers/spi/spi-sifive.c @@ -292,7 +292,6 @@ sifive_spi_transfer_one(struct spi_master *master, stru= ct spi_device *device, static int sifive_spi_probe(struct platform_device *pdev) { =09struct sifive_spi *spi; -=09struct resource *res; =09int ret, irq, num_cs; =09u32 cs_bits, max_bits_per_word; =09struct spi_master *master; @@ -307,8 +306,7 @@ static int sifive_spi_probe(struct platform_device *pde= v) =09init_completion(&spi->done); =09platform_set_drvdata(pdev, master); -=09res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); -=09spi->regs =3D devm_ioremap_resource(&pdev->dev, res); +=09spi->regs =3D devm_platform_ioremap_resource(pdev, 0); =09if (IS_ERR(spi->regs)) { =09=09ret =3D PTR_ERR(spi->regs); =09=09goto put_master; -- 2.23.0