All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Charkov <alchark@flipper.net>
To: u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>,
	 David Gibson <david@gibson.dropbear.id.au>,
	Luca Weiss <luca@z3ntu.xyz>,
	 Brandon Maier <brandon.maier@gmail.com>,
	 Francesco Valla <francesco@valla.it>,
	Simon Glass <sjg@chromium.org>,  Rob Herring <robh@kernel.org>,
	Jaipaul Cheernam <jaipaul.cheernam@est.tech>,
	 Alexey Charkov <alchark@flipper.net>
Subject: [PATCH 08/17] pylibfdt: Add size_hint parameter for get_path
Date: Mon, 24 Aug 2026 17:13:05 +0400	[thread overview]
Message-ID: <20260824-pylibfdt-sync-v1-8-a42be6fa4872@flipper.net> (raw)
In-Reply-To: <20260824-pylibfdt-sync-v1-0-a42be6fa4872@flipper.net>

From: Luca Weiss <luca@z3ntu.xyz>

Let the caller pick the initial buffer size, which also makes the
-NOSPACE retry path reachable from a test by passing a tiny hint.

This is a backport of dtc commit 3f29d6d85c24 ("pylibfdt: add size_hint
parameter for get_path").

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[adapt to U-Boot]
Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
 scripts/dtc/pylibfdt/libfdt.i_shipped | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped b/scripts/dtc/pylibfdt/libfdt.i_shipped
index 2a7fdfb2af40..6a900265459d 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -447,11 +447,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
@@ -459,11 +460,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:

-- 
2.54.0


  parent reply	other threads:[~2026-08-24 13:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 13:12 [PATCH 00/17] pylibfdt: Update the U-Boot version with changes from upstream dtc Alexey Charkov
2026-08-24 13:12 ` [PATCH 01/17] pylibfdt: Cast property length to Py_ssize_t Alexey Charkov
2026-08-24 13:12 ` [PATCH 02/17] pylibfdt: Restore the upstream bytearray() in getprop() Alexey Charkov
2026-08-24 13:13 ` [PATCH 03/17] pylibfdt: Fix Python crash on getprop deallocation Alexey Charkov
2026-08-24 13:13 ` [PATCH 04/17] pylibfdt: Add Property.as_stringlist() Alexey Charkov
2026-08-24 13:13 ` [PATCH 05/17] pylibfdt: Add Property.as_*int*_array() Alexey Charkov
2026-08-24 13:13 ` [PATCH 06/17] pylibfdt: Add FdtRo.get_path() Alexey Charkov
2026-08-24 13:13 ` [PATCH 07/17] pylibfdt: Work-around SWIG limitations with flexible arrays Alexey Charkov
2026-08-24 13:13 ` Alexey Charkov [this message]
2026-08-24 13:13 ` [PATCH 09/17] pylibfdt: Support boolean properties Alexey Charkov
2026-08-24 13:13 ` [PATCH 10/17] pylibfdt: Fix get_mem_rsv for newer Python versions Alexey Charkov
2026-08-24 13:13 ` [PATCH 11/17] pylibfdt: Fix backwards compatibility of return values Alexey Charkov
2026-08-24 13:13 ` [PATCH 12/17] pylibfdt: Fix a typo in the next_node() docstring Alexey Charkov
2026-08-24 13:13 ` [PATCH 13/17] pylibfdt: Grow the FdtSw buffer geometrically Alexey Charkov
2026-08-24 13:13 ` [PATCH 14/17] pylibfdt: Add address_cells() and size_cells() Alexey Charkov
2026-08-24 13:13 ` [PATCH 15/17] pylibfdt: Add add_mem_rsv() and del_mem_rsv() Alexey Charkov
2026-08-24 13:13 ` [PATCH 16/17] pylibfdt: Document that FdtSw.property() takes bytes Alexey Charkov
2026-08-24 13:13 ` [PATCH 17/17] dtoc: Add tests for the pylibfdt bindings dtoc does not use Alexey Charkov
2026-08-24 18:16 ` [PATCH 00/17] pylibfdt: Update the U-Boot version with changes from upstream dtc Tom Rini
2026-09-01  2:13 ` Tom Rini

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=20260824-pylibfdt-sync-v1-8-a42be6fa4872@flipper.net \
    --to=alchark@flipper.net \
    --cc=brandon.maier@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=francesco@valla.it \
    --cc=jaipaul.cheernam@est.tech \
    --cc=luca@z3ntu.xyz \
    --cc=robh@kernel.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.