Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp956648iob; Fri, 13 May 2022 17:39:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQnYf/2FuMoJmRLfYsbpQjmAiLqmIbPYUpNrPeAeWxQmXAh/VYo/tKjbiw7Plbfug6qpMV X-Received: by 2002:a05:6000:1707:b0:20c:660c:7c78 with SMTP id n7-20020a056000170700b0020c660c7c78mr5933976wrc.150.1652488779472; Fri, 13 May 2022 17:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652488779; cv=none; d=google.com; s=arc-20160816; b=HiocTrWkqJdpjB5tpY9nvVoHcgqzJuyvQfW98O8a2CAEhI9nEOGPkcSNYgVCRS/wwY bYDyHQUgvv8W55315hwag4e3dHcK2RswLrxepKgLpDnvHZCncmgLLRWVzh0ZcjBuCva4 noEVCSF/BtmU3gKiFZR6VLJAjgufp//5lEWt16Y/tlpVeY38hZ9tnsRRYgw6ipYQ75O5 nCMRb//UNL/PMlOOHDPihM3Uqjdj12K1IDruNWN6WLUhI7GHHIpW2Jb4cYfGVGPkz/Fm g/nBMgjcg2xyCAgC1frXsj63YziFzEqsL8d/LZ9eVvMJFC43KDbTSKfhkKMK2bzQLFy3 P6Tg== 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=xavI/gAisc47AB04Lxd4coGNq76/GR9N74Rm+AMG6uI=; b=VncZu4kWZHiobUMzJy/tpEWudAWJ0NuEu6JRwG8iHCjpIeD+1glnIwIfRCePRWbHZw aWO8BFkxF/Nkz2/KPKPdZHaJnjwisaShrJ1/sp8q/nHYBzUd25BBV7KgBvDDk+Dq1Sj9 /ULZZrI9EmU8mdjLKCtCAUeoZnFgcoAwjQqjcDZCnBtKaorN4ybE5eHJbwAdgMdea5TB NKv350P0HyUSrl8zzPvN2ziXd2tPqIHlnENCO0DsoBleygEx3HZvB8ZgylEE6zI7QYwe wWXQP9Xz6+3unz+Be1Ns5ev6vtYA59PHhexoyCHkxhXcB8K1drxqCQXIhP1511BG1DsR UZdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=kV8Y0Jw3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f3-20020a5d50c3000000b0020aa7e6c2d4si3219942wrt.471.2022.05.13.17.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 17:39:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=kV8Y0Jw3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CE9CB34EEB4; Fri, 13 May 2022 16:30:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231383AbiEMNiB (ORCPT + 99 others); Fri, 13 May 2022 09:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381352AbiEMNfd (ORCPT ); Fri, 13 May 2022 09:35:33 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D92C615F for ; Fri, 13 May 2022 06:35:30 -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 ABD222224D; Fri, 13 May 2022 15:35:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1652448928; 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=xavI/gAisc47AB04Lxd4coGNq76/GR9N74Rm+AMG6uI=; b=kV8Y0Jw3EDQL4i0NJHEfAhJ6F0g6bKhBayKgmBQbhkRYWqUV4GlnZm/c8aLAPLdcgiqASR jB9UiWS2jzfGWRVwAQbsciLbjfFAWZDf3zNygvuEogdP7bBYgQR2ZGhJwDOvhfRGQjEWQn Bxjdq579wN/jjTOL8dfZlo92oVv+MAg= From: Michael Walle To: Tudor Ambarus , Pratyush Yadav , Michael Walle , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH 3/6] mtd: spi-nor: remember full JEDEC flash ID Date: Fri, 13 May 2022 15:35:17 +0200 Message-Id: <20220513133520.3945820-4-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220513133520.3945820-1-michael@walle.cc> References: <20220513133520.3945820-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 At the moment, we print the JEDEC ID that is stored in our database. The generic flash support won't have such an entry in our database. To find out the JEDEC ID later we will have to cache it. There is also another advantage: If the flash is found in the database, the ID could be truncated because the ID of the entry is used which can be shorter. Some flashes still holds valuable information in the bytes after the JEDEC ID and come in handy during debugging of when coping with INFO6() entries. These are not accessible for now. Save a copy of the ID bytes after reading and display it via debugfs. Signed-off-by: Michael Walle --- drivers/mtd/spi-nor/core.c | 5 +++++ drivers/mtd/spi-nor/debugfs.c | 2 +- include/linux/mtd/spi-nor.h | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index ce5d69317d46..65cd8e668579 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1664,6 +1664,11 @@ static const struct flash_info *spi_nor_detect(struct spi_nor *nor) return ERR_PTR(ret); } + /* Cache the complete flash ID. */ + nor->id = devm_kmemdup(nor->dev, id, SPI_NOR_MAX_ID_LEN, GFP_KERNEL); + if (!nor->id) + return ERR_PTR(-ENOMEM); + info = spi_nor_match_id(nor, id); if (!info) { dev_err(nor->dev, "unrecognized JEDEC id bytes: %*ph\n", diff --git a/drivers/mtd/spi-nor/debugfs.c b/drivers/mtd/spi-nor/debugfs.c index eaf84f7a0676..23d51e7ba0a7 100644 --- a/drivers/mtd/spi-nor/debugfs.c +++ b/drivers/mtd/spi-nor/debugfs.c @@ -81,7 +81,7 @@ static int spi_nor_params_show(struct seq_file *s, void *data) int i; seq_printf(s, "name\t\t%s\n", info->name); - seq_printf(s, "id\t\t%*ph\n", info->id_len, info->id); + seq_printf(s, "id\t\t%*ph\n", SPI_NOR_MAX_ID_LEN, nor->id); string_get_size(params->size, 1, STRING_UNITS_2, buf, sizeof(buf)); seq_printf(s, "size\t\t%s\n", buf); seq_printf(s, "write size\t%u\n", params->writesize); diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 1ede4c89805a..4dd6cd7389ca 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -349,6 +349,8 @@ struct spi_nor_flash_parameter; * @bouncebuf: bounce buffer used when the buffer passed by the MTD * layer is not DMA-able * @bouncebuf_size: size of the bounce buffer + * @id: The flash's ID bytes. Always contains + * SPI_NOR_MAX_ID_LEN bytes. * @info: SPI NOR part JEDEC MFR ID and other info * @manufacturer: SPI NOR manufacturer * @addr_width: number of address bytes @@ -379,6 +381,7 @@ struct spi_nor { struct spi_mem *spimem; u8 *bouncebuf; size_t bouncebuf_size; + u8 *id; const struct flash_info *info; const struct spi_nor_manufacturer *manufacturer; u8 addr_width; -- 2.30.2