From patchwork Thu Feb 18 05:12:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 584500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 1619A140317 for ; Thu, 18 Feb 2016 16:09:29 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=uhC7ux2V; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7EAA7A7531; Thu, 18 Feb 2016 06:09:25 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dum8uk-BmG3Z; Thu, 18 Feb 2016 06:09:25 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B4A1A74B4; Thu, 18 Feb 2016 06:09:25 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A93E6A74B4 for ; Thu, 18 Feb 2016 06:09:22 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XNKnPeQiSv-7 for ; Thu, 18 Feb 2016 06:09:22 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pf0-f173.google.com (mail-pf0-f173.google.com [209.85.192.173]) by theia.denx.de (Postfix) with ESMTPS id 32E9E4BA29 for ; Thu, 18 Feb 2016 06:09:18 +0100 (CET) Received: by mail-pf0-f173.google.com with SMTP id c10so25195583pfc.2 for ; Wed, 17 Feb 2016 21:09:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=QeSKLnS27f48WijnbPyUhVZbCfgXuZojDmoWLKz6cj8=; b=uhC7ux2VEVF1uc7IUydy9mavxg492QIUGJp1B7Ttsa2MtE6ZsZwPrJXnMNWIsfflFE opXUAp6VhfaAWpm2XKhaI3RRa/kkayEAmVrZMjA7PdWl3N+dFhRBwgQ26TZHtiTHxq7X upLxFudiLoHslAzHWlY9WL061s24yvntk2U10FCfiUzkeTrj59LLhETH4LIHKphXcPPq EKTe8xCtVF9nkCdmRGbgl52Thg+KX4SJiHwzSnzxEqSSHyykt7h8HD7VerAKfhnuL+O9 XKn8uy/+hSPWpArleYIRgwrzzvfllOaoumz7rC7TYIKkGbWKHMTnR26/CNJgMTHrzwDv Fnmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=QeSKLnS27f48WijnbPyUhVZbCfgXuZojDmoWLKz6cj8=; b=DFmOY75jQfocdxO+aVO0r5c2PxHSYg4pO5ykUe4nKSgcEufzMk/ONGwFWiDyPnbLwo /iLndgMnMBqOZyWblA7PwMv3Sr6rqbZAOhOeQHkxWwLxjNY6acp76OKF17uNgXTGPCdU 2RZeLHJd3WHdc8Xl8x30PulAOyACx6yQm22MoEZs4z7Jo4TUHHc6LyaVCj746BikSqEe R6jRKOURNhIVO2psssVnz1yQDJs5yWfk66+FwG+FppLUhP4sVaBuNgLeJmqexSgiwBB7 tuOcnjCNFudYsGUDoCmtmi2e+bsJV0gFZZ7E5HDuFf7MnyiSn2WEhh/iOS78qirC2Lc9 Xd4A== X-Gm-Message-State: AG10YOTaVVawKQLpisI/RtNRoaa7iHStARltLQgDtcmoIYdhVDfeWdgSpGQ7Ax1nsVJSbA== X-Received: by 10.98.68.212 with SMTP id m81mr7438636pfi.135.1455772156661; Wed, 17 Feb 2016 21:09:16 -0800 (PST) Received: from ala-d2121-lx1.wrs.com (unknown-157-139.windriver.com. [147.11.157.139]) by smtp.gmail.com with ESMTPSA id yl1sm6343047pac.35.2016.02.17.21.09.15 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Feb 2016 21:09:16 -0800 (PST) From: Bin Meng To: Jagan Teki , Simon Glass , Tom Rini , Michal Simek , Siva Durga Prasad Paladugu , Mugunthan V N , Stefan Roese , Vikas Manocha , U-Boot Mailing List Date: Wed, 17 Feb 2016 21:12:27 -0800 Message-Id: <1455772347-25392-1-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 Subject: [U-Boot] [PATCH] spi-nor: Correct the logic to detect flash rw mode X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" spi->mode includes all available modes for operating on SPI flashes, and we should test each bit instead of a switch..case statement to make the detection logic correct. Signed-off-by: Bin Meng --- drivers/mtd/spi-nor/m25p80.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c index 4e0a53c..9d17449 100644 --- a/drivers/mtd/spi-nor/m25p80.c +++ b/drivers/mtd/spi-nor/m25p80.c @@ -178,26 +178,16 @@ static int m25p80_spi_nor(struct spi_nor *nor) return ret; } - switch (spi->mode) { - case SPI_RX_SLOW: + if (spi->mode & SPI_RX_SLOW) nor->read_mode = SNOR_READ; - break; - case SPI_RX_DUAL: + else if (spi->mode & SPI_RX_DUAL) nor->read_mode = SNOR_READ_1_1_2; - break; - case SPI_RX_QUAD: + else if (spi->mode & SPI_RX_QUAD) nor->read_mode = SNOR_READ_1_1_4; - break; - } - - switch (spi->mode) { - case SPI_TX_BYTE: + else if (spi->mode & SPI_TX_BYTE) nor->mode = SNOR_WRITE_1_1_BYTE; - break; - case SPI_TX_QUAD: + else if (spi->mode & SPI_TX_QUAD) nor->mode = SNOR_WRITE_1_1_4; - break; - } nor->memory_map = spi->memory_map; nor->max_write_size = spi->max_write_size;