From patchwork Tue Jul 27 04:51:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 1510280 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=MymL5OjU; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=Vc+gSu8R; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GYkyR7181z9sWl for ; Tue, 27 Jul 2021 14:55:59 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=C2fvnBDAx4r5cD/GGhmyByHPofaTB6xdOKT9bN7TmaQ=; b=MymL5OjUYMPl5m zWg2D7TA8JvlrJFjCF08E9lMB82lV9hrGMQ8UtaSd7PYdrSYuGTYMHpkz05B2Y8lPtEubvuXk3iqU E+8inUqHODVAB3x1k0Lf6Nj8AGs2thBzORH7j6GhFQ6mDCoBlMWL//Fi35q1mYUx1sHc44TZl/z4z HwEPj2RORAM2/sbjD3VQfimBL1zGQFbrxOlALhkpEdsZnYYGsVcKi67Sv7/TEKCi+bHR9L+XsrBht AXE29e5ZJCbEieMFKL+mOqH0H4a4vhvk6PM8B17VgjALrIiN2md28XX0xilvDUe4vjiow94h0k/+f 55r26wBFed0JJKJq632g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8F7f-00DI6w-5D; Tue, 27 Jul 2021 04:55:19 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8F58-00DHPH-En; Tue, 27 Jul 2021 04:52:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1627361562; x=1658897562; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6roB3jv3+3BTf7v5TlRyzhlr+56Le9mHFNgqovKmH/c=; b=Vc+gSu8Rf9M14orQOlCq8X87PfjZ4ja4dBOVVhWXi67VjHMLnzVTt17A 4mUVgqoE5n6Iu1dIWyomVIiE0h6/6boMGADYEatXjWY4gBDe9nBa90A2o KUW7OI0yrUsTxx29pLuWEjT0kCCZ/x8uQiuc2K+rhC8xn86AUOIHwuiSS 8uaLEH/MSIO1faEae3viBUClURn4yE3tqn3hqwZ2hFVK1zXbeRjkxdeFH qX74b52Ef5L5FIby+WODwC5jxhERWM6AQJhXsh1zP+LfLovGUYvyRkIsT ylBmNCbCR4W2m/EAZolZRdHAUMG9/jMxnF6x3uGulYqg0psmpod1ibNg6 A==; IronPort-SDR: BkXF85cxN9O0jv/0vaHEiJW78HkHjyfvEcTt0rHF55X7eZWykQ6bd3tNa+RVY63lozh0L3XkcB IsX07uekgCQzYuNYofZwXWK+d/9NezoGwaf4b1vgpxwkcVyDRX4ZABNz7S/R0Gb0QRfT//v3gm mI+w2wdWh1npBDANJHYehSa+83JanmR7AYUc1TQ9thj6CGbYLhqAetu7hOD9D8XLFOXIHY3cjw Ksxt/Qy+jAZViTodbqHp1SL4UWlhvxfN2ydhREW1oZHvxEd4AnTgBlz0B/qMJ5CFZ0RgAU2j+F BRgA1lheJMznzb7lO0pQjepq X-IronPort-AV: E=Sophos;i="5.84,272,1620716400"; d="scan'208";a="129935408" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 26 Jul 2021 21:52:41 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 26 Jul 2021 21:52:40 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Mon, 26 Jul 2021 21:52:35 -0700 From: Tudor Ambarus To: , , CC: , , , , , , , , , , , , , , , , "Tudor Ambarus" Subject: [PATCH v2 02/35] mtd: spi-nor: core: Report correct name in case of ID collisions Date: Tue, 27 Jul 2021 07:51:49 +0300 Message-ID: <20210727045222.905056-3-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210727045222.905056-1-tudor.ambarus@microchip.com> References: <20210727045222.905056-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210726_215242_582423_2A0076B9 X-CRM114-Status: GOOD ( 14.32 ) X-Spam-Score: -2.7 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Provide a way to report the correct flash name in case of ID collisions. There will be a single flash_info entry when flash IDs collide, and the differentiation between the flash types will be made at [...] Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [68.232.153.233 listed in wl.mailspike.net] -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.153.233 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Provide a way to report the correct flash name in case of ID collisions. There will be a single flash_info entry when flash IDs collide, and the differentiation between the flash types will be made at runtime if possible. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/core.c | 7 +++++-- drivers/mtd/spi-nor/sysfs.c | 2 +- include/linux/mtd/spi-nor.h | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 3d9f3698fb7b..1a278d33b02d 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -3027,7 +3027,7 @@ static void spi_nor_debugfs_init(struct spi_nor *nor, { struct mtd_info *mtd = &nor->mtd; - mtd->dbg.partname = info->name; + mtd->dbg.partname = nor->name; mtd->dbg.partid = devm_kasprintf(nor->dev, GFP_KERNEL, "spi-nor:%*phN", info->id_len, info->id); } @@ -3208,7 +3208,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, /* Configure OTP parameters and ops */ spi_nor_otp_init(nor); - dev_info(dev, "%s (%lld Kbytes)\n", info->name, + if (!nor->name) + nor->name = info->name; + + dev_info(dev, "%s (%lld Kbytes)\n", nor->name, (long long)mtd->size >> 10); dev_dbg(dev, diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c index 9aec9d8a98ad..017119768f32 100644 --- a/drivers/mtd/spi-nor/sysfs.c +++ b/drivers/mtd/spi-nor/sysfs.c @@ -25,7 +25,7 @@ static ssize_t partname_show(struct device *dev, struct spi_mem *spimem = spi_get_drvdata(spi); struct spi_nor *nor = spi_mem_get_drvdata(spimem); - return sysfs_emit(buf, "%s\n", nor->info->name); + return sysfs_emit(buf, "%s\n", nor->name); } static DEVICE_ATTR_RO(partname); diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index f67457748ed8..bd92acdd1899 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -369,6 +369,7 @@ 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 + * @name: used to point to correct name in case of ID collisions. * @info: SPI NOR part JEDEC MFR ID and other info * @manufacturer: SPI NOR manufacturer * @page_size: the page size of the SPI NOR @@ -399,6 +400,7 @@ struct spi_nor { struct spi_mem *spimem; u8 *bouncebuf; size_t bouncebuf_size; + const char *name; const struct flash_info *info; const struct spi_nor_manufacturer *manufacturer; u32 page_size;