From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: [PATCH v2 5/9] of: of_path: find device via partuuid
Date: Mon, 10 Jul 2017 12:33:51 +0200 [thread overview]
Message-ID: <20170710103355.15652-5-s.trumtrar@pengutronix.de> (raw)
In-Reply-To: <20170710103355.15652-1-s.trumtrar@pengutronix.de>
When a node is compatible to a fixed-partitions, support searching the
corresponding device via the partuuid, if it specified in the device tree.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
Changes since v1:
- add documentation
Documentation/devicetree/bindings/mtd/partition.txt | 21 +++++++++++++++++++++
drivers/of/of_path.c | 17 ++++++++++++++++-
2 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/mtd/partition.txt
diff --git a/Documentation/devicetree/bindings/mtd/partition.txt b/Documentation/devicetree/bindings/mtd/partition.txt
new file mode 100644
index 000000000000..ab21ff25bb11
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partition.txt
@@ -0,0 +1,21 @@
+Representing flash partitions in devicetree
+
+In addition to the upstream binding, another property is added:
+
+Optional properties:
+- partuuid : The partition UUID for this partition.
+
+
+Examples:
+
+flash@0 {
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ state_part: state {
+ partuuid = "16367da7-c518-499f-9aad-e1f366692365";
+ };
+ };
+};
diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c
index 334eab841a01..e53041b0a16c 100644
--- a/drivers/of/of_path.c
+++ b/drivers/of/of_path.c
@@ -56,11 +56,26 @@ static int __of_find_path(struct device_node *node, const char *part, char **out
dev = of_find_device_by_node_path(node->full_name);
if (!dev) {
+ int ret;
+ const char *uuid;
struct device_node *devnode = node->parent;
- if (of_device_is_compatible(devnode, "fixed-partitions"))
+ if (of_device_is_compatible(devnode, "fixed-partitions")) {
devnode = devnode->parent;
+ /* when partuuid is specified short-circuit the search for the cdev */
+ ret = of_property_read_string(node, "partuuid", &uuid);
+ if (!ret) {
+ cdev = cdev_by_partuuid(uuid);
+ if (!cdev)
+ return -ENODEV;
+
+ *outpath = basprintf("/dev/%s", cdev->name);
+
+ return 0;
+ }
+ }
+
dev = of_find_device_by_node_path(devnode->full_name);
if (!dev)
return -ENODEV;
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2017-07-10 10:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-10 10:33 [PATCH v2 1/9] state: fix compile warnings for dev_err expansion Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 2/9] common: efi: do not use undefined kconfig option Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 3/9] fs: efi: return with correct error code in efifs_stat Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 4/9] devfs-core: add function to find cdev by partuuid Steffen Trumtrar
2017-07-10 10:33 ` Steffen Trumtrar [this message]
2017-07-10 10:33 ` [PATCH v2 6/9] efi: efi: load state from devicetree Steffen Trumtrar
2017-07-10 13:49 ` Lucas Stach
2017-07-11 15:00 ` Lucas Stach
2017-07-10 10:33 ` [PATCH v2 7/9] blspec: skip all devicetree tests if entry doesn't specify one Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 8/9] efi: efi: register barebox-update handler Steffen Trumtrar
2017-07-10 10:33 ` [PATCH v2 9/9] efi_defconfig: enable STATE Steffen Trumtrar
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=20170710103355.15652-5-s.trumtrar@pengutronix.de \
--to=s.trumtrar@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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