Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp228871ybm; Thu, 28 May 2020 01:01:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyOWf9wCcm0DbNS1zSN3J5/rNsie0AlC1Ngdc7PUdkzVR5g4I09HtAoLZZRRhz9viPuZpv X-Received: by 2002:a17:906:279a:: with SMTP id j26mr1746402ejc.398.1590652870653; Thu, 28 May 2020 01:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590652870; cv=none; d=google.com; s=arc-20160816; b=Q/CdCU/cKlMDElLV2qlogBOFRYq8JcYjJohjBHTYOwU6pMwrNG5imkhMfHXK4ONEGD mGpU0cZ1ydb94LjuMG7ZXu2ZUzsr8usFjgsypYZsPN2MTsgso8aqzhlW/upI7sDOyzqf NPbem6lpUcvPw7Q04FKWTmmnW3Rpbe6HGYMVW4tpAAOy8RaEJKWyic+/YDelWPiog8hk ytUOey7nVzhNSqEd1FGufkCF93xyU2XCVVPfloc5g56VsAXWw+3lC9tbmmMlW14Q1GBk FrtiTgq9/CYrciqhH7ii9LoauZCTe4n7qJm+sReI0/68SG1xoF98+UtTy3PZZdemQOEf ehaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=q7mWVheGMIisHJhL3nD1LZznHAsYoYpVVeaqSoGsSqY=; b=0RiOPHEA+oy+uAAIdfrCVwx/mCBrNFnIBdI/5ZUu18cj9ZCHsDRoNYXviV2jXaF7z5 gEKvJ+UM9Dd5p9jjyfuzS74+B6l8kdk7m+cokgi+B1tJ/76Db43FwlQq8rwhJrjC4jg+ FwPCFfF8atpIQ6LjKrSJPGjTXdYkhhZIUn+9cAa0SUu5pIxsrmFa/3ksVNtDTmIjcvpk hTbLv0t1PfuE/hrSblG6hzE/PlG5VVmzaDhJQFPZQHsaoi4PqpYj6bVoEELImzr09TTy 30eX/v4qhCqND7MeazNPsGx8ewW9blGmZRu1rDdAXZkZFSerGxE2NlT8RuTWvHKHVKPt 9BSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r2si3166829edw.103.2020.05.28.01.00.47; Thu, 28 May 2020 01:01:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbgE1H6t (ORCPT + 99 others); Thu, 28 May 2020 03:58:49 -0400 Received: from twhmllg4.macronix.com ([122.147.135.202]:31138 "EHLO TWHMLLG4.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726649AbgE1H6t (ORCPT ); Thu, 28 May 2020 03:58:49 -0400 Received: from localhost.localdomain ([172.17.195.96]) by TWHMLLG4.macronix.com with ESMTP id 04S7wMHd030973; Thu, 28 May 2020 15:58:26 +0800 (GMT-8) (envelope-from masonccyang@mxic.com.tw) From: Mason Yang To: broonie@kernel.org, tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, boris.brezillon@collabora.com, matthias.bgg@gmail.com Cc: p.yadav@ti.com, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org Subject: [PATCH v3 04/14] mtd: spi-nor: sfdp: prepare BFPT parsing for JESD216 rev D Date: Thu, 28 May 2020 15:58:06 +0800 Message-Id: <1590652696-8844-5-git-send-email-masonccyang@mxic.com.tw> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1590652696-8844-1-git-send-email-masonccyang@mxic.com.tw> References: <1590652696-8844-1-git-send-email-masonccyang@mxic.com.tw> X-MAIL: TWHMLLG4.macronix.com 04S7wMHd030973 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pratyush Yadav JESD216 rev D makes BFPT 20 DWORDs. Update the BFPT size define to reflect that. The check for rev A or later compared the BFPT header length with the maximum BFPT length, BFPT_DWORD_MAX. Since BFPT_DWORD_MAX was 16, and so was the BFPT length for both rev A and B, this check worked fine. But now, since BFPT_DWORD_MAX is 20, it means this check will also stop BFPT parsing for rev A or B, since their length is 16. So, instead check for BFPT_DWORD_MAX_JESD216 to stop BFPT parsing for the first JESD216 version, and check for BFPT_DWORD_MAX_JESD216B for the next two versions. Signed-off-by: Pratyush Yadav --- drivers/mtd/spi-nor/sfdp.c | 7 ++++++- drivers/mtd/spi-nor/sfdp.h | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index f917631..c289395 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -548,7 +548,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, SNOR_ERASE_TYPE_MASK; /* Stop here if not JESD216 rev A or later. */ - if (bfpt_header->length < BFPT_DWORD_MAX) + if (bfpt_header->length == BFPT_DWORD_MAX_JESD216) return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params); @@ -604,6 +604,11 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, return -EINVAL; } + /* Stop here if JESD216 rev B. */ + if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B) + return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, + params); + return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params); } diff --git a/drivers/mtd/spi-nor/sfdp.h b/drivers/mtd/spi-nor/sfdp.h index e0a8ded..f8198af 100644 --- a/drivers/mtd/spi-nor/sfdp.h +++ b/drivers/mtd/spi-nor/sfdp.h @@ -10,11 +10,11 @@ /* Basic Flash Parameter Table */ /* - * JESD216 rev B defines a Basic Flash Parameter Table of 16 DWORDs. + * JESD216 rev D defines a Basic Flash Parameter Table of 20 DWORDs. * They are indexed from 1 but C arrays are indexed from 0. */ #define BFPT_DWORD(i) ((i) - 1) -#define BFPT_DWORD_MAX 16 +#define BFPT_DWORD_MAX 20 struct sfdp_bfpt { u32 dwords[BFPT_DWORD_MAX]; @@ -22,6 +22,7 @@ struct sfdp_bfpt { /* The first version of JESD216 defined only 9 DWORDs. */ #define BFPT_DWORD_MAX_JESD216 9 +#define BFPT_DWORD_MAX_JESD216B 16 /* 1st DWORD. */ #define BFPT_DWORD1_FAST_READ_1_1_2 BIT(16) -- 1.9.1