From patchwork Sun Jun 30 16:07:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhuohao Lee X-Patchwork-Id: 1124936 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 (mailfrom) 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; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SKey8tCK"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="c072iIno"; 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 45cFlP22LTz9sBp for ; Mon, 1 Jul 2019 02:07:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=dzX/GOK+p688PComehTba9OjfZPaKWuR/WkX+UXLfCw=; b=SKey8tCKHT1bKb WZ425SLeJhHGXQBBFGm5/iwRTjV1336HfMg+YD5p+4NmL4sGlf2fa71h+Ryqexv0Brds2WNM1v17v h751Zfk2XwroIoNg3tRm+7v6oeh4+vlp5xsg2UUGsQnJGHjZGP5xl8vCbg+RLFjsOyZWv2kuyc3cz 25IAiPVdhGjraeXTu40zqNEbneuF3EGSgSbI8Thck/rYl2HNHOSb8wC7RuahRF7bG1IUXmZM15ZRk c8CKgnJjJEPaolO0h1cC8Gb4VgXJ4X4idYPN6RE1yDVsffj1il9onsvoZWx26LwRK/m/aG/msLkxy c5Th0MXJI1hPj48RGOnA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hhcMM-0001Ac-BX; Sun, 30 Jun 2019 16:07:22 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hhcMI-0001AA-A6 for linux-mtd@lists.infradead.org; Sun, 30 Jun 2019 16:07:20 +0000 Received: by mail-pf1-x442.google.com with SMTP id 19so5324654pfa.4 for ; Sun, 30 Jun 2019 09:07:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6ofePWR9y57IHRX0wCnEWK2SIeAHDmpL2Xkdc5wlS1E=; b=c072iIno999FOTq3fiElGVKS9YvkEegTbi91lAZ5j6zzQ9FymrcQAkINdEsssRDwuJ AxxEz4hzsT9vIo6RewHN9lxgECxPwjYr3BPpy6sBPqimQ3szkz56B6jR6JBXSqP6n8Q1 7YLi2kRf2e6L5nVBPV5PvnVut7PYKY/3V/v9Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6ofePWR9y57IHRX0wCnEWK2SIeAHDmpL2Xkdc5wlS1E=; b=U8Ky4bCz+8Yso10LsQQSXc+a1wnK1U8DLKOkfUKIUCVHl8qn/84j/FcjBYkVUNM6B7 Y25CtpC09ix5qzU+sBi1BeB/rCPqbAz3R1eb0T6nSDGfKOtPTfx5UiI4dWwd+8XQ3uqe eikWSSQb7J2WXKqfpcrw9VHd6RKkF6PJ1akIOYZbHwc6IIftdJc7GQEANjlz+Nrol2a8 X/sd7UoJnsVZAwzCZIFs0IvZtllZ5bYN4QM3TUzq4Z6IzorJDzxnNOr+jf5gwffOPmV0 yP23iXgTRBViPrZRGovJ8gFfEhHor7a/zqt149gXksUXHgBKZCBlj4jDE7JORObYkbnE leMg== X-Gm-Message-State: APjAAAVpkPgwJPmFxiUGH1drvfAWc4kNZVoTsRAaYnkNS0nbA0fB28lr guo7VgXZTcu7nTPQQlqeTccHPgWBkRI= X-Google-Smtp-Source: APXvYqxP75foJBKrbS0cudDUEC8qX59bvg5Sv9o5BS/+qn3pALBdTibvs/5+DcWS3UUZcUaDBjUojA== X-Received: by 2002:a63:c106:: with SMTP id w6mr19958166pgf.422.1561910836705; Sun, 30 Jun 2019 09:07:16 -0700 (PDT) Received: from zhuohao-z440.tpe.corp.google.com ([2401:fa00:1:10:e25c:13cd:9607:cc7f]) by smtp.gmail.com with ESMTPSA id y10sm8990409pfm.66.2019.06.30.09.07.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 30 Jun 2019 09:07:16 -0700 (PDT) From: Zhuohao Lee To: linux-mtd@lists.infradead.org Subject: [PATCH v8 1/2] mtd: mtdcore: add debugfs nodes for querying the flash name and id Date: Mon, 1 Jul 2019 00:07:10 +0800 Message-Id: <20190630160711.178679-1-zhuohao@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190630_090718_384310_9AD80573 X-CRM114-Status: GOOD ( 16.41 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drinkcat@chromium.org, zhuohao@chromium.org, bbrezillon@kernel.org, richard@nod.at, briannorris@chromium.org, marek.vasut@gmail.com, boris.brezillon@collabora.com, computersforpeace@gmail.com, dwmw2@infradead.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently, we don't have vfs nodes for querying the underlying flash name and flash id. This information is important especially when we want to know the flash detail of the defective system. In order to support the query, we add mtd_debugfs_populate() to create two debugfs nodes (ie. partname and partid). The upper driver can assign the pointer to partname and partid before calling mtd_device_register(). Signed-off-by: Zhuohao Lee Reviewed-by: Boris Brezillon --- Changes in V8: - Change pr_debug/pr_err to dev_dbg/dev_err respectively - Previous discussion: https://patchwork.ozlabs.org/patch/1109227/ Changes in V7: - Remove unused check for partname/partid - Previous discussion: https://patchwork.ozlabs.org/patch/1109200/ Changes in V6: - Create the debugfs only when the partname/partid is not NULL - Previous discussion: https://patchwork.ozlabs.org/patch/1109041/ Changes in V5: - Move debugfs_create_dir() to mtd_debugfs_populate() - Previous discussion: https://patchwork.ozlabs.org/patch/1107810/ Changes in V4: - Separate the change to two patches. The first patch is adding the general handling for the partname and partid in the mtdcore.c. The second patch is enabling the two debugfs nodes for spi-nor. - Previous discussion: https://patchwork.ozlabs.org/patch/1097377/ Changes in v3: - Add partname and partid to mtd.h and create debugfs inside mtdcore.c - Previous discussion: https://patchwork.ozlabs.org/patch/1095731/ Changes in v2: - Change to use debugfs to output flash name and id - Previous discussion: https://patchwork.ozlabs.org/patch/1067763/ --- drivers/mtd/mtdcore.c | 85 ++++++++++++++++++++++++++++++++++++----- include/linux/mtd/mtd.h | 3 ++ 2 files changed, 79 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 3ef01baef9b6..1ecc27340379 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -357,6 +357,81 @@ static const struct device_type mtd_devtype = { .release = mtd_release, }; +static int mtd_partid_show(struct seq_file *s, void *p) +{ + struct mtd_info *mtd = s->private; + + seq_printf(s, "%s\n", mtd->dbg.partid); + + return 0; +} + +static int mtd_partid_debugfs_open(struct inode *inode, struct file *file) +{ + return single_open(file, mtd_partid_show, inode->i_private); +} + +static const struct file_operations mtd_partid_debug_fops = { + .open = mtd_partid_debugfs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int mtd_partname_show(struct seq_file *s, void *p) +{ + struct mtd_info *mtd = s->private; + + seq_printf(s, "%s\n", mtd->dbg.partname); + + return 0; +} + +static int mtd_partname_debugfs_open(struct inode *inode, struct file *file) +{ + return single_open(file, mtd_partname_show, inode->i_private); +} + +static const struct file_operations mtd_partname_debug_fops = { + .open = mtd_partname_debugfs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static struct dentry *dfs_dir_mtd; + +static void mtd_debugfs_populate(struct mtd_info *mtd) +{ + struct device *dev = &mtd->dev; + struct dentry *root, *dent; + + if (IS_ERR_OR_NULL(dfs_dir_mtd)) + return; + + root = mtd->dbg.dfs_dir = debugfs_create_dir(dev_name(dev), + dfs_dir_mtd); + if (IS_ERR_OR_NULL(root)) { + dev_dbg(dev, "won't show data in debugfs\n"); + return; + } + + if (mtd->dbg.partid) { + dent = debugfs_create_file("partid", S_IRUSR, root, mtd, + &mtd_partid_debug_fops); + if (IS_ERR_OR_NULL(dent)) + dev_err(dev, + "can't create debugfs entry for partid\n"); + } + if (mtd->dbg.partname) { + dent = debugfs_create_file("partname", S_IRUSR, root, mtd, + &mtd_partname_debug_fops); + if (IS_ERR_OR_NULL(dent)) + dev_err(dev, + "can't create debugfs entry for partname\n"); + } +} + #ifndef CONFIG_MMU unsigned mtd_mmap_capabilities(struct mtd_info *mtd) { @@ -534,8 +609,6 @@ static int mtd_nvmem_add(struct mtd_info *mtd) return 0; } -static struct dentry *dfs_dir_mtd; - /** * add_mtd_device - register an MTD device * @mtd: pointer to new MTD device info structure @@ -621,13 +694,7 @@ int add_mtd_device(struct mtd_info *mtd) if (error) goto fail_nvmem_add; - if (!IS_ERR_OR_NULL(dfs_dir_mtd)) { - mtd->dbg.dfs_dir = debugfs_create_dir(dev_name(&mtd->dev), dfs_dir_mtd); - if (IS_ERR_OR_NULL(mtd->dbg.dfs_dir)) { - pr_debug("mtd device %s won't show data in debugfs\n", - dev_name(&mtd->dev)); - } - } + mtd_debugfs_populate(mtd); device_create(&mtd_class, mtd->dev.parent, MTD_DEVT(i) + 1, NULL, "mtd%dro", i); diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 677768b21a1d..b11afb85d962 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -203,6 +203,9 @@ struct module; /* only needed for owner field in mtd_info */ */ struct mtd_debug_info { struct dentry *dfs_dir; + + const char *partname; + const char *partid; }; struct mtd_info { From patchwork Sun Jun 30 16:07:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhuohao Lee X-Patchwork-Id: 1124937 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 (mailfrom) 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; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FZdMhiN/"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="WWhjAcJe"; 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 45cFlR2BRBz9sCJ for ; Mon, 1 Jul 2019 02:07:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IBpFvmRXYNwkTWbiQGwtGJFF6Kw4pRXw2wazfqO6bvo=; b=FZdMhiN/tzRw9w 9M/V9vDO7B3rBbfDgpVSYioA26l1UAYv9x0O4TGyc5ThuMI5rQvvNIPK5aCl30n05V9jEK+oKfOFv 0beZeFvgGvwjMuSYBpAtV3OPRujqGcR5wdBnLtRNILs8f/fHNP5JgX0MFNnwkRkfTjZnpoqpvObtK 7EfFM6OBKz6ghsw8EDbpvBJKrl09+cgNGYeeWip8SBlLUQkmgbZcV2PPio9ypU2sQL3a3euw9Eoh9 ZXmHN4e0V+D394tKF+1HQ4IIbRX6VKyNSiNpYifxAFf+jsopXqYJKf8mkymEJsLRPzdOIfcvULXhl El/tJ+viVOX/5O4AzHeQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hhcMj-0001P5-35; Sun, 30 Jun 2019 16:07:45 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hhcMM-0001Ab-09 for linux-mtd@lists.infradead.org; Sun, 30 Jun 2019 16:07:23 +0000 Received: by mail-pf1-x444.google.com with SMTP id p184so5310545pfp.7 for ; Sun, 30 Jun 2019 09:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GvtWRTZzYJCoh3kBu10Gbyh1vhhZa3AxKvxk95ea2Z8=; b=WWhjAcJe2exCcDC6/A/ofBRAAQS03XsOA5dhtT7s9O4EH/XJBmY6aNPWOAF6TsL9Mw EeuMoDI9EB2e9dJKivXd6FLAGpoWjVI6vYlBut0aIZkmpAZMT4hwvBMQ+43DplODPFf2 cOzeN+PB5fUaEhoEf9uvmHKQbwZ/WLxAEBMNg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GvtWRTZzYJCoh3kBu10Gbyh1vhhZa3AxKvxk95ea2Z8=; b=XVcwfiXbRlhK6jDojNMXi17k9qLSKU7pSxnn0zFIxFk6ojPwRdpGExbplLWr66XUur pZKMd3kp8qYeN/mVlEe25g5QfTsyolK3uvs0jQNdNEs+DBYtAx4XMFHTVN8Fzt4Dx/0d EgukVM4touOxP/vzysMVk3NaQDQRhIg0s5bzxfNGsII0a03FfbH/btFMwSOZTbTOrIjp M0Hy1Rrb2SzZcRgjtceGv5pEoNWYgOwvLAQzbyBHDTOmK0rpzekaIu28L0FQ7po7ey/U P0lVN8HX4XwfI540DuAJoQlHOyrZrCI4kHPKk41VM+48rGfS3RIsIxaoCOd12bJAFviv htiA== X-Gm-Message-State: APjAAAVrZs9vXNQyZqgR5IEtK69Ghrk7TgUR07axVRW3I3LnD695n1DZ mlDgs3BW/qiX7GMQQ3i5oKZvSuNxfso= X-Google-Smtp-Source: APXvYqw+0/5GONQTfUqDDIBJixcHnbmFyMF3q7QDqs/k+Ulw88JmZdNHIPX/45b9dsay2tC5UUKqMw== X-Received: by 2002:a17:90a:db52:: with SMTP id u18mr25860508pjx.107.1561910841020; Sun, 30 Jun 2019 09:07:21 -0700 (PDT) Received: from zhuohao-z440.tpe.corp.google.com ([2401:fa00:1:10:e25c:13cd:9607:cc7f]) by smtp.gmail.com with ESMTPSA id y10sm8990409pfm.66.2019.06.30.09.07.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 30 Jun 2019 09:07:20 -0700 (PDT) From: Zhuohao Lee To: linux-mtd@lists.infradead.org Subject: [PATCH v8 2/2] mtd: spi-nor: enable the debugfs for the partname and partid Date: Mon, 1 Jul 2019 00:07:11 +0800 Message-Id: <20190630160711.178679-2-zhuohao@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190630160711.178679-1-zhuohao@chromium.org> References: <20190630160711.178679-1-zhuohao@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190630_090722_119540_D91D6A53 X-CRM114-Status: GOOD ( 10.23 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:444 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drinkcat@chromium.org, zhuohao@chromium.org, bbrezillon@kernel.org, richard@nod.at, briannorris@chromium.org, marek.vasut@gmail.com, boris.brezillon@collabora.com, computersforpeace@gmail.com, dwmw2@infradead.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch adds spi_nor_debugfs_init() for the debugfs initialization. With this patch, we can read the partname and partid through the debugfs. The output of new debugfs nodes on my device are: cat /sys/kernel/debug/mtd/mtd0/partid spi-nor:ef6017 cat /sys/kernel/debug/mtd/mtd0/partname w25q64dw Signed-off-by: Zhuohao Lee Reviewed-by: Boris Brezillon --- drivers/mtd/spi-nor/spi-nor.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 6e13bbd1aaa5..52b1a2da9ac0 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -3935,6 +3935,17 @@ static void spi_nor_resume(struct mtd_info *mtd) dev_err(dev, "resume() failed\n"); } +static void spi_nor_debugfs_init(struct spi_nor *nor, + const struct flash_info *info) +{ + struct mtd_info *mtd = &nor->mtd; + + mtd->dbg.partname = info->name; + mtd->dbg.partid = devm_kasprintf(nor->dev, GFP_KERNEL, + "spi-nor:%*phN", + info->id_len, info->id); +} + void spi_nor_restore(struct spi_nor *nor) { /* restore the addressing mode */ @@ -4036,6 +4047,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, mtd->_read = spi_nor_read; mtd->_resume = spi_nor_resume; + spi_nor_debugfs_init(nor, info); + /* NOR protection support for STmicro/Micron chips and similar */ if (JEDEC_MFR(info) == SNOR_MFR_ST || JEDEC_MFR(info) == SNOR_MFR_MICRON ||