From patchwork Tue Oct 4 08:37:09 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: 612213 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp26672pvb; Tue, 4 Oct 2022 01:38:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7hKpm/0lvX3jFi6sR9fcl3lRquQqpYmwaCyNJUubZCSEg977z6M+QZ9H0rgDtpgANxumQC X-Received: by 2002:a17:90b:384a:b0:20a:dbe3:25d7 with SMTP id nl10-20020a17090b384a00b0020adbe325d7mr1129104pjb.85.1664872693030; 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=Q6oCgBfH34LEYsS5c2GipE3RYR6KjSOGPlo40m5s+RkdZTdBgj2guRUYMVLgqJPcG2 lNyPljVztgYJARBbdu+F103S5DCmOhOcgF7tryJbAnyIiA3upqdZoLI8Nuy8uwvq1CzJ AKf7vNmW9mFlHHtBz60FPUcy9J5GcGigJ9U4/gQXHXuwmvExaS8R7XNT+XZhm+4yyxyi EpBTAMmQ/Xo/5igShOgYryT6dz0z9bxirHtKYkksIb0IogNOFaORgg7FaJbfYLfN0A9k PkxaDJFbYUWH531eDTqQxBZ6mRadXq8+SP93tgqe/jhQ2jeOFMB+QfIj0AWkV9L+VZV3 /eOA== 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:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature; bh=zd9j8QiK9rBISICjMhUmGgrBdD4BcI7l9fiQpDHxq0k=; b=QUDdx2OyHupzrnFTzSPrEw2QtC1B04lNvPbicmCLItH62mPE7JJOBnl6LEs06cbzQD zQEMB8xg/tuGTdjJhts6hGXTrtti3cCKmCaALqdr5oHdgap+RP6kY0LQ77Cm+3AbzaMY OO8lU4l9vG8w4fVQf3vyrXiajKJGHVa0TTY2o4AqaXUvtzMHq94R+W3oCkg8vC7ceuXH ktQxQyKKmJKhGCYKkcTKGcv+xvHkMKPmolMgpUHWf4QWkXvMhxPDR1EJ16QCvjqHqn+p p3babxtK/3UglYbpW3kaAXLVjh5MaUvQIfeyhM2C/wzO6fPcHoul4OuNwF3XRhe35tkb pIhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=49suF6Xy; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=IB39GjvK; 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 c16-20020a170902d49000b0017f5c8315dbsi5794613plg.359.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=49suF6Xy; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=IB39GjvK; 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: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=zd9j8QiK9rBISICjMhUmGgrBdD4BcI7l9fiQpDHxq0k=; b=49suF6XyvAbM4e wOFHUyFUBOfYICJrVuPMzqVMOByqy3DRxRYdc7mELxAUntLUqMFLrgGY4u6nWunqsMXyQJrUo4m7h aUVOyk0gz1hn60ImVh1LBgf9M/u7f9gZe+xIqfhJURy45pRqXEL+bGEhN/kFR0Hc5WQsWnjCrQ7Q+ 5j5gNNYrDLWoohBCkM7zWxLE2w+Ew0Wlfp5DP4ZcxtlT4269SmwfVmHFAzocxVtkSZF0+zQniGXbF 6+ZTjg3/43MbIEHGZtQZJK2MFusdKNHdEksSDtHnhte+mx/DUdCfirazREfxTBTfAMFVEafQ1OhYY K0qEMH3Xmrj3q22fiFgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofdQa-008yQm-FI; Tue, 04 Oct 2022 08:37:24 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofdQX-008yPX-3v for linux-mtd@lists.infradead.org; Tue, 04 Oct 2022 08:37:22 +0000 Received: by mail-ed1-x529.google.com with SMTP id s2so7261666edd.2 for ; Tue, 04 Oct 2022 01:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=kShu3JiHXeOC6qlCggCXPdZVbnNPqXavY4BcrnK5Xm4=; b=IB39GjvKSpw8yqo7YB/mEkBVWTY3fslQk1Pr3I9rSGi3MTuep5N992Nuo/RDn8cQhw kOFr+GMG7/tOszPtpOvRF7TZvul0ACRc20XmqAqhp8a100tZ+Am9zvuVs7XholdFvMDB YAqYbghk+ZcAkIWWJvZ5ksCCJ4KnRYSPwP3cJFjLXkm+iEkjZWjxkb4qknzBZjByflpv m4OwglJgaocdKWdr9SmnDVxJTFI5j9+Y8ngyM4NvGuJDXaD5w09eou3VUUXQ7QYVBTLt GjxY6XWX4OMf3p4GEU+X2ZO1QLULkXCjID8MmyDBsgMA36tb/2ly5Ga3EYmXGQ2m+ZOs X6Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=kShu3JiHXeOC6qlCggCXPdZVbnNPqXavY4BcrnK5Xm4=; b=G1hDQ/WRrS6KrOlRgiLUfg5Xi+ABM/P0WTPrLhBnumGSQTNwJu8UXutE1eq45CApwg yFiHVgwc13YNsy6gVqju6035tX2ZJuVj47nProexbnbGwjPIGHhPsrYf/Dcbs3L+DSgE oew3Sn5/eIv7maeX7xaInj/VvhzXY/DUKjSmlEgi9G2yUvNYNO1BdLk0nOsCrv3YryiX nAt1x1ge88f5q0kXh1Fw5AysOa9gpz0e0yVi52cio7goleXXS3TyC7tQBkMqiwLsYWJX q3Hu3rIpHD5ipqp9aduUed2GneXaSwCjWXziITO+AZXOqLwQYD9Srq9gFCdXVMvVxLn+ CnRw== X-Gm-Message-State: ACrzQf0MMp2WxYNjkU8fc7uyGdtkZpDCLUrhs9x77uFQh+Sg2bJHBWJV RH4zeff46WZ8A4s2JjDrEF4= X-Received: by 2002:a05:6402:33c5:b0:447:e4a3:c930 with SMTP id a5-20020a05640233c500b00447e4a3c930mr22278878edc.401.1664872638877; Tue, 04 Oct 2022 01:37:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 01:37:18 -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 1/2] mtd: core: simplify (a bit) code find partition-matching dynamic OF node Date: Tue, 4 Oct 2022 10:37:09 +0200 Message-Id: <20221004083710.27704-1-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221004_013721_182607_29F4F4EC X-CRM114-Status: GOOD ( 14.85 ) 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_1?= =?utf-8?q?=2E_Don=27t_hardcode_=22partition-=22_string?= =?utf-8?q?_twice_2=2E_Use_simpler_logic_=26_use_-=3Ename_to_avoid_of=5Fprope?= =?utf-8?q?rty=5Fread=5Fstring=28=29?= =?utf-8?q?_3=2E_Use_mtd=5Fget=5Fof=5Fnode=28=29_helper_Cc=3A_Christian_Maran?= =?utf-8?q?gi_Signed-off-by=3A_Rafa=C3=85=C2=82?= =?utf-8?q?_Mi=C3=85=C2=82ecki_---_drivers/mtd/mtdcore=2Ec_=7C_16_+++++++----?= =?utf-8?q?-----_1_file_changed=2C?= =?utf-8?q?_7_insertions=28+=29=2C_9_deletions=28-=29_?= =?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?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo1MjkgbGlzdGVkIGluXQ==?= =?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 1. Don't hardcode "partition-" string twice 2. Use simpler logic & use ->name to avoid of_property_read_string() 3. Use mtd_get_of_node() helper Cc: Christian Marangi Signed-off-by: Rafał Miłecki --- drivers/mtd/mtdcore.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 18aa54460d36..2211e0ed6cc9 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -551,18 +551,16 @@ 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; - struct mtd_info *parent; bool found = false; /* Check if MTD already has a device node */ - if (dev_of_node(&mtd->dev)) + if (mtd_get_of_node(mtd)) return; /* Check if a partitions node exist */ if (!mtd_is_partition(mtd)) return; - parent = mtd->parent; - parent_dn = dev_of_node(&parent->dev); + parent_dn = mtd_get_of_node(mtd->parent); if (!parent_dn) return; @@ -575,15 +573,15 @@ static void mtd_check_of_node(struct mtd_info *mtd) /* Search if a partition is defined with the same name */ for_each_child_of_node(partitions, mtd_dn) { - offset = 0; - /* Skip partition with no/wrong prefix */ - if (!of_node_name_prefix(mtd_dn, "partition-")) + if (!of_node_name_prefix(mtd_dn, prefix)) continue; /* Label have priority. Check that first */ - if (of_property_read_string(mtd_dn, "label", &pname)) { - of_property_read_string(mtd_dn, "name", &pname); + if (!of_property_read_string(mtd_dn, "label", &pname)) { + offset = 0; + } else { + pname = mtd_dn->name; offset = prefix_len; } 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);