From patchwork Tue Sep 25 09:46:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10613829 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-2.web.codeaurora.org (Postfix) with ESMTP id A950A6CB for ; Tue, 25 Sep 2018 09:47:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D77829ADE for ; Tue, 25 Sep 2018 09:47:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9184A29B3C; Tue, 25 Sep 2018 09:47:04 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 4D33B29ADE for ; Tue, 25 Sep 2018 09:47:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726125AbeIYPxo (ORCPT ); Tue, 25 Sep 2018 11:53:44 -0400 Received: from laurent.telenet-ops.be ([195.130.137.89]:57086 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727281AbeIYPxo (ORCPT ); Tue, 25 Sep 2018 11:53:44 -0400 Received: from ramsan.of.borg ([84.194.111.163]) by laurent.telenet-ops.be with bizsmtp id flmw1y00j3XaVaC01lmwdT; Tue, 25 Sep 2018 11:46:59 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1g4jvk-0001DV-Ot; Tue, 25 Sep 2018 11:46:56 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1g4jvk-0002zD-N8; Tue, 25 Sep 2018 11:46:56 +0200 From: Geert Uytterhoeven To: Mark Brown , Boris Brezillon Cc: 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, Geert Uytterhoeven Subject: [PATCH] spi: spi-mem: Fix inverted logic in op sanity check Date: Tue, 25 Sep 2018 11:46:55 +0200 Message-Id: <20180925094655.11438-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 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 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 --- 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;