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 09/29] libfdt: Add get_property() and del_node()
Date: Tue, 5 Jun 2018 18:46:45 -0600 [thread overview]
Message-ID: <20180606004705.79641-10-sjg@chromium.org> (raw)
In-Reply-To: <20180606004705.79641-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>
---
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 5b38e63b267..e180ee93088 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.17.1.1185.g55be947832-goog
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot
prev parent reply other threads:[~2018-06-06 0:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 0:46 [PATCH 00/29] binman: Add more tests and support for updating the device tree Simon Glass
2018-06-06 0:46 ` [PATCH 07/29] libfdt: Bring in proposed pylibfdt changes Simon Glass
2018-06-06 0:46 ` [PATCH 08/29] libfdt: Fix the Python pack() function Simon Glass
2018-06-06 0:46 ` Simon Glass [this message]
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=20180606004705.79641-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).