Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5311983ybe; Tue, 17 Sep 2019 06:13:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOzmU2RGjVt3beDPm+vy1rWlEZTqQGpr6/2QTE8RnCJB6EDhFD6P9rQ9ovEuC/cPIWav9M X-Received: by 2002:a5d:6785:: with SMTP id v5mr3042531wru.9.1568726005214; Tue, 17 Sep 2019 06:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568726005; cv=none; d=google.com; s=arc-20160816; b=zc4s98xA3uUAbVZAQzQd6HKzXFylR2Z2V8IyWV1Wl0SE6Fd0sBnCbbwQGUi1k/PDfN E+7lZWoNVQN2GM3IBYKHzyG7bAnEwp25oot43mVXkLUwdU07zJouJKNOWiYa8E+te4Qn KnxW1NViIeT70Qjiu71vRQRduIPaoisOADr3zz4TIu5KCP9fOKu+Xcz2vTuePGQ3nETm RuUuLxmsKxiIl1yefU3vrvYAy2eRk/3DKk5ujaCSOGIAmQBsd8UDWTSlHaiHV1jZCyDB 8bypTOFjKDyS70XdwRHJEU34cJpU+ZfHUu33LsZyZ2u9uf/SSlwE4vSE2XpWlHMTSF5j n2Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=g5v8FU71dAfo6AK8WTwyNN8dUr35hQbvr87IlwvE3Io=; b=qVcVvmXVf405kDLtKlR/igZU9UuMK+v1SY/qIuUmsywnSU9Q+TaKrt98YMGWL3XIfW phUaN/OrsM+IwwUDchNYpjVnam6N2Txj88PCP7HiES6wABnOTVf3KM7IxeCDB7zXY4XR 8Y7/ieiLm6luiXMDhJtEGen33M48Cp351ildxpp2Dw+iv3XxW8Y6WLPJs2DK7ICOoEnW MNaSBttMMe8xnkTRJKZZ5edPXWMjEW7FHKfq/klCmJVAAVx0RfIy3olhqBOtFX4mN0M+ tQyS9mwkYnfchFcZJpM3EEC3XLrNi1Q26DwAGn24SjYO9+zV/EHKSZBk8vMQ1f19pY2i vD1w== 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 y1si1251015edm.323.2019.09.17.06.13.00; Tue, 17 Sep 2019 06:13:25 -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; 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 S1727698AbfIQNID (ORCPT + 99 others); Tue, 17 Sep 2019 09:08:03 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:43234 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbfIQNID (ORCPT ); Tue, 17 Sep 2019 09:08:03 -0400 Received: by mail-oi1-f194.google.com with SMTP id t84so2736371oih.10; Tue, 17 Sep 2019 06:08:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=g5v8FU71dAfo6AK8WTwyNN8dUr35hQbvr87IlwvE3Io=; b=GaQCfgDmoIJDIj/HMimAHculytQx+8TRcXB+HkljHd29Db/5qwdcLBUlyTNzd2mHic FFVjzssqTBaTXoKHkcsPy14+IMrAkH/4f9Q2fqqNPlp+fxGEgMsONIOe4qW9uzAhnUNT VEa0C7eUZUdG08andew3N7iU6rewjQ1Qd2ihRVtblKhinW8s/JDc/AbNAAjXjxIUjqXa +jlBgHpUpym7zeGFW47Sd1b0SqDTFrKgY7xSziGMtu4KnnUc3TKo6+qvkFo2BNyqXIAG Kqp3pgc0a/houA1VOuCuDTBRDO33s/TLBu0EdAhcCU64KdK+l/djRbQoltcep22hg/2t vcPQ== X-Gm-Message-State: APjAAAU71hkjtwcQguruxLO3nfI/nsQhQMcazaD7pd6DjViBgOztQsnl eT3pQex+1X95Bei1lTxn4QsQkuIepcuBeYBrJyY= X-Received: by 2002:aca:f305:: with SMTP id r5mr3356423oih.131.1568725681893; Tue, 17 Sep 2019 06:08:01 -0700 (PDT) MIME-Version: 1.0 References: <20190917085627.4562-1-mail@aurabindo.in> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 17 Sep 2019 15:07:50 +0200 Message-ID: Subject: Re: [PATCH] spi: sifive: check return value for platform_get_resource() To: Paul Walmsley Cc: Baolin Wang , Aurabindo Jayamohanan , Mark Brown , Palmer Dabbelt , linux-spi , linux-riscv@lists.infradead.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, On Tue, Sep 17, 2019 at 2:16 PM Paul Walmsley wrote: > On Tue, 17 Sep 2019, Baolin Wang wrote: > > On Tue, 17 Sep 2019 at 17:12, Aurabindo Jayamohanan wrote: > > > platform_get_resource() may return NULL. If it is so, return -ENXIO > > > > > > Signed-off-by: Aurabindo Jayamohanan > > > --- > > > 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_device *pdev) > > > platform_set_drvdata(pdev, master); > > > > > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > > + if (!res) { > > > + dev_err(&pdev->dev, "no IOMEM resource found\n"); > > > + ret = -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? Probably not. The sequence can be replaced by a single call to devm_platform_ioremap_resource(), which BTW also doesn't check the intermediate result, as that's unneeded. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds