From patchwork Wed Oct 4 22:04:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 1843656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=Q9MpCzyM; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=I4Gy56FN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S17zc62PYz1yq7 for ; Thu, 5 Oct 2023 09:05:30 +1100 (AEDT) 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: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:In-Reply-To:References: List-Owner; bh=FHR5H2LYt+rKEkuidhzDC+5lOELkgUZRamOJDgETg5I=; b=Q9MpCzyM0orSPY e1+66Ti59v+y9FguslYAzpJr9qditbIw4GQtxU6BDNJIl/aG9hnrdG4Udyy+EYcmnSAi+Alq1TQTa PTbAVpfuvVJk9YKPy/W3ZDQfD7hrUIKipZN8x6OujfrrEE5Xolp4TUJN67QL90xEEZQSuJYBmYqjw hbndzYsSodUZTscMu1vSfQNG5Gi+cqcCRG+UoJ2H76lFIObMjZGYoNeQP6WMCiT2TjtzFfDSdyvMu cP1GcGzm/9NwJJyQUFMqpje8MtO8mO2IjjPfBKMSgQRZXuaQMRjBpF0WT16Crp0SSFQrH9NcaarTw dl7KDAjAW8DtEC3QH7Tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qo9z6-000y4m-1e; Wed, 04 Oct 2023 22:04:48 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qo9z3-000y3d-1s for linux-mtd@lists.infradead.org; Wed, 04 Oct 2023 22:04:47 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 54369E0006; Wed, 4 Oct 2023 22:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696457081; 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; bh=9ONukwliW8afod/uqqOCJF3W294VpFny5l+bXSFF2Ac=; b=I4Gy56FNjUtiehwUUxOkR9l/FMBhS8k6o4d9n7dSkDqVwog+3VDuwO3uSESc43p9xnYvrg t8bvG98qGnDVSWjSokJ9JQtEhdIT/r9L7VunsuuRGBDViYJhV0mTXvhOZs0JFe6Al38Zk2 k6mBuVf4Ehs36GBfWZQXX6dSAFbaIFmS54aMD1Spl5uyFX+fN/Cmjlnwm+FCbvvPcmjo/J MtHfaH2aTO8BnDXUuPUZuVwpl7qpv4Z+fBLsXn6EkIULvauToema0jT4K/PL5NFUa2L3f1 39rXnIQSFGvfHzhfmugBIpkBwc4rN8GHTbBCyc875+IE/4pJIK5tOTmuTpK4cw== From: Miquel Raynal To: Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus , Pratyush Yadav , Michael Walle , Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Srinivas Kandagatla , Thomas Petazzoni , Robert Marko , Luka Perkov , Miquel Raynal Subject: [PATCH] mtd: Ensure NVMEM layouts get their of_node Date: Thu, 5 Oct 2023 00:04:37 +0200 Message-Id: <20231004220437.405959-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231004_150445_914464_E92F8012 X-CRM114-Status: GOOD ( 10.94 ) X-Spam-Score: -0.9 (/) 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: All the nvmem-layouts logic expects an of_node to be available. When mtd started registering nvmem devices, the exact exposure was not yet decided and thus the no_of_node field was set to 1 to avoid e [...] Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [2001:4b98:dc4:8:0:0:0:224 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 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 All the nvmem-layouts logic expects an of_node to be available. When mtd started registering nvmem devices, the exact exposure was not yet decided and thus the no_of_node field was set to 1 to avoid exposing "too much". This has been lowered since we want children nodes of mtd devices with the "nvmem-cells" compatible to be actually registered in NVMEM. This is now also the case of the nvmem-layout containers. Signed-off-by: Miquel Raynal --- drivers/mtd/mtdcore.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 061745acb9a7..60b670c42be5 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -543,6 +543,13 @@ static int mtd_nvmem_reg_read(void *priv, unsigned int offset, return retlen == bytes ? 0 : -EIO; } +static bool mtd_contains_nvmem_layout(struct mtd_info *mtd) +{ + /* of_find_node_by_name() calls of_node_put() on the starting node */ + of_node_get(mtd->dev.of_node); + return of_find_node_by_name(mtd->dev.of_node, "nvmem-layout"); +} + static int mtd_nvmem_add(struct mtd_info *mtd) { struct device_node *node = mtd_get_of_node(mtd); @@ -559,7 +566,8 @@ static int mtd_nvmem_add(struct mtd_info *mtd) config.read_only = true; config.root_only = true; config.ignore_wp = true; - config.no_of_node = !of_device_is_compatible(node, "nvmem-cells"); + config.no_of_node = !of_device_is_compatible(node, "nvmem-cells") || + !mtd_contains_nvmem_layout(mtd); config.priv = mtd; mtd->nvmem = nvmem_register(&config);