From nobody Fri Sep 5 07:57:11 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C20AC001B0 for ; Mon, 7 Aug 2023 13:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233948AbjHGNW2 (ORCPT ); Mon, 7 Aug 2023 09:22:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233941AbjHGNWM (ORCPT ); Mon, 7 Aug 2023 09:22:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90ADC1992 for ; Mon, 7 Aug 2023 06:22:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 06AD261AD8 for ; Mon, 7 Aug 2023 13:22:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3FDCC433A9; Mon, 7 Aug 2023 13:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691414525; bh=Q4z4+GIyFZK8CSdRNcA78KcB6lv81rYFZShyRxMrYg8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Xy9tZZyDS9je5J/g5EPyXSF5L28YejMfzVdB3pstP80KdTfQAO9R5VCFIcYn4TrPh 1zJBWiJPCtn3ui2aBMISCrzXDs1typj833a+eUPw977ssxgTzHyBxS8ckonXO1JCGE JbR3AOhxrV2BufQ1iuDNmUzEXp7zkTzkoSeCsmU8OkQfaAkKhVVGX0kGtbJBLTJYaM i90jVNJLq48HQlpIOBAlsuxEi5/JxK8ou+X5wJaTdAmyjzs+Lk6nrRyD5/3z8u8qX5 u3L+0AW0NHznZO3CxU8wprOwygBx3eYtxoXQbgv/8N5upCWabLKeD4r5+9CUkJyVAW Jt40hC41GFArw== From: Michael Walle Date: Mon, 07 Aug 2023 15:21:00 +0200 Subject: [PATCH 06/41] mtd: spi-nor: default page_size to 256 bytes MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230807-mtd-flash-info-db-rework-v1-6-3d3d5bef4ba4@kernel.org> References: <20230807-mtd-flash-info-db-rework-v1-0-3d3d5bef4ba4@kernel.org> In-Reply-To: <20230807-mtd-flash-info-db-rework-v1-0-3d3d5bef4ba4@kernel.org> To: Tudor Ambarus , Pratyush Yadav , Michael Walle , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Michael Walle X-Mailer: b4 0.12.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The INFO() macro always set the page_size to 256 bytes. Make that an optinal parameter. This default is a sane one for all older flashes, newer ones will set the page size by its SFDP tables anyway. Signed-off-by: Michael Walle Reviewed-by: Miquel Raynal --- drivers/mtd/spi-nor/core.c | 7 +------ drivers/mtd/spi-nor/core.h | 8 ++++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index c504a5af4032..138bc1e0a67c 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2017,11 +2017,6 @@ static const struct spi_nor_manufacturer *manufactur= ers[] =3D { static const struct flash_info spi_nor_generic_flash =3D { .name =3D "spi-nor-generic", .n_banks =3D 1, - /* - * JESD216 rev A doesn't specify the page size, therefore we need a - * sane default. - */ - .page_size =3D 256, .parse_sfdp =3D true, }; =20 @@ -3000,7 +2995,7 @@ static void spi_nor_init_default_params(struct spi_no= r *nor) params->writesize =3D 1; params->size =3D info->size; params->bank_size =3D params->size; - params->page_size =3D info->page_size; + params->page_size =3D info->page_size ?: SPI_NOR_DEFAULT_PAGE_SIZE; =20 if (!(info->flags & SPI_NOR_NO_FR)) { /* Default to Fast Read for DT and non-DT platform devices. */ diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 12c35409493b..25bc18197614 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -10,6 +10,11 @@ #include "sfdp.h" =20 #define SPI_NOR_MAX_ID_LEN 6 +/* + * 256 bytes is a sane default for most older flashes. Newer flashes will + * have the page size defined within their SFDP tables. + */ +#define SPI_NOR_DEFAULT_PAGE_SIZE 256 =20 /* Standard SPI NOR flash operations. */ #define SPI_NOR_READID_OP(naddr, ndummy, buf, len) \ @@ -447,7 +452,7 @@ struct spi_nor_fixups { * @sector_size: the size listed here is what works with SPINOR_OP_SE, = which * isn't necessarily called a "sector" by the vendor. * @n_banks: the number of banks. - * @page_size: the flash's page size. + * @page_size: (optional) the flash's page size. Defaults to 256. * @addr_nbytes: number of address bytes to send. * * @parse_sfdp: true when flash supports SFDP tables. The false value = has no @@ -558,7 +563,6 @@ struct flash_info { #define SPI_NOR_GEOMETRY(_sector_size, _n_sectors, _n_banks) \ .size =3D (_sector_size) * (_n_sectors), \ .sector_size =3D (_sector_size), \ - .page_size =3D 256, \ .n_banks =3D (_n_banks) =20 /* Used when the "_ext_id" is two bytes at most */ --=20 2.39.2