From patchwork Tue May 10 13:12:59 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: 571223 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:66c4:0:0:0:0 with SMTP id x4csp4906196mal; Tue, 10 May 2022 06:14:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpHsXUspxZdXfVUom1tcJzM+XcfNUmPnvZ7KlW9+TIvcDGDD4GDWAzqI+5BDB7KHfh+RiR X-Received: by 2002:a17:90b:3b41:b0:1de:b313:2b27 with SMTP id ot1-20020a17090b3b4100b001deb3132b27mr1898238pjb.203.1652188459219; Tue, 10 May 2022 06:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652188459; cv=none; d=google.com; s=arc-20160816; b=uHOIRgUetFC5VkQgU31FrZ2+suv5VHRU7HEwMXrORzJTWIjCLkn4MVoRR72fhL0fIw 4VJjOnF510o/AZUuMPOU0OcAXM8dqPLCShL3pkOiQzd7bjZaT0gDXgUc6/p62AHdp2Oi muo2CYXg+5kGmGZ+ZwFasrV00p7PVXqrgA/UzEkt2xC0zSpu5HFaZxN5wOfD9FayRu9o lo8H6fGCjiSEiv1fgLdh2MTUs6hj5AVffNYAyGp7yxudQK0aADzEMePpagM56R0GbDLe j1LTbHANiUTp6RJXmsFxvhb12K/VP02UCu56criE0tg5506x2uvdXC+UHFV2qaqt3zDH LgiQ== 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=iimFJ6U2wZQtUuYQEuZtXHxdEbffDvf2ecxNug1oOsc=; b=EQF3pESNZ+bqH15TVjUiBv0cGjdxoayohfikg3woAkeiH+/7L7wj1jVA+RGQvb6VVd PdIzCVa9AvXhzSp/MX5fjoRDah2vW/DhT2foBZW3pijwfR4vZIlFt66XZdL8huZNG3gM 6aDc0NyD/egmnlqVnntbQnbXm5QpaAr++l2bANQ2Q0/vi1abyHgVto8kuoqCGKi7ONVZ 7U8lYbVEqwjIxrvhDiSREl8kv72+HeiL+xdedUORs0XYH9x5amM3L6ud9GtkVaS/drfW ujOQpiAH6A7Tg7x/XzmPnlhfaGJ73TiehM6ATusJOX2noh+/gWaF4Gtqauv8EqgNo2HI bybA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=3Lk3fdHe; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=AnRe9hbL; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::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:e::133]) by mx.google.com with ESMTPS id nv12-20020a17090b1b4c00b001ca6c627df7si3232677pjb.117.2022.05.10.06.14.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 06:14:19 -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:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=3Lk3fdHe; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=AnRe9hbL; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::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=iimFJ6U2wZQtUuYQEuZtXHxdEbffDvf2ecxNug1oOsc=; b=3Lk3fdHepO+YgG NR1lCOx2GWZDzEgD/u9rJl29/NbBKc+TWoUC+JshMswWmJBBCujRrz7nXSyJcd080PxxvYS6Je6dU dwIVgGf5Ba7lAiM8lswSVHIQApM44u/n9qeJ50FN+OhwBE6nj7/ExzV7JoVmj/24Pi86oeZn/Axuq v3q2d2eyUQX+PEAy3JKeAjqTGrQ3VSvbgFtp0C4X9e6FL6lY60xFi07rzp99agvn9AqEHES+6RKrX Hs5rGrLB/O0InulIXLmRm9oh/QsY2Ko5UTK09+qJiARyRlvKcgatUxfd/saI1RwXc9ED2SWXd4bZl tN8fi5AqId52KvEVoD8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1noPfq-0029s9-GQ; Tue, 10 May 2022 13:13:10 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1noPfn-0029qO-Fx for linux-mtd@lists.infradead.org; Tue, 10 May 2022 13:13:08 +0000 Received: by mail-ej1-x633.google.com with SMTP id m20so32843996ejj.10 for ; Tue, 10 May 2022 06:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=a8nsbDVM3+ugAvLUdOVtBpKzHJmbj2uNhbXgOFH/eJI=; b=AnRe9hbLDU4378bYA9cF2a6iUW3egeQ9QvWhmKm361s28mYdqUrA9SIcpVI4xXjwEN eTul0MaL3zQkDWl4pmybOatQSybEJ6ZZxs/1O02BGfuyP7eEeOQb+uOZfqKrkF/xA6Ek cfmgaG6nLhV7cnfSVdjsll7iUxNghIEEIyC/UXH8OVVpcsCuiBHDKI5UU4w89xq4IhOw H3SdJv6Jzww/oSvqH6/EyUlRv/AYdYcNK0wfBmiEwj5QFWEpJbHmj8KfgXCfA/JffpBQ GauqSYzSI13is2OXMdYr51tNODq1LRhWVq2tVEnXfhbtmzqYiCiTN3tM+/ERMFoVTPxI pyzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=a8nsbDVM3+ugAvLUdOVtBpKzHJmbj2uNhbXgOFH/eJI=; b=wQR+bf+p5Kx5017+/U07EwicEsUjCynWdsJRU0YJ2ash+MiKQv8FLwrlJixxCenJvm vrpfPnKEFWnQ7UwguUpH52E28/pICADvF/wWJ037qkbBGdy4kGOWZjPBucdSUIrg/JcH nuIhQB0yR0D+oKxmVJSPIoOCV5gB3GVa56nzabABxifCmtfbXPnyw5xqAVsM2v2jdG0/ LoNvyqS3AKEQVbfscUMFmFc6vVgEAqX/ukiueQBhLoipVlVvqoEVzui5gjr4uBFdGRTU n5frONHV87jUpbpO87wGVMA3eUaojPsPrGEtAkuqyTdzk9mTxTvB14zIxnGYne0dlgMJ FY1w== X-Gm-Message-State: AOAM5334+Xz7+w3/slMW6hVUAVkhuSlcTON6IdtVRvknfdRXUCoty74S yvS3EebnTBgPwKXu8W+DC8g= X-Received: by 2002:a17:906:4fd5:b0:6f8:5aa9:6f13 with SMTP id i21-20020a1709064fd500b006f85aa96f13mr15355764ejw.267.1652188385347; Tue, 10 May 2022 06:13:05 -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 q2-20020a1709064c8200b006f3ef214dccsm6110815eju.50.2022.05.10.06.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 06:13:05 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, Srinivas Kandagatla , Daniel Golle , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V3] mtd: call of_platform_populate() for MTD partitions Date: Tue, 10 May 2022 15:12:59 +0200 Message-Id: <20220510131259.555-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-20220510_061307_608911_E001179B X-CRM114-Status: GOOD ( 17.09 ) 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_U?= =?utf-8?q?ntil_this_change_MTD_subsystem_supported?= =?utf-8?q?_handling_partitions_only_with_MTD_partitions_parsers=2E_That=27s_?= =?utf-8?q?a_specific_/?= =?utf-8?q?_limited_API_designed_around_partitions=2E_Some_MTD_partitions_may?= =?utf-8?q?_however_require?= =?utf-8?q?_different_handling=2E_They_may_contain_specific_data_that_needs_t?= =?utf-8?q?o_be_parsed?= =?utf-8?q?_and_somehow_extracted=2E_For_that_purpose_MTD_subsystem_should_al?= =?utf-8?q?low_binding?= =?utf-8?b?IG9mIHN0YW5kYXIgWy4uLl0g?= =?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?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo2MzMgbGlzdGVkIGluXQ==?= =?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 Until this change MTD subsystem supported handling partitions only with MTD partitions parsers. That's a specific / limited API designed around partitions. Some MTD partitions may however require different handling. They may contain specific data that needs to be parsed and somehow extracted. For that purpose MTD subsystem should allow binding of standard platform drivers. An example can be U-Boot (sub)partition with environment variables. There exist a "u-boot,env" DT binding for MTD (sub)partition that requires an NVMEM driver. Ref: 5db1c2dbc04c ("dt-bindings: nvmem: add U-Boot environment variables binding") Signed-off-by: Rafał Miłecki --- V2: Fix case for # CONFIG_MTD_PARTITIONED_MASTER is not set master->dev can't be used blindly as it may point to unregistered device and cause WARNINGs V3: Use easier to follow logic for setting "dev" variable + add comment --- drivers/mtd/mtdpart.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 357661b62c94..d442fa94c872 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "mtdcore.h" @@ -577,10 +578,16 @@ static int mtd_part_of_parse(struct mtd_info *master, struct mtd_part_parser *parser; struct device_node *np; struct property *prop; + struct device *dev; const char *compat; const char *fixed = "fixed-partitions"; int ret, err = 0; + dev = &master->dev; + /* Use parent device (controller) if the top level MTD is not registered */ + if (!IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER) && !mtd_is_partition(master)) + dev = master->dev.parent; + np = mtd_get_of_node(master); if (mtd_is_partition(master)) of_node_get(np); @@ -593,6 +600,7 @@ static int mtd_part_of_parse(struct mtd_info *master, continue; ret = mtd_part_do_parse(parser, master, pparts, NULL); if (ret > 0) { + of_platform_populate(np, NULL, NULL, dev); of_node_put(np); return ret; } @@ -600,6 +608,7 @@ static int mtd_part_of_parse(struct mtd_info *master, if (ret < 0 && !err) err = ret; } + of_platform_populate(np, NULL, NULL, dev); of_node_put(np); /*