* [PATCH] pylibfdt: add size_hint parameter for get_path @ 2023-02-01 18:11 Luca Weiss [not found] ` <20230201181112.1644842-1-luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Luca Weiss @ 2023-02-01 18:11 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: Luca Weiss This also enables us to test the -NOSPACE condition by adding a test setting size_hint=1 so this path is taken. --- Follow-up from "pylibfdt: add FdtRo.get_path()" from April 2022 pylibfdt/libfdt.i | 8 ++++---- tests/pylibfdt_tests.py | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i index f9f7e7e..0c80c54 100644 --- a/pylibfdt/libfdt.i +++ b/pylibfdt/libfdt.i @@ -443,11 +443,12 @@ class FdtRo(object): """ return fdt_get_alias(self._fdt, name) - def get_path(self, nodeoffset, quiet=()): + def get_path(self, nodeoffset, size_hint=1024, quiet=()): """Get the full path of a node Args: nodeoffset: Node offset to check + size_hint: Hint for size of returned string Returns: Full path to the node @@ -455,11 +456,10 @@ class FdtRo(object): Raises: FdtException if an error occurs """ - size = 1024 while True: - ret, path = fdt_get_path(self._fdt, nodeoffset, size) + ret, path = fdt_get_path(self._fdt, nodeoffset, size_hint) if ret == -NOSPACE: - size = size * 2 + size_hint *= 2 continue err = check_err(ret, quiet) if err: diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py index 68d6aaa..34c2764 100644 --- a/tests/pylibfdt_tests.py +++ b/tests/pylibfdt_tests.py @@ -354,6 +354,7 @@ class PyLibfdtBasicTests(unittest.TestCase): node2 = self.fdt.path_offset('/subnode@1/subsubnode') self.assertEqual("/subnode@1", self.fdt.get_path(node)) self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2)) + self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2, size_hint=1)) with self.assertRaises(FdtException) as e: self.fdt.get_path(-1) -- 2.39.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <20230201181112.1644842-1-luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org>]
* Re: [PATCH] pylibfdt: add size_hint parameter for get_path [not found] ` <20230201181112.1644842-1-luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> @ 2023-02-01 20:20 ` Simon Glass [not found] ` <CAPnjgZ1hHkTuAiUwxPuTeWTeJX1Sju2tnZz-pCyBY0BeW6cYhg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Simon Glass @ 2023-02-01 20:20 UTC (permalink / raw) To: Luca Weiss; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA Hi Luca, On Wed, 1 Feb 2023 at 11:16, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > This also enables us to test the -NOSPACE condition by adding a test > setting size_hint=1 so this path is taken. > --- > Follow-up from "pylibfdt: add FdtRo.get_path()" from April 2022 > > pylibfdt/libfdt.i | 8 ++++---- > tests/pylibfdt_tests.py | 1 + > 2 files changed, 5 insertions(+), 4 deletions(-) > Can you add a motivation for this? Why are the paths so long? Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i > index f9f7e7e..0c80c54 100644 > --- a/pylibfdt/libfdt.i > +++ b/pylibfdt/libfdt.i > @@ -443,11 +443,12 @@ class FdtRo(object): > """ > return fdt_get_alias(self._fdt, name) > > - def get_path(self, nodeoffset, quiet=()): > + def get_path(self, nodeoffset, size_hint=1024, quiet=()): > """Get the full path of a node > > Args: > nodeoffset: Node offset to check > + size_hint: Hint for size of returned string > > Returns: > Full path to the node > @@ -455,11 +456,10 @@ class FdtRo(object): > Raises: > FdtException if an error occurs > """ > - size = 1024 > while True: > - ret, path = fdt_get_path(self._fdt, nodeoffset, size) > + ret, path = fdt_get_path(self._fdt, nodeoffset, size_hint) > if ret == -NOSPACE: > - size = size * 2 > + size_hint *= 2 > continue > err = check_err(ret, quiet) > if err: > diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py > index 68d6aaa..34c2764 100644 > --- a/tests/pylibfdt_tests.py > +++ b/tests/pylibfdt_tests.py > @@ -354,6 +354,7 @@ class PyLibfdtBasicTests(unittest.TestCase): > node2 = self.fdt.path_offset('/subnode@1/subsubnode') > self.assertEqual("/subnode@1", self.fdt.get_path(node)) > self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2)) > + self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2, size_hint=1)) > > with self.assertRaises(FdtException) as e: > self.fdt.get_path(-1) > -- > 2.39.1 > ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAPnjgZ1hHkTuAiUwxPuTeWTeJX1Sju2tnZz-pCyBY0BeW6cYhg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] pylibfdt: add size_hint parameter for get_path [not found] ` <CAPnjgZ1hHkTuAiUwxPuTeWTeJX1Sju2tnZz-pCyBY0BeW6cYhg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2023-02-02 6:38 ` David Gibson 2023-02-02 17:08 ` Luca Weiss 0 siblings, 1 reply; 6+ messages in thread From: David Gibson @ 2023-02-02 6:38 UTC (permalink / raw) To: Simon Glass; +Cc: Luca Weiss, devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 3093 bytes --] On Wed, Feb 01, 2023 at 01:20:51PM -0700, Simon Glass wrote: > Hi Luca, > > On Wed, 1 Feb 2023 at 11:16, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > > This also enables us to test the -NOSPACE condition by adding a test > > setting size_hint=1 so this path is taken. > > --- > > Follow-up from "pylibfdt: add FdtRo.get_path()" from April 2022 > > > > pylibfdt/libfdt.i | 8 ++++---- > > tests/pylibfdt_tests.py | 1 + > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > Can you add a motivation for this? Why are the paths so long? I'm also curious about that. > Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> Code looks sane, so Reviewed-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> Unfortunately, I have no way to test this until https://github.com/dgibson/dtc/issues/78 is fixed. Also, I'll need a Signed-off-by line in order to apply this change (see CONTRIBUTING.md for details). > > > > diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i > > index f9f7e7e..0c80c54 100644 > > --- a/pylibfdt/libfdt.i > > +++ b/pylibfdt/libfdt.i > > @@ -443,11 +443,12 @@ class FdtRo(object): > > """ > > return fdt_get_alias(self._fdt, name) > > > > - def get_path(self, nodeoffset, quiet=()): > > + def get_path(self, nodeoffset, size_hint=1024, quiet=()): > > """Get the full path of a node > > > > Args: > > nodeoffset: Node offset to check > > + size_hint: Hint for size of returned string > > > > Returns: > > Full path to the node > > @@ -455,11 +456,10 @@ class FdtRo(object): > > Raises: > > FdtException if an error occurs > > """ > > - size = 1024 > > while True: > > - ret, path = fdt_get_path(self._fdt, nodeoffset, size) > > + ret, path = fdt_get_path(self._fdt, nodeoffset, size_hint) > > if ret == -NOSPACE: > > - size = size * 2 > > + size_hint *= 2 > > continue > > err = check_err(ret, quiet) > > if err: > > diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py > > index 68d6aaa..34c2764 100644 > > --- a/tests/pylibfdt_tests.py > > +++ b/tests/pylibfdt_tests.py > > @@ -354,6 +354,7 @@ class PyLibfdtBasicTests(unittest.TestCase): > > node2 = self.fdt.path_offset('/subnode@1/subsubnode') > > self.assertEqual("/subnode@1", self.fdt.get_path(node)) > > self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2)) > > + self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2, size_hint=1)) > > > > with self.assertRaises(FdtException) as e: > > self.fdt.get_path(-1) > > > -- 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 --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pylibfdt: add size_hint parameter for get_path 2023-02-02 6:38 ` David Gibson @ 2023-02-02 17:08 ` Luca Weiss [not found] ` <2060136.KlZ2vcFHjT-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Luca Weiss @ 2023-02-02 17:08 UTC (permalink / raw) To: Simon Glass, David Gibson; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA On Donnerstag, 2. Februar 2023 07:38:05 CET David Gibson wrote: > On Wed, Feb 01, 2023 at 01:20:51PM -0700, Simon Glass wrote: > > Hi Luca, > > > > On Wed, 1 Feb 2023 at 11:16, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > This also enables us to test the -NOSPACE condition by adding a test > > > setting size_hint=1 so this path is taken. > > > --- > > > Follow-up from "pylibfdt: add FdtRo.get_path()" from April 2022 > > > > > > pylibfdt/libfdt.i | 8 ++++---- > > > tests/pylibfdt_tests.py | 1 + > > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > Can you add a motivation for this? Why are the paths so long? > > I'm also curious about that. Please see this for context: https://www.spinics.net/lists/devicetree-compiler/msg03922.html Basically just for the new test. > > > Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > Code looks sane, so > > Reviewed-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> > > Unfortunately, I have no way to test this until > https://github.com/dgibson/dtc/issues/78 is fixed. > > Also, I'll need a Signed-off-by line in order to apply this change > (see CONTRIBUTING.md for details). Right. Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> If I should resend with it, please let me know. Regards Luca > > > > diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i > > > index f9f7e7e..0c80c54 100644 > > > --- a/pylibfdt/libfdt.i > > > +++ b/pylibfdt/libfdt.i > > > > > > @@ -443,11 +443,12 @@ class FdtRo(object): > > > """ > > > return fdt_get_alias(self._fdt, name) > > > > > > - def get_path(self, nodeoffset, quiet=()): > > > > > > + def get_path(self, nodeoffset, size_hint=1024, quiet=()): > > > """Get the full path of a node > > > > > > Args: > > > nodeoffset: Node offset to check > > > > > > + size_hint: Hint for size of returned string > > > > > > Returns: > > > Full path to the node > > > > > > @@ -455,11 +456,10 @@ class FdtRo(object): > > > Raises: > > > FdtException if an error occurs > > > > > > """ > > > > > > - size = 1024 > > > > > > while True: > > > - ret, path = fdt_get_path(self._fdt, nodeoffset, size) > > > + ret, path = fdt_get_path(self._fdt, nodeoffset, size_hint) > > > > > > if ret == -NOSPACE: > > > - size = size * 2 > > > + size_hint *= 2 > > > > > > continue > > > > > > err = check_err(ret, quiet) > > > > > > if err: > > > diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py > > > index 68d6aaa..34c2764 100644 > > > --- a/tests/pylibfdt_tests.py > > > +++ b/tests/pylibfdt_tests.py > > > > > > @@ -354,6 +354,7 @@ class PyLibfdtBasicTests(unittest.TestCase): > > > node2 = self.fdt.path_offset('/subnode@1/subsubnode') > > > self.assertEqual("/subnode@1", self.fdt.get_path(node)) > > > self.assertEqual("/subnode@1/subsubnode", > > > self.fdt.get_path(node2)) > > > > > > + self.assertEqual("/subnode@1/subsubnode", > > > self.fdt.get_path(node2, size_hint=1))> > > > > with self.assertRaises(FdtException) as e: > > > self.fdt.get_path(-1) ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <2060136.KlZ2vcFHjT-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org>]
* Re: [PATCH] pylibfdt: add size_hint parameter for get_path [not found] ` <2060136.KlZ2vcFHjT-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> @ 2023-02-02 17:13 ` Simon Glass 2023-02-05 6:32 ` David Gibson 1 sibling, 0 replies; 6+ messages in thread From: Simon Glass @ 2023-02-02 17:13 UTC (permalink / raw) To: Luca Weiss; +Cc: David Gibson, devicetree-compiler-u79uwXL29TY76Z2rM5mHXA Hi Luca, On Thu, 2 Feb 2023 at 10:08, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > On Donnerstag, 2. Februar 2023 07:38:05 CET David Gibson wrote: > > On Wed, Feb 01, 2023 at 01:20:51PM -0700, Simon Glass wrote: > > > Hi Luca, > > > > > > On Wed, 1 Feb 2023 at 11:16, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > > This also enables us to test the -NOSPACE condition by adding a test > > > > setting size_hint=1 so this path is taken. > > > > --- > > > > Follow-up from "pylibfdt: add FdtRo.get_path()" from April 2022 > > > > > > > > pylibfdt/libfdt.i | 8 ++++---- > > > > tests/pylibfdt_tests.py | 1 + > > > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > > > Can you add a motivation for this? Why are the paths so long? > > > > I'm also curious about that. > > Please see this for context: > https://www.spinics.net/lists/devicetree-compiler/msg03922.html > > Basically just for the new test. Got it, thanks. > > > > > > Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > > > Code looks sane, so > > > > Reviewed-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> > > > > Unfortunately, I have no way to test this until > > https://github.com/dgibson/dtc/issues/78 is fixed. > > > > Also, I'll need a Signed-off-by line in order to apply this change > > (see CONTRIBUTING.md for details). > > Right. > > Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> > > If I should resend with it, please let me know. > > Regards > Luca > > > > > > > diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i > > > > index f9f7e7e..0c80c54 100644 > > > > --- a/pylibfdt/libfdt.i > > > > +++ b/pylibfdt/libfdt.i > > > > > > > > @@ -443,11 +443,12 @@ class FdtRo(object): > > > > """ > > > > return fdt_get_alias(self._fdt, name) > > > > > > > > - def get_path(self, nodeoffset, quiet=()): > > > > > > > > + def get_path(self, nodeoffset, size_hint=1024, quiet=()): > > > > """Get the full path of a node > > > > > > > > Args: > > > > nodeoffset: Node offset to check > > > > > > > > + size_hint: Hint for size of returned string > > > > > > > > Returns: > > > > Full path to the node > > > > > > > > @@ -455,11 +456,10 @@ class FdtRo(object): > > > > Raises: > > > > FdtException if an error occurs > > > > > > > > """ > > > > > > > > - size = 1024 > > > > > > > > while True: > > > > - ret, path = fdt_get_path(self._fdt, nodeoffset, size) > > > > + ret, path = fdt_get_path(self._fdt, nodeoffset, size_hint) > > > > > > > > if ret == -NOSPACE: > > > > - size = size * 2 > > > > + size_hint *= 2 > > > > > > > > continue > > > > > > > > err = check_err(ret, quiet) > > > > > > > > if err: > > > > diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py > > > > index 68d6aaa..34c2764 100644 > > > > --- a/tests/pylibfdt_tests.py > > > > +++ b/tests/pylibfdt_tests.py > > > > > > > > @@ -354,6 +354,7 @@ class PyLibfdtBasicTests(unittest.TestCase): > > > > node2 = self.fdt.path_offset('/subnode@1/subsubnode') > > > > self.assertEqual("/subnode@1", self.fdt.get_path(node)) > > > > self.assertEqual("/subnode@1/subsubnode", > > > > self.fdt.get_path(node2)) > > > > > > > > + self.assertEqual("/subnode@1/subsubnode", > > > > self.fdt.get_path(node2, size_hint=1))> > > > > > with self.assertRaises(FdtException) as e: > > > > self.fdt.get_path(-1) Regards, Simon ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] pylibfdt: add size_hint parameter for get_path [not found] ` <2060136.KlZ2vcFHjT-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> 2023-02-02 17:13 ` Simon Glass @ 2023-02-05 6:32 ` David Gibson 1 sibling, 0 replies; 6+ messages in thread From: David Gibson @ 2023-02-05 6:32 UTC (permalink / raw) To: Luca Weiss; +Cc: Simon Glass, devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1996 bytes --] On Thu, Feb 02, 2023 at 06:08:20PM +0100, Luca Weiss wrote: > On Donnerstag, 2. Februar 2023 07:38:05 CET David Gibson wrote: > > On Wed, Feb 01, 2023 at 01:20:51PM -0700, Simon Glass wrote: > > > Hi Luca, > > > > > > On Wed, 1 Feb 2023 at 11:16, Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> wrote: > > > > This also enables us to test the -NOSPACE condition by adding a test > > > > setting size_hint=1 so this path is taken. > > > > --- > > > > Follow-up from "pylibfdt: add FdtRo.get_path()" from April 2022 > > > > > > > > pylibfdt/libfdt.i | 8 ++++---- > > > > tests/pylibfdt_tests.py | 1 + > > > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > > > Can you add a motivation for this? Why are the paths so long? > > > > I'm also curious about that. > > Please see this for context: > https://www.spinics.net/lists/devicetree-compiler/msg03922.html > > Basically just for the new test. Ah, ok, I'd forgotten that discussion, sorry. > > > Reviewed-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > > > Code looks sane, so > > > > Reviewed-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> > > > > Unfortunately, I have no way to test this until > > https://github.com/dgibson/dtc/issues/78 is fixed. So, turns out this was triggered by something bogus in my git state. I'm not sure what went wrong in the first place, but I've gotten around it by making myself a new clone. > > Also, I'll need a Signed-off-by line in order to apply this change > > (see CONTRIBUTING.md for details). > > Right. > > Signed-off-by: Luca Weiss <luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> > > If I should resend with it, please let me know. That will do, thanks. Applied. -- 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 --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-05 6:32 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-02-01 18:11 [PATCH] pylibfdt: add size_hint parameter for get_path Luca Weiss [not found] ` <20230201181112.1644842-1-luca-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> 2023-02-01 20:20 ` Simon Glass [not found] ` <CAPnjgZ1hHkTuAiUwxPuTeWTeJX1Sju2tnZz-pCyBY0BeW6cYhg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2023-02-02 6:38 ` David Gibson 2023-02-02 17:08 ` Luca Weiss [not found] ` <2060136.KlZ2vcFHjT-IfPCFPJWly+lVyrhU4qvOw@public.gmane.org> 2023-02-02 17:13 ` Simon Glass 2023-02-05 6:32 ` David Gibson
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).