Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6172105iob; Tue, 10 May 2022 11:58:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl9S2VwrlauP3atk4VBOP6FDN3KVHmxnPS6pBCcO8NCsby9zRnXef2HnbLstIjsnT27vip X-Received: by 2002:a05:622a:14c6:b0:2e2:3f:f938 with SMTP id u6-20020a05622a14c600b002e2003ff938mr21073179qtx.358.1652209139245; Tue, 10 May 2022 11:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652209139; cv=none; d=google.com; s=arc-20160816; b=gJdTyu6JVZZpgJqyms+tlCP7oCY168k+wChwVHwRLkAqUPgdf/b/WYgObcxQduEG99 Ul+r2I0WGx+5OIPEb5miSIEap0XxufX/qew031+IpR69lRsOKrLgc/C14tNVkQBCsSik xpT4QabJvyu9aWq8cBRDyqThqGP7bAoeMOO1N/60fK+em+IpVsrX0mErkW+wDCTicyeJ 9HuoOYbOzYwAUQa8g3w7NVVy3bY+Aa/JKG948YCJh+ObXl+cppZCucxuIZgeeuealb4m 406j+MsBQSOjnYDx/d66751mmlRXxQipn0OrqKH4GhkyY9Bsx2+E7uYBfurF/1sBGyDw 2VHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sNpsQrS7bRHbkVhDDh7veJc42zC8dW1iNbM2RveywWU=; b=iHaxLiqv7c4muWBVQoOFKu3n97axeXMOZcbJQqFvCrHQMBdWNW6v+/iz4CjsuXMvAY GJVNe3U9Y1L8uAVaegZTTMi8U2urcqhYfHh5T+YhYnbjfnAB6BHBLm+I8NITJE7FlziV /ta2Cx+WiNTYuCww7XwhcAD5aqs3DGF5jn0twxhIL3gbafnWdIOBRcjVM7Zl0LWZaOxf QtSu//pnikK0mXh30MXgX1o2yHpWbtKUA5JbtrHrIQRaxvT2qu2a/QGpZJ2yy9t0sSqh rSjiulSR83Y0XHWEV/nQ6NPuwADjmjwjOBKFxIvTfM0v2f/K9Y7vgyLJmDEeHAWZsxhu bhYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=vjM2lIFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a05620a25d200b0069f99b3f658si11775620qko.378.2022.05.10.11.58.43; Tue, 10 May 2022 11:58:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=vjM2lIFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344838AbiEJOpr (ORCPT + 99 others); Tue, 10 May 2022 10:45:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242769AbiEJOof (ORCPT ); Tue, 10 May 2022 10:44:35 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA24F1B12D3 for ; Tue, 10 May 2022 07:02:40 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 12D552224D; Tue, 10 May 2022 16:02:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1652191358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sNpsQrS7bRHbkVhDDh7veJc42zC8dW1iNbM2RveywWU=; b=vjM2lIFstx/0lCKopKyQAx10ui00/X/78QfkIkAKIb1weg+It1Ublv4YwmPQ1dGgteRJAr FxUR4WJ8unAZRa2tDF1ogwYRHLRG9z/MhrDBYpFTEwxH2rUUQSohB7mJQBAbBXn8Eker9h bwcGHYueM0byx/2oUnYvn/E4yL8L1ig= From: Michael Walle To: Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Shaik Sajida Bhanu Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH 1/2] mtd: spi-nor: introduce SNOR_ID3() Date: Tue, 10 May 2022 16:02:31 +0200 Message-Id: <20220510140232.3519184-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220510140232.3519184-1-michael@walle.cc> References: <20220510140232.3519184-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Up until now, flashes were defined by specifying the JEDEC ID, the sector size and the number of sectors. This can be read by parsing the SFDP, we don't have to specify it. Thus provide a new macro SNOR_ID3() which just takes the JEDEC ID and implicitly set .parse_sfdp = true. All new flashes which have SFDP should use this macro. Signed-off-by: Michael Walle --- drivers/mtd/spi-nor/core.c | 7 +++++-- drivers/mtd/spi-nor/core.h | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 402b37cdbcea..29329ed0a934 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2104,8 +2104,11 @@ static int spi_nor_select_pp(struct spi_nor *nor, * spi_nor_select_uniform_erase() - select optimum uniform erase type * @map: the erase map of the SPI NOR * @wanted_size: the erase type size to search for. Contains the value of - * info->sector_size or of the "small sector" size in case - * CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is defined. + * info->sector_size, the "small sector" size in case + * CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is defined or 0 if + * there is no information about the sector size. The + * latter is the case if the flash parameters are parsed + * solely by SFDP. * * Once the optimum uniform sector erase command is found, disable all the * other. diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 61886868cd02..fab3038c4f4a 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -563,6 +563,15 @@ struct flash_info { .n_regions = (_n_regions), \ }, +#define SNOR_ID3(_jedec_id) \ + .id = { \ + ((_jedec_id) >> 16) & 0xff, \ + ((_jedec_id) >> 8) & 0xff, \ + (_jedec_id) & 0xff, \ + }, \ + .id_len = 3, \ + .parse_sfdp = true, \ + #define PARSE_SFDP \ .parse_sfdp = true, \ -- 2.30.2