From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
hg-K0bRW+63XPQe6aEkudXLsA@public.gmane.org
Cc: Devicetree Compiler
<devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 07/10] pylibfdt: Add a method to access the device tree directly
Date: Mon, 21 Aug 2017 10:17:14 +1000 [thread overview]
Message-ID: <20170821001714.GC12356@umbus.fritz.box> (raw)
In-Reply-To: <20170819171803.195806-7-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2472 bytes --]
On Sat, Aug 19, 2017 at 11:18:00AM -0600, Simon Glass wrote:
> When calling libfdt functions which are not supported by the Fdt class it
> is necessary to get direct access to the device tree data. At present this
> requries using the internal _fdt member. Add a new method to provide
> public access to this.
>
> Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
I've applied patches 1-6 already.
This looks fine, except I'm dubious about the name. "get_fdt" from an
fdt object seems a bit.. tautological? How about "as_bytestring"?
> ---
>
> pylibfdt/libfdt.i | 11 +++++++++++
> tests/pylibfdt_tests.py | 5 +++--
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
> index d492d58..1f6809e 100644
> --- a/pylibfdt/libfdt.i
> +++ b/pylibfdt/libfdt.i
> @@ -174,6 +174,17 @@ class Fdt:
> self._fdt = bytearray(data)
> check_err(fdt_check_header(self._fdt));
>
> + def get_fdt(self):
> + """Get the device tree contents as a bytearray
> +
> + This can be passed directly to libfdt functions that access a
> + const void * for the device tree.
> +
> + Returns:
> + bytearray containing the device tree
> + """
> + return self._fdt
> +
> def path_offset(self, path, quiet=()):
> """Get the offset for a given path
>
> diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
> index 8028c1a..a775d37 100644
> --- a/tests/pylibfdt_tests.py
> +++ b/tests/pylibfdt_tests.py
> @@ -285,9 +285,10 @@ class PyLibfdtTests(unittest.TestCase):
>
> def testIntegers(self):
> """Check that integers can be passed and returned"""
> - self.assertEquals(0, libfdt.fdt_get_phandle(self.fdt._fdt, 0))
> + self.assertEquals(0, libfdt.fdt_get_phandle(self.fdt.get_fdt(), 0))
> node2 = self.fdt.path_offset('/subnode@2')
> - self.assertEquals(0x2000, libfdt.fdt_get_phandle(self.fdt._fdt, node2))
> + self.assertEquals(0x2000,
> + libfdt.fdt_get_phandle(self.fdt.get_fdt(), node2))
>
> def testGetPhandle(self):
> """Test for the get_phandle() method"""
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-08-21 0:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-19 17:17 [PATCH 01/10] pylibfdt: Add a test for use of uint32_t Simon Glass
[not found] ` <20170819171803.195806-1-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2017-08-19 17:17 ` [PATCH 02/10] pylibfdt: Use local pylibfdt module Simon Glass
2017-08-19 17:17 ` [PATCH 03/10] tests: Return a failure code when any tests fail Simon Glass
2017-08-19 17:17 ` [PATCH 04/10] pylibfdt: Add support for fdt_get_phandle() Simon Glass
2017-08-19 17:17 ` [PATCH 05/10] pylibfdt: Add support for fdt_parent_offset() Simon Glass
2017-08-19 17:17 ` [PATCH 06/10] pylibfdt: Add support for fdt_node_offset_by_phandle() Simon Glass
2017-08-19 17:18 ` [PATCH 07/10] pylibfdt: Add a method to access the device tree directly Simon Glass
[not found] ` <20170819171803.195806-7-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2017-08-21 0:17 ` David Gibson [this message]
[not found] ` <20170821001714.GC12356-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-08-21 3:04 ` Simon Glass
2017-08-19 17:18 ` [PATCH 08/10] pylibfdt: Add support for fdt_subnode_offset() Simon Glass
2017-08-19 17:18 ` [PATCH 09/10] README: Add a note about test_tree1.dts Simon Glass
[not found] ` <20170819171803.195806-9-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2017-08-21 0:25 ` David Gibson
[not found] ` <20170821002557.GD12356-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-08-22 13:39 ` Simon Glass
[not found] ` <CAPnjgZ05qhg5hLAtRGS89qEcrPyfYXtJSjQTzaR0y8z4YOUvQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-23 0:36 ` David Gibson
2017-08-19 17:18 ` [PATCH 10/10] pylibfdt: Allow reading integer values from properties 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=20170821001714.GC12356@umbus.fritz.box \
--to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hg-K0bRW+63XPQe6aEkudXLsA@public.gmane.org \
--cc=sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.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;
as well as URLs for NNTP newsgroup(s).