devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>
Cc: ansuelsmth@gmail.com, linux-mtd@lists.infradead.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Rafał Miłecki" <rafal@milecki.pl>
Subject: [PATCH 2/2] mtd: core: find OF node for every MTD partition
Date: Thu,  7 Jul 2022 18:36:07 +0200	[thread overview]
Message-ID: <20220707163607.20729-2-zajec5@gmail.com> (raw)
In-Reply-To: <20220707163607.20729-1-zajec5@gmail.com>

From: Rafał Miłecki <rafal@milecki.pl>

Don't limit this feature to the "nvmem-cells". There are more cases to
this.
1. Dynamic partitions may need to be handled with parsers
   This applies to "fixed-partitions" parser and all custom ones.
2. Dynamic partitions can be handled with specific drivers
   Consider "u-boot,env" as specified in the u-boot,env.yaml.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/mtd/mtdcore.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 79c447fe30b4..f7693736dde4 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -552,7 +552,6 @@ static void mtd_check_of_node(struct mtd_info *mtd)
 	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))
@@ -588,19 +587,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);
-- 
2.34.1


  reply	other threads:[~2022-07-07 16:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 16:36 [PATCH 1/2] mtd: core: simplify (a bit) code find partition-matching dynamic OF node Rafał Miłecki
2022-07-07 16:36 ` Rafał Miłecki [this message]
2022-07-11  9:45   ` [PATCH 2/2] mtd: core: find OF node for every MTD partition Rafał Miłecki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220707163607.20729-2-zajec5@gmail.com \
    --to=zajec5@gmail.com \
    --cc=ansuelsmth@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=rafal@milecki.pl \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).