Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp659353oof; Tue, 25 Sep 2018 02:59:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV61umDkTMlYph/6D40Q5/FhLk07Tk0S5WP99yNPtUjqqVDXR919vt1OYIsAYaYJsbjbvM2Xl X-Received: by 2002:a62:db46:: with SMTP id f67-v6mr268831pfg.1.1537869564609; Tue, 25 Sep 2018 02:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537869564; cv=none; d=google.com; s=arc-20160816; b=H6i19mBCZXNvpKTVZWMXP+LPhwfoeuquw4h1PWuiBPZOJxYs7YU/24xhhPV2O4efh2 NL+FqoEbNuZw6KXiibQRzcCKlKprcFv0rqRuUgcRCtGJA6WMOYXpRSRbpfUa1NXNfxpI zUWLhSkQiooOi1QdmIH4A3gkMSVnpNtbWV7wZDtPX5+1VY89bBQbFCOPvfnIvqxWKXwB BClgzTeqP56s69/EAmeVUG1N38moXDwvMQJi/FVMMI5q5nr2As4WzX9WkMIguflU5aV6 3RBo4DcKcJRqnjSjzgns84YMOEZAIlla/IlFEiHmWWJ69yrr40ebp5Hl7zDTf5PpOuq4 Ik0g== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=RVcrxigAsWeQl+t10P1oipNUuijPP86v55hyeF1B9rI=; b=KTVGsKpPlElwlf8tWsg8HudhYuuKtvKRfGo/KuykmTNyka30dUdkgGGr97yoVjTpnu xQW/dteLz+RO12aczxTFmnmT95VYUsNuWJ6KLIm7q+NxWEedhfUsQsou8EP3L4o2RkIo omQZdWV2xkcw68BhUyrgkoBf93faGYkZc+zwchjls1YuwtTAAn++pZ6HjgQj+cUniLi1 Ep49W9dQ/zsSl0QZyiusoCeoT77micQjB2RoCzbTvB45mJAuCOs8hIzX8EYfpKZILG6M HmA0wP244+bXvxBtBgi/DXLOQEeWPfjX5BtM0/erNMA0h7rplqtRwQGft+syKaaXF8TE GO1A== 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 s63-v6si1923183pfj.226.2018.09.25.02.59.08; Tue, 25 Sep 2018 02:59:24 -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 S1728289AbeIYQFY (ORCPT + 99 others); Tue, 25 Sep 2018 12:05:24 -0400 Received: from mail.bootlin.com ([62.4.15.54]:36614 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbeIYQFX (ORCPT ); Tue, 25 Sep 2018 12:05:23 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 5631F20731; Tue, 25 Sep 2018 11:58:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-42-80.w90-88.abo.wanadoo.fr [90.88.160.80]) by mail.bootlin.com (Postfix) with ESMTPSA id 8CED7203DA; Tue, 25 Sep 2018 11:58:24 +0200 (CEST) Date: Tue, 25 Sep 2018 11:58:23 +0200 From: Boris Brezillon To: Geert Uytterhoeven Cc: Mark Brown , David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] spi: spi-mem: Fix inverted logic in op sanity check Message-ID: <20180925115823.3dd07cda@bbrezillon> In-Reply-To: <20180925094655.11438-1-geert+renesas@glider.be> References: <20180925094655.11438-1-geert+renesas@glider.be> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 25 Sep 2018 11:46:55 +0200 Geert Uytterhoeven wrote: > On r8a7791/koelsch: > > m25p80 spi0.0: error -22 reading 9f > m25p80: probe of spi0.0 failed with error -22 > > Apparently the logic in spi_mem_check_op() is wrong, rejecting the > spi-mem operation if any buswidth is valid, instead of invalid. > > Fixes: 380583227c0c7f52 ("spi: spi-mem: Add extra sanity checks on the op param") > Signed-off-by: Geert Uytterhoeven Reviewed-by: Boris Brezillon Sorry for the mess :-/, and thanks for reporting/fixing it. > --- > drivers/spi/spi-mem.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c > index cc3d425aae56c634..62a7b80801d22098 100644 > --- a/drivers/spi/spi-mem.c > +++ b/drivers/spi/spi-mem.c > @@ -169,10 +169,10 @@ static int spi_mem_check_op(const struct spi_mem_op *op) > (op->data.nbytes && !op->data.buswidth)) > return -EINVAL; > > - if (spi_mem_buswidth_is_valid(op->cmd.buswidth) || > - spi_mem_buswidth_is_valid(op->addr.buswidth) || > - spi_mem_buswidth_is_valid(op->dummy.buswidth) || > - spi_mem_buswidth_is_valid(op->data.buswidth)) > + if (!spi_mem_buswidth_is_valid(op->cmd.buswidth) || > + !spi_mem_buswidth_is_valid(op->addr.buswidth) || > + !spi_mem_buswidth_is_valid(op->dummy.buswidth) || > + !spi_mem_buswidth_is_valid(op->data.buswidth)) > return -EINVAL; > > return 0;