From patchwork Tue Oct 4 08:37:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 612214 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp26671pvb; Tue, 4 Oct 2022 01:38:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5MGEd0Bef21iN7502WT4J0vyz5Dl1mQBvYsBV4KHv1pVD9L2F/amfMK+JZSri52dRS+j42 X-Received: by 2002:a63:2b53:0:b0:439:34d9:5d47 with SMTP id r80-20020a632b53000000b0043934d95d47mr21832473pgr.283.1664872693020; Tue, 04 Oct 2022 01:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664872693; cv=none; d=google.com; s=arc-20160816; b=vRmyoko3Gdc5DWntPCwA3avYWHFUFxn4w/ktpVGYLXTYRjCDjqmyx9fuSmhRYOVDNW 9cJz24i14yqGNli0ePYiq05nTMzId/YfUjuuCwdp/6tPpFn9MYEpxH/G12Z4ICb30o7Y 1NiVxvTIlT21yP8o0ZeE2MVmHc7llMTqpSfaFwGYSV/9B7luGyehpNfn5f0yVVyayImU nqS5r47FKV9Jmk5HIYZxlr4lrR12C/W6OVX4Th3iXZQte3fxJD+k2nD+S/4xQibKubbA McOM/vm4e+l2pVr72AvWomABhmqC/47IQHQ9kRVHKdrzhX//8Q4mOhShUbtZI0JRYgpf /hPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=5HBnlrBWfIPwl77JxMUc8t1lT9kYlmY7a10ar487jHE=; b=0CP6WOyiYRe4+YSMTSH75nuSwTFAFyfA+EEUpTXo/VJcrNBkKCBSYas7DW/boRdjI0 s9g7MYB9tG6v14wDMj9a6plcTDBjsJPVnHWInHdijiC60mYe32AJws8JlFSCZlGneVAx nQSw52iKZ9BOBiPmGXbo1w5roTt4kq1gzKW3UdhFGJlo+923+BxDQzIyTPKIO083UPdu WJNVjaat+2/AVYOPqfXjmi5KCBNiR3GnptPQdqsjRtrgOCGdZ0+MdBaARpUvXvCYjyCC +AKl2XTslaucB9HGUIZa9SQE77Qtda1LuMgm7+gY1EqlsU7ENcI436COjP/I4o43+dTy zBkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=Qplb01tA; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Jj8QhHRV; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:3::133]) by mx.google.com with ESMTPS id y9-20020a056a00190900b0055ad053d6f6si14030625pfi.71.2022.10.04.01.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 01:38:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) client-ip=2607:7c80:54:3::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=Qplb01tA; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Jj8QhHRV; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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=5HBnlrBWfIPwl77JxMUc8t1lT9kYlmY7a10ar487jHE=; b=Qplb01tAtp32aD zfvdcqJaLEwfvfp6fTiOtKHVnJr3hWSTEXHKQgJYlNrPrEVEZ8hSYol4TTDk5js0HAEPwopTyzCSy H+bi65zNOAftsa92Txnel1MmwQ8p5WNw27Pps3zD6fbsd+8o6vH0d0xrNdYA8SKKrqyXgENf3LThL ZxQGf9+sylHkDO2LerbFgqtdp6sMF+ob7QUojiYNLKPx82QAe0xC1dtbRcTy1hO7AU7Sezq0vI1xm +5Dh7BAD8m9pXw0aDrlIcoIJ+ElSYYSCvSpUfIwy77Ccj3MEW/umzueAJH06TxTzXw79MISgs2KBP zk7Q7GLkWAZ8dCiDYh2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofdQd-008yRm-IC; Tue, 04 Oct 2022 08:37:28 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofdQa-008yPq-5Z for linux-mtd@lists.infradead.org; Tue, 04 Oct 2022 08:37:25 +0000 Received: by mail-ej1-x62e.google.com with SMTP id qx23so9215600ejb.11 for ; Tue, 04 Oct 2022 01:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6398PXCM0Z75TAhOXIJvZ7VMvOm+wU8M/apzJQ0fPNo=; b=Jj8QhHRVv8XhN9gn3Zy3845Ep6P4N74frrh8J0sNy9Nvw6cZWznxO4pAfFKytDI/eI hxT50YyaGei0d7lEZGu5Tjq1q5j2QqMGVH46bdZAvFqoWOFZi+iNpiQaLIrDiTskySPy NAjOl+xcOvnGKdpu4PyMmTpGjV8VaFqhFpkZjKSdXnx/N6FNXcc/no5e9ku9J5Bcj8Xp ICAFBJ5HnF1XGxuI0aSIZpzIRWtNNDXVd+cdct8UjrTwEZIqswMZMRar4T99qJLnjY68 IK8QbPlcw+DznnZ27auF6JEbvLSc73GnTbAu2YYvw0ZhOoJmx3orZmn6Bx8yKNJ27c1w xR/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=6398PXCM0Z75TAhOXIJvZ7VMvOm+wU8M/apzJQ0fPNo=; b=q3m9wYI2eWdsl36HsQcmITzD30pHaw6423FXGuFNG2Cz23F1uLJ6ksUVECJqpkMs6F +zfxvmK8FCvEYUf3P/Un+uMn4J1zsFHuZkYqOYGUAc90a3TzlQIjFRIbjrQOJZhEAIWR SBhzKxGDLCns7cwcF9RgtLkzIGB4fF0RHI7zkqFXFbNUyn7ZKEjvwcUhQOS0mG3/U0XP phD/qcRBo86hHgdr8+ixnL0STe/hk2QmTlpnLA9Fmo8Q+aYpUY04WliC5CBMXXUceJ9K //QcESFxT7aNyWVmalfBWoPQH7VnhTZ45mTiWnfqApCD6u01N5UEtrzmMg3fqouIN1Mi 2fWw== X-Gm-Message-State: ACrzQf1h2UIGWxB7svoyH3br6+Lw4O+udspAwMN/5hILf/p0w1BYq7yl cjSAvQZ/BnT0S5QKb4z5yuBmgSTfqY0= X-Received: by 2002:a17:906:5d16:b0:783:78d5:e47a with SMTP id g22-20020a1709065d1600b0078378d5e47amr18495748ejt.453.1664872640525; Tue, 04 Oct 2022 01:37:20 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id kv20-20020a17090778d400b00787a6adabe9sm6598376ejc.75.2022.10.04.01.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 01:37:20 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: ansuelsmth@gmail.com, linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFm?= =?utf-8?b?YcWCIE1pxYJlY2tp?= Subject: [PATCH V2 2/2] mtd: core: try to find OF node for every MTD partition Date: Tue, 4 Oct 2022 10:37:10 +0200 Message-Id: <20221004083710.27704-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221004083710.27704-1-zajec5@gmail.com> References: <20221004083710.27704-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221004_013724_233083_2CD1B308 X-CRM114-Status: GOOD ( 15.62 ) X-Spam-Score: 0.1 (/) X-Spam-Report: =?utf-8?q?Spam_detection_software=2C_running_on_the_system_?= =?utf-8?q?=22bombadil=2Einfradead=2Eorg=22=2C?= =?utf-8?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_original?= =?utf-8?q?_message_has_been_attached_to_this_so_you_can_view_it_or_label?= =?utf-8?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?utf-8?q?_the_administrator_of_that_system_for_details=2E?= =?utf-8?q?_?= =?utf-8?q?_Content_preview=3A__From=3A_Rafa=C3=85=C2=82_Mi=C3=85=C2=82ecki_S?= =?utf-8?q?o_far_this_feature_was_limited_to_the?= =?utf-8?q?_top-level_=22nvmem-cells=22_node=2E_There_are_multiple_parsers_cr?= =?utf-8?q?eating_partitions?= =?utf-8?q?_and_subpartitions_dynamically=2E_Extend_that_code_to_handle_them_?= =?utf-8?q?too=2E_?= =?utf-8?q?_?= =?utf-8?q?_Content_analysis_details=3A___=280=2E1_points=2C_5=2E0_required?= =?utf-8?q?=29?= =?utf-8?q?_?= =?utf-8?q?_pts_rule_name______________description?= =?utf-8?q?_----_----------------------_-------------------------------------?= =?utf-8?q?-------------?= =?utf-8?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_at_https?= =?utf-8?q?=3A//www=2Ednswl=2Eorg/=2C?= =?utf-8?q?_no_trust?= =?utf-8?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo2MmUgbGlzdGVkIGluXQ==?= =?utf-8?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?utf-8?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_record?= =?utf-8?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publish_an_?= =?utf-8?q?SPF_Record?= =?utf-8?q?_0=2E0_FREEMAIL=5FFROM__________Sender_email_is_commonly_abused_en?= =?utf-8?q?duser_mail?= =?utf-8?q?_provider?= =?utf-8?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?utf-8?q?_0=2E2_FREEMAIL=5FENVFROM=5FEND=5FDIGIT_Envelope-from_freemail_use?= =?utf-8?q?rname_ends?= =?utf-8?q?_in_digit?= =?utf-8?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?utf-8?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM_or_DK_?= =?utf-8?q?signature_from?= =?utf-8?q?_author=27s_domain?= =?utf-8?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_valid_DK?= =?utf-8?q?IM_or_DK_signature?= =?utf-8?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_signature?= =?utf-8?q?=2C_not_necessarily?= =?utf-8?q?_valid?= =?utf-8?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM_or_DK_?= =?utf-8?q?signature_from?= =?utf-8?q?_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+patch=linaro.org@lists.infradead.org From: Rafał Miłecki So far this feature was limited to the top-level "nvmem-cells" node. There are multiple parsers creating partitions and subpartitions dynamically. Extend that code to handle them too. This allows finding partition-* node for every MTD (sub)partition. Random example: partitions { compatible = "brcm,bcm947xx-cfe-partitions"; partition-firmware { compatible = "brcm,trx"; partition-loader { }; }; }; Cc: Christian Marangi Signed-off-by: Rafał Miłecki --- drivers/mtd/mtdcore.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 2211e0ed6cc9..07249af4f890 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -551,20 +551,22 @@ static void mtd_check_of_node(struct mtd_info *mtd) struct device_node *partitions, *parent_dn, *mtd_dn = NULL; const char *pname, *prefix = "partition-"; int plen, mtd_name_len, offset, prefix_len; - bool found = false; /* Check if MTD already has a device node */ if (mtd_get_of_node(mtd)) return; - /* Check if a partitions node exist */ if (!mtd_is_partition(mtd)) return; + parent_dn = mtd_get_of_node(mtd->parent); if (!parent_dn) return; - partitions = of_get_child_by_name(parent_dn, "partitions"); + if (mtd_is_partition(mtd->parent)) + partitions = of_node_get(parent_dn); + else + partitions = of_get_child_by_name(parent_dn, "partitions"); if (!partitions) goto exit_parent; @@ -588,19 +590,11 @@ static void mtd_check_of_node(struct mtd_info *mtd) plen = strlen(pname) - offset; if (plen == mtd_name_len && !strncmp(mtd->name, pname + offset, plen)) { - found = true; + mtd_set_of_node(mtd, mtd_dn); break; } } - if (!found) - goto exit_partitions; - - /* Set of_node only for nvmem */ - if (of_device_is_compatible(mtd_dn, "nvmem-cells")) - mtd_set_of_node(mtd, mtd_dn); - -exit_partitions: of_node_put(partitions); exit_parent: of_node_put(parent_dn);