From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>,
Devicetree Compiler <devicetree-compiler@vger.kernel.org>
Subject: [PATCH v2 09/29] libfdt: Add get_property() and del_node()
Date: Fri, 6 Jul 2018 10:27:22 -0600 [thread overview]
Message-ID: <20180706162742.186950-10-sjg@chromium.org> (raw)
In-Reply-To: <20180706162742.186950-1-sjg@chromium.org>
Add support for these functions in the Python binding. This patch stands
in for a pending upstream change.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
scripts/dtc/pylibfdt/libfdt.i_shipped | 32 +++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped b/scripts/dtc/pylibfdt/libfdt.i_shipped
index 5b38e63b26..e180ee9308 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -398,6 +398,27 @@ class Fdt:
return pdata
return Property(pdata[0], pdata[1])
+ def get_property(self, nodeoffset, prop_name, quiet=()):
+ """Obtains a property by name
+
+ Args:
+ nodeoffset: Offset to the node to check
+ prop_name: Name of property to get
+ quiet: Errors to ignore (empty to raise on all errors)
+
+ Returns:
+ Property object, or None if not found
+
+ Raises:
+ FdtException on error (e.g. invalid prop_offset or device
+ tree format)
+ """
+ pdata = check_err_null(
+ fdt_get_property(self._fdt, nodeoffset, prop_name), quiet)
+ if isinstance(pdata, (int)):
+ return pdata
+ return Property(pdata[0], pdata[1])
+
@staticmethod
def create_empty_tree(size, quiet=()):
"""Create an empty device tree ready for use
@@ -632,6 +653,17 @@ class Fdt:
"""
return check_err(fdt_node_offset_by_phandle(self._fdt, phandle), quiet)
+ def del_node(self, nodeoffset):
+ """Delete a node
+
+ Args:
+ nodeoffset: Node offset containing property to delete
+
+ Raises:
+ FdtError if the node does not exist, or another error occurs
+ """
+ return check_err(fdt_del_node(self._fdt, nodeoffset))
+
class Property(bytearray):
"""Holds a device tree property name and value.
--
2.18.0.203.gfac676dfb9-goog
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot
next prev parent reply other threads:[~2018-07-06 16:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-06 16:27 [PATCH v2 00/29] binman: Add more tests and support for updating the device tree Simon Glass
2018-07-06 16:27 ` [PATCH v2 07/29] libfdt: Bring in proposed pylibfdt changes Simon Glass
2018-07-09 19:52 ` Simon Glass
2018-07-06 16:27 ` [PATCH v2 08/29] libfdt: Fix the Python pack() function Simon Glass
2018-07-09 19:52 ` Simon Glass
2018-07-06 16:27 ` Simon Glass [this message]
2018-07-09 19:52 ` [PATCH v2 09/29] libfdt: Add get_property() and del_node() Simon Glass
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=20180706162742.186950-10-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=devicetree-compiler@vger.kernel.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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).